Ask Your Question

stuck with numerical integration

asked 2020-05-01 15:57:17 -0600

polka125 gravatar image

When I try something like

integral_numerical(bessel_I(0, x), (x, 0, 1))

I get

TypeError: Cannot evaluate symbolic expression to a numeric value.

So my question is: how to integrate numerically special functions?

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted

answered 2020-05-02 10:43:01 -0600

Sébastien gravatar image

According to the documentation of integral_numerical, the correct syntax is:

sage: integral_numerical(bessel_I(0,x), 0, 1)
(1.0865210970235897, 1.206280738656573e-14)
edit flag offensive delete link more


Thank you! This answers my question. I have to read the documentation more carefully

polka125 gravatar imagepolka125 ( 2020-05-02 11:30:23 -0600 )edit

answered 2020-05-02 11:52:05 -0600

Juanjo gravatar image

In addition to integral_numerical, it is possible to use the nintegrate method:

sage: bessel_I(0,x).nintegrate(x, 0, 1)
(1.08652109702359, 1.206280738656574e-14, 21, 0)

The output provides the value of the integral, an error estimate, the times that the function is evaluated and an error code (0 means "no problem encountered"). Write

sage: sage.calculus.calculus.nintegral?

for more information.

edit flag offensive delete link more

answered 2020-05-02 19:02:02 -0600

slelievre gravatar image

Using a lambda function also works:

sage: integral_numerical(lambda x: bessel_I(0, x), (0, 1))
(1.0865210970235897, 1.206280738656573e-14)

Besides numerical integration, lambda functions are often helpful for plotting.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2020-05-01 15:57:17 -0600

Seen: 55 times

Last updated: May 02