# 10 minute (wx)Maxima tutorial

Aus http://wxmaxima.sourceforge.net/  Ergänzungen auf Deutsch von Ha 

Mathematik in wxMaxima www.mathematik-verstehen.de Haftendorn Okt 2010

Achtung: Durch Anklicken der linken Zellmarkierung kann man die 
Abschnitte und auch einzelne Zellen aufklappen und auch wieder zuklappen.
Dazu Shift halten, dann werden auch alle Unterebenen aufgeklappt.

Endung *.wxmx ist komfortabel. Ist die Endung *.wxm muss man 
erst noch alle Ausgaben neu erzeugen. Mit Strg r  werden alle aufgeklappten Zellen ausgewertet.
Zum Lernen ist es besser die Zellen einzeln (mit Shift+Enter) auszuwerten.

Werte einzelne Zellen aus mit Shift-Enter. 
Auswertung in einem Rutsch: Falte alle Abschnitte auf,
werte alle Zellen mit Strg r aus ( auch Menu Cell Alle Zellen auswerten).

Welcome to wxMaxima! In this introductory tutorial you will
learn the basics of wxMaxima and Maxima. Maxima is a CAS
(Computer Algebra System) similar to systems like Mathematica,
Maple and others. Maxima, however, is a commandline application,
which makes it a bit harder to use than its younger cousins.
Here is where wxMaxima comes in - it's a GUI (Graphical User
Interface) for Maxima, made to make using Maxima simpler and
more enjoyable.

Let's start with some simple calculation examples! Below is 
an input cell with a simple addition. Place the cursor in it
and press SHIFT-ENTER to evaluate it.

1 + 1;

If you didn't get any errors, your Maxima is configured properly.
If you did get an error, you should check wxMaxima configuration or
visit wxMaxima website (http://wxmaxima.sourceforge.net/) for
instructions on how to setup wxMaxima and Maxima properly!

Assuming you've delt with your problems, let's do some more
calculations (again - place the cursor in the input cell below
and press SHIFT-ENTER to evaluate the code)!

5!;
% * 10;
%o1 * 100;
5! *100;
1 / 3;
1.0 / 3.0;
%o3;

%o1;

%o  gefolgt von einer Zahl spricht den Output mit dieser Nummer an. 
also %o1 ist hier die 2 aus der ersten Auswertung.  Aber weil sich die 
Nummern bei nochmaliger Auswertung ändern, ist so ein Bezug nicht empfehlenswert.
Beim Speichern gehen die Nummern verloren und auch die Ausgaben.

In the input cell above, we've sent 5 "lines" to Maxima. Each line
must end with a ";" or a "$". In case the line ends with a ";", Maxima
will show the result of the line, while results of lines ending
with "$" will be supressed. The "$" comes in handy when doing longer
calculations. Note also that the result of "1/3" and "1.0/3.0" differ.
That's because Maxima, unlike numerical matrix packages (Matlab etc.),
tries to keep calculations precise - it does not evaluate 
expressions like 1/3 or sqrt(2) unless asked to. In "1.0/3.0" we used
floating point numbers, so Maxima didn't leave expression unevaluated.

We can, however, tell Maxima we want a floating point aproximation
of an expression. Evaluate the cell below and observe results.

sqrt(2 * %pi);
float(%);

In line "float(%);" we used the "%" symbol. This symbol always holds
the result of the last evaluated line. Numbered symbols "%o1", "%o2"
... hold the results as they appear when input cells are evaluated.
We can also store, not only numbers, but whole expressions, in variables.
Use "variable_name: value;" form to store value into "variable_name".
Evaluate the cell below and observe.

radius: 10 $
height: 100 $
area: %pi * radius^2;
volume: area * height;

Let's evaluate the last result numerically:

float(%);

So far we've only used Maxima as a simple calculator. Now let's try
some things not possible with a calculator. Indefinite and definite
integrals:

integrate( sin(x), x);
integrate( sin(x), x, 0, %pi);

Let's define a function, evaluate it and integrate it!

f(x) := x^2 + a$
f(5);
f(5), a = -5;
integrate( f(var), var );

Sometimes Maxima needs additional information to evaluate an expression
and asks us a question. A cursor should appear automatically, indicating
you need to answer a question. If it doesn't, write an answer below the
cell and send it to Maxima with SHIFT-ENTER. Note: instead of answering
with "positive;", you can only type "p". Below is an integral with
a question: (lies deutschen Text darunter)

;

Hier stand in einer Eingabezelle integrate( 1 / (x^2 + a), x); 
Das Programm hielt an mit der Fehlemeldung Ist a eine positive Zahl?
Im Folgenden wird gezeigt, was man dann machen muss.
Ich habe die Zeile herausgenommen, weil man mit ihr nicht die Datei
in einem Rutsch auswerten konnte.

We can also inform Maxima beforehand using the function "assume". To
revert an assumption, use "forget".
(Note: to get help on any function, just click on the function name
and press F1. Try it.)

assume(a > 0)$
integrate( 1 / (x^2 + a), x);
forget(a > 0)$

Now that you've learned the basics, it's time for some general
mathematical examples! Remember: if you want to know more about
a specific function, click on it and press F1.

Solving equations using solve:

solve(a*x^2 + b*x + c = 0, x);

Linear algebra. Use "matrix" to create matrices. Matrices can contain
non-number expressions. Use "invert" to calculate an inverse and "."
for matrix multiplication.

A: matrix([1,-1],
          [1,sin(c)]);
B: invert(A);

A.B;
ratsimp(A.B);

In the last line we used "ratsimp" to simplify the result of "A.B".
Maxima has a lot of different simplification functions, depending on
what kind of simplification you want. Simplification is a complex
topic and if you don't know anything about it, using "ratsimp" may
be your best shot.

Let's do a 2D and a 3D plot!

wxplot2d([sin(x), cos(x)], [x,0, 2*%pi]);
wxplot3d( exp(-x^2 - y^2), [x,-2,2],[y,-2,2]);

Let's try differenciation using "diff" function.

f(x) := x^2 $
diff(f(x), x);
g(y) := sin(y)$
g(f(x));
diff( g(f(x)) , x);

Yes, Maxima knows about the chain rule!

And for the end, let's solve an ODE of second order:
y''(t) + omega^2 * y(t) = 0

assume(omega > 0);
ode2( 'diff(y, t, 2) + omega^2 * y = 0, y, t );

ic2(%, t = 0, y = amp, 'diff(y,t) = 0 );

You should now start exploring (wx)Maxima on your own. Remember 
to press F1 often, if you want Maxima to help you solve your 
mathematical problems!

Enjoy using Maxima and wxMaxima!

'diff(y, t, 2) + omega^2 * y = 0;
ode2( 'diff(y, t, 2) + omega^2 * y = 0, y, t );
ic2(%, t = 0, y = amp, 'diff(y,t) = 0 );

ic2 heißt offenbar  initial condition einer DGL mit zwei Var. 
'diff wertet diff nicht aus. 

Wieder freigeben von omega

forget(omega>0);