11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.8 Animation • 275> partsum := partsum> + 2/l * evalf( Int(func*sin(k*x), xrange) )> * sin(k*x)> + 2/l * evalf( Int(func*cos(k*x), xrange) )> * cos(k*x);> # Plot k-th Fourier approximation.> q[k] := plot( partsum, xrange, color=blue,> args[4..nargs] );> end do;> # Generate sequence of frames.> q := plots[display]( [ seq( q[k], k=1..n ) ],> insequence=true );> # Add the function plot, p, to each frame.> p := plot( func, xrange, color = red, args[4..nargs] );> plots[display]( [ q, p ] );> end proc:You can now use fourierPicture to see, for example, the first sixFourier approximations of e x .> fourierPicture( exp(x), x=0..10, 6 ):This is the static version.> display( fourierPicture( exp(x), x=0..10, 6 ) );.200e5.150e5.100e5.50e4.200e5.150e5.100e5.50e4.200e5.150e5x.100e5.50e40. 0.2.4.6.8. 10..200e5.150e5x.100e5.50e40. 0.2.4.6.8. 10..200e5.150e5x.100e5.50e40. 0.2.4.6.8. 10..200e5.150e5x.100e5.50e40. 0.2.4.6.8. 10.x0. 0.2.4.6.8. 10.x0. 0.2.4.6.8. 10.The following are the first six Fourier approximations of x -> signum(x-1).The signum function is discontinuous, so the discont=true option is required.> fourierPicture( 2*signum(x-1), x=-2..3, 6,> discont=true );Again, these pages require a static version.> display( fourierPicture( 2*signum(x-1), x=-2..3, 6,> discont=true ) );

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!