On 2/23/11 11:14 PM, Ronald L. Rivest wrote:
Let  f(x,y)  be a function such that
     integral(f(x,y),y,0,x)
doesn't evaluate to anything simpler, such as
     f(x,y) = (y+1)  ^ (y+1) ^ x

How can I then compute the (definite) integral of f over the region
     0<= y<= x<= 1

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.  And
    numerical_integral(integral(f(x,y),y,0,x),0,1)
doesn't work either, since the inner integral doesn't evaluate.

I couldn't find guidance on this in the documentation or elsewhere...
(Please let me know if this request should be posted elsewhere instead
of here...)


You might try using scipy to do this numerical integral. See http://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.dblquad.html#scipy.integrate.dblquad for documentation of the function. Here is your example, I think:

sage: f(y,x) = (y+1)  ^ (y+1) ^ x
sage: from scipy.integrate import dblquad
sage: dblquad(f,0,1,lambda x: 0, lambda x: x)
(0.76066264344246226, 8.4450518072205739e-15)

This matches up with Mathematica:

NIntegrate[f[x, y], {x, 0, 1}, {y, 0, x}] gives 0.760663

Note that for scipy, the function must take two arguments, the first being the *y* value, and the second being the x value.

Thanks,

Jason


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

Reply via email to