Worksheet #4 - PHY102 (Spr. 2005)
Due Thursday February 10th

## Solving equations and differential equations

Solving using Mathematica

Look up how to solve algebraic equations exactly(Solve) and numerically(NSolve). If you have a transcendental equation (e.b. x = sin(x)) you need to use FindRoot''.

In simple kinematics and simple applications of Newton's second law, the physics is often described by a second order linear differential equation. This may be solved analytically using DSolve, or numerically using NDSolve. We shall consider initial value problems in which it is necessary to specify the initial conditions. In Newton's second law, this is the initial position and velocity. An example is: DSolve[ x''[t] + 0.05 x'[t] +x[t] == 0,x'[0]==0,x[0]==2},x[t],t]''. Note the double equals (=='') occurs in all of the Solve, DSolve ...'' functions. It is Mathematica's way of expressing a Truth'' statement.

Extracting what you want

This is a pretty confusing, but essential, part of Mathematica syntax. The solutions are given as a list of substitution rules. First you have to choose the element of the output list that you want. Then you have to correctly use the substitution rule. Look at the two examples of how to do this. The reference material for this worksheet is a practical introduction to Mathematica Sections 1.5.1-1.5.8 and Section 1.9.1.

### Problem 1

(i) Find and print the real root of the equation:

 x3 -2 x2 + x = 1 (1)

(ii) Plot the two functions, x, and, 2 tanh(x), on the same graph (use Plot). Then find and print the largest real root of the equation.

 x = 2 tanh(x) (2)

Problem 2.

Set up the differential equation for the displacement x(t) of a simple harmonic oscillator with mass m=1 and angular frequency . Program Mathematica to solve this differential equation (DSolve) to find x(t). Plot its kinetic energy as a function of time, given x(0) = 5, v(0)=x'[t] = 0. Now add damping to the equation, in the form 0.05 x'(t). Repeat your calculation with this damping term. Plot over a time which includes at least 10 periods of the motion.

Problem 3.

A projectile is thrown (from earth) with initial speed u, at an angle to the horizontal.

(i) Program Mathematica functions describing its equations of motion along the x and the y directions as a function of time. (ii) Program Mathematica to Solve'' for the range'' of this projectile motion using these functions. At what angle to the horizontal is the range maximal?