Maxima
Maxima is a symbolic math program (similar to Mathematica) that I ran into last quarter in order to supplement Octave (Matlab equivalent). Like Octave (which does only numerical analysis) Maxima is completely free. I like the version of Maxima called wxMaxima, and I have that installed on Ubuntu.
You can define an equation in maxima such as:
s: a^2 + 7 = b*4 + a/3
Then you can solve for b in one step:
solve(s,b)
And it simply returns b = a^2/4 + a/12 + 7/4. You can do other cool things such as summation, integration, and differentiation, of course, as you will see below.
Fourier Transforms
Another cool thing you can do with Maxima is define a symbolc function with one or multiple inputs. For example:
f(a) := a^2 + a
Typing in f(3) after this will return 12.
I used this fact to construct some functions that use summations to return the first several orders of a Fourier transform for a square wave, triangle wave, and a few others. I'll just get to the images of what happened when I graphed those functions.
Figure 1 is a square wave approximation. I entered the formula and the plotted it in Maxima:
Figure 1 is a square wave approximation. I entered the formula and the plotted it in Maxima:
square(x,n,omega) := expand((4/%pi)*sum(1/(m*21)*sin((m*21)*x*omega),m,1,n));
plot2d(square(x,50,2),[x,0,2*%pi]);
Figure 1: Square Wave Fourier Approximation (50 terms) 
This triangle wave approximation in Figure 2 was made with the commands:
triangle(x,n,omega) := expand((8/(%pi^2))*sum((((1)^((2*m2)/2))/((2*m1)^2)*sin((2*m1)*omega*x)),m,1,n));plot2d(triangle(x,50,2),[x,0,2*%pi]);

This sawtooth wave approximation in Figure 3 was made with the commands:
sawsymmetric(x,n,omega) := expand(2/%pi*sum(((1)^(m+1))/m*sin(m*omega*x),m,1,n));
plot2d(sawsymmetric(x,50,2),[x,0,2*%pi]);
Figure 3: Sawtooth Wave Fourier Approximation (50 terms) 
You'll notice just how approximate these functions are, especially on the square and sawtooth waves, around where there are the greatest discontinuities. The triangle wave looks nearly perfect because while it has a sharp peak, it is changing rate from the same point rather than jumping from 0 to 1.
No comments:
Post a Comment
Please keep your comments respectful and in the spirit of constructive criticism.