4 <img src=maxima-icon.gif align=center border=
0>
7 <h1 align=center
>Maxima Primer
</h1>
9 <body BGCOLOR=#ffffff TEXT=#
000000 LINK=#
244C21
>
13 <p>Maxima is a computer program for doing mathematics calculations,
14 symbolic manipulations, numerical computations and graphics.
15 Procedures can be programmed and then run by Maxima to
16 do complex tasks. Much of the syntax for other languages such as
17 Maple was copied from Maxima.
</p>
19 <h2>Project and documentation links
</h2>
20 <p>The
<em>Help
</em> menu in Xmaxima gives you access to the following documents:
</p>
22 <li>Maxima reference manual
</li>
23 <li>Xmaxima reference manual
</li>
24 <li>Maxima home page, https://maxima.sourceforge.io
</li>
25 <li>Maxima project page, https://sourceforge.net/projects/maxima
</li>
28 <h2>Getting started
</h2>
30 <p>To do basic operations, a line is typed, followed by a
31 semicolon, and then entered. This can be done in the window above.
32 Alternately you may edit the blue portions in this buffer, and click
33 on them, to see the result evaluated above and/or inserted in
34 this window, depending on what was specified in the html source for this
36 For example clicking below
39 <eval program=maxima doinsert=
0
40 >integrate(
1/(
1+x^
3),x)
</eval>
42 You may double click the above formula, and the integral will be substituted into the Maxima evaluation in the other window.
44 There are
<a href=
"examples.html">examples
</a> which you may also look at
45 <a href=
"plotmaxima.html">3d plotting
</a>
46 If you wish to have your plots appear in a separate window, go to the
47 preferences button under file, and select separate.
48 You may also go to the
<http://www.ma.utexas.edu/users/wfs/netmath/netmath.html
>
49 netmath page
</a> to see some more capabilities.
52 <p>Here are some examples from basic calculus. To have Maxima
53 evaluate the derivative of the function below, click on this line.
55 <eval program=maxima doinsert=
1> diff(cos(x),x);
</eval> returns
<result modified
>result
</result>.
58 <p>Maxima can calculate
<b>indefinite integrals
</b>.
60 <li><eval program=maxima doinsert=
1> integrate( x/(
1+x^
3),x );
</eval> returns
<result modified
>result
</result>
62 <li>...and definite integrals with respect to x from
0 to
1.
63 <br><eval program=maxima doinsert=
1> integrate(
1/(
1+x^
2), x,
0,
1 );
</eval> returns
<result modified
>result
</result>
64 <li><eval program=maxima doinsert=
0> plot2d(sin(x),[x,
0,
2*%pi])
</eval>
65 <li><eval program=maxima doinsert=
0> plot3d(x^
2-y^
2,[x,-
2,
2],[y,-
2,
2],[grid,
12,
12])
</eval>
68 <li>Also, limits can be evaluated as x goes to infinity:
69 <br><eval program=maxima doinsert=
1> limit( (
2*x+
1)/(
3*x+
2), x,inf );
</eval> produces
<result modified
>result
</result>
71 <li><eval program=maxima doinsert=
1> limit( sin(
3*x)/x, x,
0);
</eval> evaluates to
<result modified
>result
</result>
74 <p>Maxima can perform calculations to arbitrary precision. The
75 following example computes Pi to one hundred decimal places.
76 <ul><li><eval program=maxima doinsert=
1>block([fpprec:
100],bfloat(%pi))
</eval> yields
<result modified
>result
</result>
77 if we took sin of this we would get
0 to to within
100 decimal places..
78 <li><eval program=maxima doinsert=
1>block([fpprec:
100],sin(bfloat(%pi)))
</eval> gives
<result modified
>result
</result>
80 <p>Maxima can solve equations. Click this line to solve the system.
81 <li><eval program=maxima doinsert=
1> solve([x+y+z=
5,
3*x-
5*y=
10,y+
2*z=
3],[x,y,z]);
</eval> returns
<result modified
>result
</result>
83 <li><eval program=maxima doinsert=
1> solve(x^
2-
5*x+
6 =
0,x);
</eval> produces
<result modified
>result
</result>
85 <h5>Linear Algebra
</h5>
87 For example, matrices can be
88 entered and manipulated. Click these two lines.
90 <li><eval program=maxima doinsert=
1> A:matrix([
1,
2],[
3,
4]);
</eval> gives
<result modified
>result
</result>
93 <li><eval program=maxima doinsert=
1> B:matrix([
1,
1],[
1,
1]);
</eval> gives
<result modified
>result
</result>
95 <p>The matrices can then be added, for example:
96 <li><eval program=maxima doinsert=
1> A + B ;
</eval> returns the sum
<result modified
>result
</result>
99 <li><eval program=maxima doinsert=
1> A . B ;
</eval> gives the product
<result modified
>result
</result>
102 <li><eval program=maxima doinsert=
1> A^^-
1</eval> evaluates to the inverse:
<result modified
>result
</result>
104 <li><eval program=maxima doinsert=
1>determinant(matrix([a,b],[c,d]))
</eval> gives
<result modified
>result
</result>
105 <li><eval program=maxima doinsert=
0
108 Fib[n] := Fib[n-
1] + Fib[n-
2];
111 Then the procedure can be called.
<eval program=maxima doinsert=
1> Fib[
8];
</eval> gives
<result>21</result>
114 <p>Maxima can solve ordinary differential equations analytically and numerically. Click the
115 following line for an example of an analytic solution.
119 <eval program=maxima doinsert=
1>ode2('diff(y,x)+
3*x*y = sin(x)/x, y,x)
</eval> returns
<result modified
>result
</result>
120 <li><eval program=maxima doinsert=
1>ode2('diff(y,x) -y =
1, y,x)
</eval> returns
<result modified
>result
</result>
122 <eval program=maxima doinsert=
1> ode2('diff(y,x,
2) - y =
1, y,x)
</eval> gives
<result modified
>result
</result>
125 <h4 align=left
>Defining a Function
</h4>
128 <p>The standard form is
132 <eval program=maxima doinsert=
1>f(
3)
</eval> gives
<result>f(
3)
</result>
135 <eval program=maxima doinsert=
0>f(x):=x+
2</eval>
136 <li>now
<eval program=maxima doinsert=
1>f(
3)
</eval> gives
<result>5</result>
140 <p>The
<b>block
</b> construct lets us introduce local variables, and also lets
141 us have a sequence of statements:
143 <pre>block([v1:val1,v2:val2,v3,v4:val4],stmt1,stmt2,... stmtn)
</pre>
144 the value is the value of the last statement. During the execution the
145 variables v1,v2,... will have the values indicated. If no value is given
146 for v3 then it will just evaluate to itself:
148 <p>Thus if we set v3 globally to be
7,
149 <ul><li><eval program=maxima doinsert=
1>v3:
7</eval> produces
<result>7</result>
150 <li> , then
<eval program=maxima doinsert=
1>block([v3],v3)
</eval> gives
<result>v3
</result>.
152 An example in a function:
155 <li><eval program=maxima doinsert=
0>g(x):=block([u:x+
3,w], u:u^
2, w:(y+
2)^
2, u+w);
</eval>
159 <li><eval program=maxima doinsert=
1>g(
2)
</eval> yields
<result><pre>
167 <li><eval program=maxima doinsert=
0>h(x):=block([u:x+
3,w], u:u^
2,
168 if (u
<3) then w:(y+
2)^
2 else w:(y+
2)^
2+
1,
174 <li><eval program=maxima doinsert=
1>[h(
3),h(
2)]
</eval> gives
<result><pre>
176 [(y +
2) +
37, (y +
2) +
26]
184 <li><eval program=maxima doinsert=
1> block([w:
0], for i:
1 thru
10 do (w:w+i^
2))
</eval> gives
<result>done
</result>
186 <p>a for loop always returns 'done as its value. To get the value you want
191 <li><eval program=maxima doinsert=
1> block([w:
0], for i:
1 thru
10 do (w:w+i^
2),w)
</eval> gives
<result>385</result>
194 The function
<b>describe(
</b><i>s
</i><b>)
</b>
195 returns documentation on all functions whose names include the string
<i>s
</i>.
196 For example, if the string is
"log",
197 <br><eval program=maxima doinsert=
1>describe(
"log");all
</eval> prints
<result modified
>this output
</result>