Fourier Series using fourie.mac



> You need to overcome the evaluation rules in sum. Here is one way to do
> this using a lambda-function:
> 
> (%i2) load("fourie");
> (%o2) "/home/work/maxima/maxima-5.18.1-clisp/share/calculus/fourie.mac"
> (%i3) f(x):=abs(sin(x));
> (%o3) f(x):=abs(sin(x))
> (%i4) flist : fourier(f(x),x,%pi);
> (%t4) a[0] = 2/%pi
> 
> (%t5) a[n] =
> 2*(cos(%pi*n)/(2*n+2)-cos(%pi*n)/(2*n-2)+1/(2*n+2)-1/(2*n-2))/%pi
> 
> (%t6) b[n] = 0
> 
> (%o6) [%t4,%t5,%t6]
> (%i7) %t5 : a[n] = 'apply(lambda([s], if s=1 then 0 else
> rhs(''%t5)),[n]);
> (%o7) a[n] = 'apply(lambda([s],
>                            if s = 1 then 0
>                                else rhs(
>                                a[n] = 2*(cos(%pi*n)/(2*n+2)
>                                         -cos(%pi*n)/(2*n-2)+1/(2*n+2)
>                                         -1/(2*n-2))
>                                     /%pi)),[n])
> (%i8) fourexpand(flist,y,%pi,3)$
> (%i9) ev(%,nouns);
> (%o9) 2/%pi-4*cos(2*y)/(3*%pi)
> 
> 
> Leo
> 
Thanks. I'll study your solution. I've another problem with fourie.mac 
when expanding function with abs() - abs(x^2-1). I get coefficients for 
x^2-1 rather then abs(x^2-1):
a[n]=(2*((%pi^2*sin(%pi*n))/n-sin(%pi*n)/n-(2*sin(%pi*n))/n^3+(2*%pi*cos(%pi*n))/n^2))/%pi;
is it bug or am I doing sth wrong?

RT