[Maxima] Fourier Series using fourie.mac

Richard Hennessy richhen2008 at gmail.com
Tue Jul 28 13:36:17 CDT 2009


Maxima does not work well with abs() function, I noticed.  There is the
abs_integrate.mac package and also pw.mac which can handle this function.
(%i1) load(pw)$
...

(%i8) display2d:false;
(%o8) false
(%i9) abs2signum(abs(x) - abs(x^2-1));
(%o9) x*signum(x)-(x^2-1)*signum(x^2-1)
(%i10) simpsignumargs(%,x);
(%o10) x*signum(x)-(x^2-1)*signum(x-1)*signum(x+1)
(%i11)

pw.mac can work well with %o11.

Rich


2009/7/28 Rafał Topolnicki <rtopolnicki at o2.pl>

>
> > 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
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.math.utexas.edu/pipermail/maxima/attachments/20090728/5637538b/attachment-0001.htm 


More information about the Maxima mailing list