Subject: problem with integration of gaussian distribution
From: Leo Butler
Date: Wed, 8 Jul 2009 03:36:59 +0100 (BST)
On Tue, 7 Jul 2009, Riemann, Robert wrote:
< Thanks for the hints to collectterms and ratsubst.
<
< I got done the integration with the following code
< (with wxmaxima, %o6 is used!):
<
<
< phi(p) := A*exp(-(p-p_0)^2/(h/d)^2);
< phi(p)*(2*%pi*h)^(-1)*exp(%i/h*(p*x-p^2/(2*m)*t));
< ratsubst(exp(c),A/(2*%pi*h),%);
< collectterms(expand(log(%)),p);
< ratsubst(a1,((%i*x)/h+(2*d^2*p_0)/h^2),%);
< ratsubst(a2,(-(%i*t)/(2*h*m)-d^2/h^2),%);
< ratsubst(a0,(d^2*p_0^2)/h^2+c,%);
< assume(a2 < 0)$
< integrate(exp(%o7),p,minf,inf);
< ratsubst(((%i*x)/h+(2*d^2*p_0)/h^2),a1,%);
< ratsubst((-(%i*t)/(2*h*m)-d^2/h^2),a2,%);
< ratsubst((d^2*p_0^2)/h^2+c,a0,%);
< psi(x,t) := ''%;
<
<
< To make it perfect:
<
< Is there a way to simplify the re-substitution?
Yes, map and coeff will do most of the work for you. Here is an example
where we create a polynomial, change its first and second degree
coefficients and change them back:
(%i2) f : sum('a[i]*x^i,i,0,4);
(%o2) 'a[4]*x^4+'a[3]*x^3+'a[2]*x^2+'a[1]*x+'a[0]
(%i3) map(lambda([i],c[i]=coeff(f,x,i)),[1,2]);
(%o3) [c[1] = 'a[1],c[2] = 'a[2]]
(%i4) g : f$ for r in %o3 do ( g : ratsubst(lhs(r),rhs(r),g) )$
(%i6) g;
(%o6) 'a[4]*x^4+'a[3]*x^3+c[2]*x^2+c[1]*x+'a[0]
(%i7) for r in %o3 do ( g : ratsubst(rhs(r),lhs(r),g) )$
(%i8) g;
(%o8) 'a[4]*x^4+'a[3]*x^3+'a[2]*x^2+'a[1]*x+'a[0]
< Is there a simple way to expand and collect the term in exp(...) to get psi
< in something like a bell-shaped curve?
Yes, you really want to do to psi(x,t) what you did to the original
integrand.
Leo
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.