Simplification of exponential and trigonometric expression



Thank you very much for your help (and for introducing me to the 
function scanmap).

I made a couple of mistakes (now fixed) in the normalizations of q:

define(Wvac(x,p), 2/(%pi) * exp(-2*(x^2+p^2)))$
define(Wsq(x,p), Wvac(exp(-r)*(cos(theta/2)*x + sin(theta/2)*p), 
exp(+r)*(-sin(theta/2)*x + cos(theta/2)*p)))$
define(Wsqd(x,p), Wsq(x-a*cos(phi),p-a*sin(phi)))$
define(W(x,p), Wsqd(cos(psi)*x-sin(psi)*p,sin(psi)*x+cos(psi)*p))$
assume(A<0)$
F : integrate(2/(%pi)*exp(A*p^2+B*p+C), p, minf, inf)$
l : makelist(coeff(expand(log(%pi/2*W(x,p))),p,n),n,0,2)$
define(q(x,a,phi,r,theta,psi), (trigreduce(trigexpand(subst([A = l[3], B 
= l[2], C = l[1]], F)))));

and of p:

xavg(a,psi,phi) := a*cos(psi-phi)$
sigma2(r,theta,psi) := 
%e^(2*r)*cos(psi-theta/2)^2+%e^(-2*r)*sin(psi-theta/2)^2$
define(p(x,a,phi,r,theta,psi), sqrt(2/(%pi*sigma2(r,theta,psi))) * 
exp(-2*(x-xavg(a,psi,phi))^2/sigma2(r,theta,psi)));

so that now

qq: q(x,a,phi,r,theta,psi)$
pp: p(x,a,phi,r,theta,psi)$
qq1: scanmap(factor,trigreduce(qq));
pp1: scanmap(factor,trigreduce(pp));

qq1 and pp1 are equivalent.

Is there any way to ask Maxima to simplify q(x,a,phi,r,theta,psi) into 
the nicer form of p(x,a,phi,r,theta,psi)?

It may sound pointless as we already know the two functions are the 
same, but I would really like to learn how to do smart simplification in 
Maxima.

Thanks a lot,

Michele


On 09/30/2012 12:51 AM, Stavros Macrakis wrote:
> First of all, your functions don't seem to be equal:
>
> q(0,0,0,0,0,0) => 1/sqrt(%pi)
> p(0,0,0,0,0,0) => sqrt(2)/sqrt(%pi)
>
> Let's put them in similar forms to see the differences:
>
> qq: q(x,a,phi,r,theta,psi)$
> pp: p(x,a,phi,r,theta,psi)$
>
> qq1: scanmap(factor,trigreduce(qq));
> pp1: scanmap(factor,trigreduce(pp));
>
> You can also look at radcan(qq1) and radcan(pp1).
>
> Looking over the two expressions, I see quite a few differences, though the
> structure is the same.  Quite a few coefficients are different (factor of
> -1, factor of 2) and it seems unlikely (at a quick glance) that these
> cancel.
>
>                    -s
>
>
> On Sat, Sep 29, 2012 at 4:19 AM, Michele Dall'Arno <
> michele.dallarno at gmail.com> wrote:
>
>> Hello,
>>
>> I know that the function q(x,a,phi,r,theta,psi) defined as
>>
>> define(Wvac(x,p), 1/(%pi) * exp(-(x^2+p^2)))$
>> define(Wsq(x,p), Wvac(exp(-r)*(cos(theta/2)*x + sin(theta/2)*p),
>> exp(r)*(-sin(theta/2)*x + cos(theta/2)*p)))$
>> define(Wsqd(x,p), Wsq(x-a*cos(phi),p-a*sin(phi))**)$
>> define(W(x,p), Wsqd(cos(psi)*x-sin(psi)*p,**sin(psi)*x+cos(psi)*p))$
>> assume(A<0)$
>> F : integrate(1/(%pi)*exp(A*p^2+B***p+C), p, minf, inf)$
>> l : makelist(coeff(expand(log(%pi***W(x,p))),p,n),n,0,2)$
>> define(q(x,a,phi,r,theta,psi), (trigreduce(trigexpand(subst([**A = l[3],
>> B = l[2], C = l[1]], F)))));
>>
>> is equivalent to the function p(x,a,phi,r,theta,psi) defined as
>>
>> xavg(a,psi,phi) := a*cos(psi-phi)$
>> sigma2(r,theta,psi) := %e^((-2)*r)*cos(psi-theta/2)^**
>> 2+%e^(2*r)*sin(psi-theta/2)^2$
>> define(p(x,a,phi,r,theta,psi), sqrt(2/(%pi*sigma2(r,theta,**psi))) *
>> exp(-2*(x-xavg(a,psi,phi))^2/**sigma2(r,theta,psi)));
>>
>> but I am not able to simplify q to the form of p. Can you help me?
>>
>> Thank you,
>>
>> Michele
>> ______________________________**_________________
>> Maxima mailing list
>> Maxima at math.utexas.edu
>> http://www.math.utexas.edu/**mailman/listinfo/maxima<http://www.math.utexas.edu/mailman/listinfo/maxima>;
>>
>