On Dec 4, 2008, at 9:38 PM, Jason Grout wrote:
Robert Dodier wrote:On Dec 4, 2:04 pm, "William Stein" <[EMAIL PROTECTED]> wrote:sage: f.n() and get back a floating point number. This is surprisingly not implemented in Sage, but it isn't. (That's basically because Maxima itself doesn't seem to have such functionality.)I'm guessing that f.n() just turns on the numer flag for Maxima. numer causes any literal numbers or symbolic constants to be replaced by floating point values. However the integrate function is called as without numer. If you want a numerical integration, call quad_qags or some other Quadpack function.FYI, scipy has numerical integration, based on quadpack: http://docs.scipy.org/doc/scipy/reference/integrate.html sage: from scipy.integrate import quad sage: f(x) = 250*cos(pi*x/180)^1.8 + 170.35 sage: from sage.ext.fast_eval import fast_float sage: ff = fast_float(f, 'x') sage: quad(ff,0,18) (7435.2795815640284, 8.2548185859776835e-11) sage: timeit('quad(ff,0,18)') 625 loops, best of 3: 118 µs per loopThere are lots of options you can pass. If you want an infinite limit,then, use scipy.integrate.Inf. It sounds like it would be good to use this if we wanted a numerical approximation of an integral. Jason
Is there an easy way to get the integrand, variable and bounds out of the
integral? That way, if one has tried to analytically evaluate it, they can pull it out and try numerically evaluating it easily. In fact, it probably could be done automatically. Cheers, Tim. --- Tim Lahey PhD Candidate, Systems Design Engineering University of Waterloo http://www.linkedin.com/in/timlahey
smime.p7s
Description: S/MIME cryptographic signature