Thursday, September 22, 2011

wxMaxima - defining a parameter/variable and a function

Ok, so here is one of my shots at Maxima/wxMaxima.  My goal is to define a parameter/variable then use it in a function I have defined myself.

My variable is alpha, $$\alpha$$, but I defined it as al_pha since Maxima doesn't like variables that are already defined and many of those are Greek variables.  I just broke it up phonetically.  I set alpha to be a constant by

al_pha: 30*%pi/180

(I think using just "pi" works too.  It does, it just leaves it in symbolic form.  See screen shots.)

The colon (:) provides the capability to define the variable  al_pha in Maxima.  I also multiplied by Pi and divided by 180 in order to get al_pha from degrees (30) into radians since I am going to be dealing with trigonometric functions.

Next, I define my function as lamb_da as

lamb_da(x):= (csc(x))^2

Note, that I used "x" even though I want the angle alpha.  We will call lamb_da for al_pha later.  So the colon (:) plus the equal sign (=) attains a function definition in Maxima.  Also note that in order to square cosecant in Maxima I had to wrap in parentheses and then square.  I also could have done

csc(x)*csc(x)

but who wants to do that for 2 or higher?!

Screen shots:

Notice the difference between using %pi and pi gives 4 and $$\csc ^2 \left( \dfrac{\pi}{6}\right)$$, respectively.

I then add more to lamb_da once I know it is working properly.

I can check it with KAlgebra.

I found this very good pdf where I discovered how to define a function and parameter:

resources.eun.org/xplora/Maxima_Xplora.pdf

Also this can be found in the Maxima documentation here:

7.6 Assignment operators - http://maxima.sourceforge.net/docs/manual/en/maxima_7.html#SEC41