Ask Your Question
1

stuck with numerical integration

asked 2020-05-01 22:57:17 +0200

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
2

answered 2020-05-02 17:43:01 +0200

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

Comments

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

polka125 gravatar imagepolka125 ( 2020-05-02 18:30:23 +0200 )edit
1

answered 2020-05-03 02:02:02 +0200

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
1

answered 2020-05-02 18:52:05 +0200

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

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2020-05-01 22:57:17 +0200

Seen: 67 times

Last updated: May 03 '20