next up previous
Next: About this document ...

Worksheet #1 - PHY 102 (Spr. 2005)
Due Thursday Jan. 20th at 9:30pm
This worksheet introduces you to the use Mathematica. Mathematica is a programming language developed by Stephen Wolfram which has many applications,e.g., solving algebraic equations, differentiation, integration, making plots in two and three dimensions, etc.. You will also solve a couple of simple problems in mechanics using Mathematica. The reference material for this worksheet is in sections 1.0.1 to 1.1.7 of the practical introduction to mathematica . You should read this material as you work through the exersizes below. A brief introduction to Mathematica is also available on the course www page (written by Ellen Lau).

Getting Started

To access mathematica in your PC follow these steps:

1. Click on the ``start'' button in the lower left corner of the screen.

2. Move the cursor ``Programs $\rightarrow$ Mathematica $\rightarrow$ Mathematica ''

3. Click on Mathematica.

4. Under the format menu click on ``Show Toolbar''

5. Again, go the format menu and click on ``Screen Style $\rightarrow$ Condensed''

You will now get a screen where you can carry out the following simple exercises to get an idea of how to use Mathematica.

i) Type ``2+4'' and hold down the ``shift'' button in the key board and push ``enter'' (each time you want to get the result for what you have typed, you have to type ``shift+enter''). In the output the screen will give you back the result.

ii) Type ``10/2'' to check that you'll get 5 in the output.

iii) To find the roots of an equation (e.g. x2-1), type ``Solve[x$^{\wedge}$2-1 == 0,x]''. In the output you'll get +1 and -1 as the two roots.

iv) You can do much more! You can factorize the expression x2-1 as we usually do to get the roots. In order to do that type ``Factor[x$^{\wedge}$2-1]'', and check if you get (x+1)(x-1).

v) Mathematica has extensive plotting tools. For example plot the function sin(x). To do this type ``Plot[Sin[x],{x,0,6.28}]''.

vi) Help??? Mathematica has an extensive online help library. Try looking up the sin(x) function to make sure you have the right format.

vi) Here is an example how you can perform differentiation using mathematica: suppose f(x) = xn; then $\frac{df}{dx}=nx^{n-1}$. To check it type ``D[x$^{\wedge}$n, x]'' and see the output.

vii) Likewise, you can perform integration on f(x) = xn. Type ``Integrate [x$^{\wedge}$n, x]'' and assure yourself that you indeed get back $\frac{x^{n+1}}{1+n}$.

Assignment 1. - Hand in by Thursday Jan. 20th
Examples. Hand in the results of 10 mathematica operations you experimented with.

Problem 1. The displacement of a particle undergoing one dimensional motion under constant acceleration is given by the equation $x(t) = u t + \frac{1}{2}a t^2$. Choose values of u and a that you think are physically reasonable. Find and plot x(t) and v(t) over a reasonable range of time (this depends on your choice of u and a). Note: In plotting, use ``Plot[Evaluate[x[t]],{t,0,5}]'' after defining x[t].

Problem 2 The velocity of a particle is given by v(t) = 0.10 t - cos(2t) in the positive x direction. At t=0, it was located at x(0)=0. Find and plot x(t) for t up to 10s.

next up previous
Next: About this document ...
Phil Duxbury