Maple and Mathematica

Maple and Mathematica are two very powerful packages for symbolic and numeric computing as well as for visualization. In my personal opinion Matlab is more convenient for numerical computation but I use the CAS-features in Maple and Mathematica fairly often. CAS stands for Computer Algebra System and here is a Wikipedia-link to a list of such systems.

The only reasons for this assignment is to inform you about the existence of these packages (not many students seem to have used them) and for you to try some graphics commands. My intention is not for you to become an expert (nor am I one myself :-)

You can probably start the programs from the menu in the window system, if not you can start them by typing the following in a terminal window:

To start Maple: /chalmers/sw/sup64/maple-18.01/bin/xmaple
To start Mathematica: /chalmers/sw/sup64/mathematica-9.0.1/bin/mathematica

Three important notes:
  1. When  you type a command in Mathematica you need to press shift-enter to execute it, enter by itself just makes it possible for you to continue on the next line.
  2. There seem to be a glitch in the Maple-graphics (at least on my machine, probaly an old driver for the GPU).
  3. You may have to load packages in Maple (see the documentation), perhaps typing something like with(plots):  (the colon suppresses output). If you miss a package, nothing much will happen when you give the plot-command.
Now to the problems. Both packages have huge help-systems. In Maple choose Maple Help from the Help-menu and then have a look at Graphics. In Mathematica, choose Documentation Center from the Help-menu, then look at Visualization and Graphics.

Question  Visualize the follwing objects in Mathematica (Maple is optional).


Explanation of the hint: Say we have a second order polynomial (so I don't have to write so much) with the roots (for a fixed p) 2 + 3i and -7+11i (using Matlab-notation). The Solve-command produces a list of lists of so-called rules: {{x -> 2+3i}, {x -> -7+11i}}. lhs -> rhs represents a rule that transforms lhs to rhs.

/. is the ReplaceAll-command, expr /. rules applies a rule or list of rules in an attempt to transform each subpart of an expression expr. So x /. {{x -> 2+3i}, {x -> -7+11i}} becomes the list of the roots: {2+3i, -7+11i}.

@
produces an operator form (prefix notation) of a function. One can write like this, for example: Sqrt@ 4 and get the answer 2 (it is more standard to write Sqrt[argument], but the operator version is needed in the hint).

#, called slot, represents the first argument supplied to a function and & is used to define the body of a function, body &, so for example: (Sin[#] Cos[#]) &[6] becomes Sin[6] Cos[6]. func = (#^2) & followed by func[5] produces 25.

f /@ expr, map, applies the function f to each element in expr, so for example, Sin /@ {1, 2, 3} becomes {Sin[1], Sin[2], Sin[3]}.

Now suppose you have two functions F[x] and G[x], then {F@#, G@#} & /@ {r1, r2} produces {{F[r1], G[r1]}, {F[r2], G[r2]}} which is the final expression if you change F, G to Re, Im and let {r1, r2} be the list of roots.

If you want more help you can search the Mathematica documentation for symbols like, /., @ etc. or read the free pdf-file, Core Language, 357 pages (here is a page of free manuals). here is the equivalent page for Maple.


Definition of the gravitational potential for point masses. Suppose there are n masses mk, k = 1, .., n with positions rk. (each rk is a 3D-point). Given the position r (in 3D) we define the potential V(r) as:
V(r) = - (m1 / | r - r1 | + ... + mn / | r - rn |)

where | | denotes the ordinary Euclidean vector length.

Back