On Thu, Feb 24, 2011 at 1:14 PM, Ronald L. Rivest <[email protected]> wrote:

> I want a numeric integration, but
>    numerical_integral(numerical_integral(f,0,x),0,1)
> doesn't work, since f takes two parameters, not one.

IIUY, you could nest it, and do

sage: numerical_integral(lambda x: numerical_integral(lambda y:
(y+1)^(y+1)^x,(0,x))[0],(0,1))
(0.76066264344246259, 8.4450518072205787e-15)

or

sage: import mpmath
sage: f = mpmath.quad(lambda x: mpmath.quad(lambda y: (y+1)^ (y+1)^
x,(0,x)),(0,1))
sage: f
mpf('0.76066264344246248')

I like mpmath because I more often want the increased accuracy than I
care about the decrease in speed.

sage: mpmath.mp.dps = 50
sage: f = mpmath.quad(lambda x: mpmath.quad(lambda y: (y+1)^ (y+1)^
x,(0,x)),(0,1))
sage: f
mpf('0.76066264344246243183604278581374359729636608721856373')

But since flat is better than nested, I think something like

numerical_integral(f, (x,0,3), (y,0,x^2))

should Just Work(tm).


Doug

--
Department of Earth Sciences
University of Hong Kong

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to