Robert M. Corless
Department of Applied Mathematics
University of Western Ontario
London, Canada

Copyright 2001 by Robert M. Corless
All rights reserved

Programming in Maple 

Программирование в Maple

Sample Maple programs 

Пример программ Maple

Fourier sine series, revisited 

Синус-ряды Фурье, новый взгляд

> restart;

> plots[setoptions](colour=BLACK);

> FourierSineSeries3 := proc( f, x )
local k, z, F, fop, desc;
desc := sprintf( "Computes Fourier Sine Series of %a", f );
fop := unapply(f,x);
F := 2*int( sin(k*Pi*z)*fop(z), z=0..1 );
subs(DUMMY=desc,proc(n)
local j, s, tmp;
option Copyright;
description DUMMY;
s := 0;
for j to n do
try
tmp := eval( F, k=j );
catch "numeric exception: division by zero":
tmp := limit( F, k=j );
finally
s := s + tmp*sin(j*Pi*x);
end try;
end do;
end proc);
end proc:

> macro( FSS3=FourierSineSeries3 );

FSS3

> f := FSS3( x^2*(1-x^2), x );

> f5 := f( 5 );

> fc := FSS3( cos(Pi*x), x );

> fc( 10 );

8/3/Pi*sin(2*Pi*x)+16/15/Pi*sin(4*Pi*x)+24/35/Pi*si...

> plot( fc(10)-cos(Pi*x), x=0..1 );

> read "D:/books/ess/programs/fouriersine.mpl";

> macro( FSS=FourierSineSeries );

FSS3, FSS

> f1 := FSS( x*sin(Pi*x), x );

f1 := proc (n) options operator, arrow; add(c(k)*si...

> f1( 10 );

Error, (in c) numeric exception: division by zero

> f3 := FSS3( x*sin(Pi*x), x );

> f3( 10 );

> plot( f3(10)-x*sin(Pi*x), x=0..1 );

> int( sin(Pi*k*x)*x*sin(Pi*x), x=0..1 );

-(2*k*cos(Pi*k)-Pi*sin(Pi*k)+Pi*k^2*sin(Pi*k)+2*k)/...

> bad := FSS( x*sin(Pi*x)^2, x );

bad := proc (n) options operator, arrow; add(c(k)*s...

> bad( 10 );

Error, (in c) numeric exception: division by zero

> good := FSS3( x*sin(Pi*x)^2, x );

> good( 10 );

> g := FSS3( Ei(x), x );

g := proc (n) local j, s, tmp; option Copyright; de...

> g5 := g( 5 );

> map( evalf, g5 );

> w := FSS3( x^2*(1-x)*LambertW(x), x );

> w5 := w( 5 );

> w5f := evalf( w5 );

> plot( w5f-x^2*(1-x)*LambertW(x), x=0..1 );

С официального разрешения                    © 2002 Waterloo Maple, Inc

 
Hosted by uCoz