Stripping out coefficients of Fourier series




On Tue, 2 Jun 2009, Dan Hatton wrote:

< On Mon, 1 Jun 2009, Dan Hatton wrote:
< 
< > Imagine I have some three-dimensional Fourier series like
< > series : (complicated_expression_1)*cos(3*z)*cos(3*x)*cos(y)
< > 		+(complicated_expression_2)*cos(2*z)*cos(2*x)*cos(2*y) ;
< > (only with rather more than two Fourier components).
< > complicated_expression_1 and complicated_expression_2 are free of x,
< > y, and z.
< > I know the Fourier series is zero for all (x,y,z) - from which I infer
< > that complicated_expression_1 and complicated_expression_2 are zero
< > individually.  So I'd like to do some algebraic manipulations with the
< > equations
< > complicated_expression_1 = 0 ;
< > complicated_expression_2 = 0 ;
< > but first I have to be able to extract complicated_expression_1 and
< > complicated_expression_2 from series.  Is there a Maxima function I
< > can apply to series to achieve this, please?
< 
< Oh, what a fool I am... I just realized I can take advantage of the
< orthogonality of the Fourier components, so the following should do
< the job, albeit at the expense of quite a bit of CPU time:
< 
< integrate(integrate(integrate(series*cos(3*x)*cos(y)*cos(3*z),z,0,2*%pi),y,0,2*%pi),x,0,2*%pi)/%pi^2 = 0 ;
< integrate(integrate(integrate(series*cos(2*x)*cos(2*y)*cos(2*z),z,0,2*%pi),y,0,2*%pi),x,0,2*%pi)/%pi^2 = 0 ;



Let maxima work for you to recover the coeffs. All we need to know is
that the junk we want to strip off is a cos/sin of an integer multiple
of x, y or z:

(%i2) expr : cos(a)*sin(b)*cos(x)*cos(3*y)*sin(5*z)$

(%i3) strip(expr) := block([t:args(expr),u], u:part(t,1),
if(mod(u,x)*mod(u,y)*mod(u,z)=0) then 1 else expr)$

/* oops, a typo, but the output is informative */
(%i4) map(lambda([t], if atom(t) then t else stripc(t)),expr);
(%o4) stripc(cos(a))*stripc(sin(b))*stripc(cos(x))*stripc(cos(3*y))
			    *stripc(sin(5*z))
(%i5) subst(stripc=strip,%o4);
(%o5) strip(cos(a))*strip(sin(b))*strip(cos(x))*strip(cos(3*y))
                   *strip(sin(5*z))
(%i6) ev(%,nouns);
(%o6) cos(a)*sin(b)

/* or directly, without the typo */
(%i7) map(lambda([t], if atom(t) then t else strip(t)),expr);
(%o7) cos(a)*sin(b)

You can wrap this up into a function that strips off the coefficient on
a Fourier monomial. To strip off the coefficients on a polynomial (= a
list of monomials with "+"), you can  then do

stripfn(expr) := map(lambda([t], if atom(t) then t else strip(t)),expr);
list_of_monomials : makelist(part(fourier_sum,i),1,length(fourier_sum));
map(stripfn,list_of_monomials);

Leo
 

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.