Ask Your Question

How to do numerical integral where the answer still have variables in it?

asked 2018-02-21 15:13:07 -0500

Sarah gravatar image

updated 2018-02-21 17:09:27 -0500

I typed in

"numerical_integral(lambda d:exp(-(h-1)^2-(d-2)^2), 0,Infinity)"

and got

"unable to simplify to float approximation"

Are there anyway to compute the integral numerically and still leave a variable in the answer? Thanks,

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-02-21 18:09:03 -0500

tmonteil gravatar image

updated 2018-02-21 18:10:25 -0500

The general answer is no. In your case, you can easily isolate h and d since $exp(x+y)=exp(x)+exp(y)$. Note also that the integral can be computed symbolically:

sage: var('d h')
(d, h)
sage: integral(exp(-(h-1)^2-(d-2)^2), d,0,Infinity)
1/2*sqrt(pi)*erf(2)*e^(-h^2 + 2*h - 1) + 1/2*sqrt(pi)*e^(-h^2 + 2*h - 1)
edit flag offensive delete link more


since exp(x+y)=exp(x)+exp(y)

Huh ? I didn't know that.

I'll have to get back to high school. Damn...

More seriously, this is the typo of the death...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2018-02-23 00:51:36 -0500 )edit

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: 2018-02-21 15:13:07 -0500

Seen: 30 times

Last updated: Feb 21