Übungsblatt 15a
 

PI-1 2008/09

Scientific Computing with Mathematica

Lernziel: Kennenlernen des Werkzeugs Mathematica anhand von einfachen Beispielaufgaben.
Hinweis: Mathematica ist auf allen Poolrechnern bereits installiert. Benötigen Sie eine Installation auf weiteren Rechnern, so wenden Sie sich bitte an Ihren Praktikumsleiter.
 


Assignment 1: 100th and 101st digit in the representation of

Using Mathematica, determine (acurately) the 100th and 101st digit in the representation of .

For example: The first digit of is 3, the second digit is 1, the third digit is 4, ...


Assignment 2:  Ploting a function

Using Mathematica, plot the following function in the range: -3 < x < +3.


Assignment 3: Polynomials

Use Mathematica to expand the following product to a polynomial in normalized form:

Use Mathematica to solve the equation p(x)=0, i.e. determine all values x for which p(x)=0.


Assignment 4:  Electrostatic potential and field of a system of charges

The electrostatic potential of a single charge is:

\begin{displaymath}V(\mathbf{r})=\frac{Kq}{r}

(1)

while the electric field is given by:

\begin{displaymath}\mathbf{E}(\mathbf{r})= - {\bf\nabla} V = \frac{Kq\mathbf{r}}{r^{3}}

(2)

Here bold letters denote a vector, while regular letters are scalars. In this assignment, for simplification, we assume that K=1. Also remember that the potential and field of a group of charges is the sum of the individual potentials (scalar sum) and fields(vector sum).

Store the magnitudes of the charges in an array (lists), and store their positions in a two-dimensional array (nested list). For example for two charges:

   q={1,-2};
   rq={{1,2,0},{0,-1,0}};
Now define a Mathematica function (operator) to evaluate the potential at a given point (vector)
$\mathbf{r}=\left( x,y,z\right) $. Try to devise an operator that will work with any q, rq and r. 

Just to remind you, here is an example of defining an operator in Mathematica that calculates the square of an expression x:

   sqr[x_]:=x^2

You may also need a function to calculate the length of a vector $r=\left\Vert \mathbf{r}\right\Vert $. You can use, for example, a dot product ( .) to do this:

   magnitude[r_]:= Sqrt[r.r]

Plot the electric potential both as a surface (Plot3D in Mathematica) and as a contour plot (ContourPlot) and compare the two. Which one is better and why? Try to make both plots look as nice as possible. Then plot the electric field as a vector field ( PlotVectorField loaded with the package via << Graphics`PlotField`).