Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The following works for me:

sage: numerical_integral( lambda x: x^(-2/3), (0,1) )
(2.99999987764845, 2.578819502242948e-06)
sage: numerical_integral( lambda x: (1-x)^(-2/3), (0,1) )
0.0 cannot be raised to a negative power
0.0 cannot be raised to a negative power
0.0 cannot be raised to a negative power
0.0 cannot be raised to a negative power
0.0 cannot be raised to a negative power
0.0 cannot be raised to a negative power
(2.999988120409371, 3.768990092235661e-05)

Here, numerical_integral gets a (true pythonic) function, a "callable object" as its first argument. There are seldom problems with such an input. Expressions instead of callables are sometimes a problem for the numerical_integral.

Note: Related numerical integral, that goes to maxima and uses expressions:

sage: (x^(-2/3)).nintegral(x,0,1)
(3.000000000000006, 3.01980662698043e-14, 231, 0)
sage: ((1-x)^(-2/3)).nintegral(x,0,1)
(3.000000000002707, 8.78142003557514e-12, 231, 0)