Paul Kienzle wrote: > This is improved somewhat as: > > import numpy as N > res = N.sqrt(2*N.sin(N.pi*x**2) + N.cos(x**2) - N.exp(2*N.pi*1j)) > > but the following is better: > > from mpl.math import * > res = sqrt(2*sin(pi*x**2) + cos(x**2) - exp(2*pi*1j))
quite true. Interestingly, I find that expressions like that are not a large fraction of my code these days -- maybe that's a bad thing, I used to do math! > Can we create a math.py which makes a standard set of math functions > available? You're right that for math expressions, it is nice to have them in the namespace, so this is used a lot: from numpy import sqrt, sin, cos, exp Maybe it's a reasonable idea to write a Nmath.py, which would have an import line like that. Out of 491 names in the numpy namespace, I found 26 that would commonly be found in math expressions. Not bad, really, much better than including all 491. Inf NaN abs angle arccos arccosh arcsin arcsinh arctan arctan2 arctanh cos cosh exp log log10 pi sign sin sinc sinh sqrt square tan tanh > I'm guessing a function sqrt(-1.) which returns 1j is out of the question? what's wrong with "1j" as a literal? -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel