Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
0

Strange behviour when trying to integrate gaussian function. bug?

asked 14 years ago

Shashank gravatar image

updated 14 years ago

I was trying integrate the following function

y=var('y')
integrate(x*exp(-(x-y)*(x-y)*2.0),x)

18(2(erf(2(xy)2)1)(xy)πy(xy)22e(2(xy)2))2 The integral can easily be done by redefining variables and does not have to be expressed in terms of error functions. Also the behavior of sage becomes even strange when I change the coefficient from 2.0 to 2.1. Sage just refuses to do the integral

integrate(x*exp(-(x-y)*(x-y)*2.1),x)

xe(2.1(xy)2)dx

Any ideas on how to make sage give an answer in the usual exponential form?

Edit: Sorry. My bad. It is an error function. However, I expect error function even for the second example, when I replace 2 by 2.1. Any ideas why that is the case?

Preview: (hide)

Comments

Could you be specific about the transformation you have in mind? As usual, I'm missing something-- I can't see how to do it without an erf popping up. (And you should expect this comment to vanish after I realize how stupid I was. :^)

DSM gravatar imageDSM ( 14 years ago )

@DSM - no need to make comments vanish, that's part of the open development process, to keep a record of everyone's thoughts. "Stupid" comments may later turn out to be prescient.

kcrisman gravatar imagekcrisman ( 14 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 14 years ago

kcrisman gravatar image

updated 14 years ago

I assume this is still not what you want, as it doesn't use any substitution as you suggest, but it does seem to work:

sage: integrate(x*exp(-(x-y)*(x-y)*2.1),x)
-1/882*I*(21*I*(erf(sqrt(21/10)*sqrt((x - y)^2)) - 1)*(x - y)*sqrt(pi)*y/sqrt((x - y)^2) - I*sqrt(10)*sqrt(21)*e^(-21/10*(x - y)^2))*sqrt(10)*sqrt(21)

This is coming from Maxima, of course.

1882i(21i(erf(2110(xy)2)1)(xy)πy(xy)2i1021e(2110(xy)2))1021

If I do simplify_full() to the answer, I get something that looks like

1882(1037e(215xy)+21(25ye(2110x2+2110y2)erf(110(37x37y)25)25ye(2110x2+2110y2))π)37e(2110x22110y2)

which is still messy but at least doesn't have any imaginary components. Is this not sufficient?

Preview: (hide)
link

Comments

Can you elaborate on how you got the quoted answer? I am still getting this as the output \int x e^{\left(-2.1 \, {\left(x - y\right)}^{2}\right)}\,{d x}

Shashank gravatar imageShashank ( 14 years ago )

I literally typed integrate(x*exp(-(x-y)*(x-y)*2.1),x). If you do A=integrate(x*exp(-(x-y)*(x-y)*2.1),x), and then A.simplify_full(), you get the last thing. What version of Sage are you using? Maxima has steadily improved its integration ability, and we try to keep up with it.

kcrisman gravatar imagekcrisman ( 14 years ago )

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: 14 years ago

Seen: 1,262 times

Last updated: Feb 15 '11