Solutions Exercises (1)

Assigned: January 22, 2013
Due: before class on January 29, 2013

Getting Help

Use the ? command to find all commands that begin with the letters P and Q.

?P*

?Q*

Using the Help Browser

Use the Help Browser and describe the basic differences between Plot and ListPlot. In particular, describe the argument to each command in words.

?Plot

?ListPlot

Simple Evaluation

Evaluate the following pairs of expressions and describe in words why they are different.

{2 x + x 7, 2x + x7}

x7 is a symbolic name; whereas, x 7 (with a space in-between) is the same as x*7.

{2 meters + 7 meters, 1 meter + 8 meters}

A "meter" is not a "meters".

Working with Real numbers

(1) Find the numerical value for Sin[53 °] to six significant figures.

N[Sin[53 °], 6]

(2) Find the 2001st significant figure of π.

?RealDigits

Last[First[RealDigits[N[π,2001]]]]

(3) Find Tan[50] - 1 to 10 significant figures.

N[Tan[50] - 1, 10]

(4) Find the real and imaginary parts of the complex number z = Exp[2 + 9 I].

z = (E^(2 + 9 I))

Re[z]

Im[z]

Procedures

Construct a list of 30 random number using, 
list = Table[Random[ Real, {0, 20} ], {i, 30}]. 
Write a procedure that will retain only those elements having values between 6 and 15. Try sorting the list from largest to smallest.

list1=Table[RandomReal[{0,20}],{i,1,30}]

proc6To15[x_] := Select[x, (6 < #) && (# < 15) &]

proc6To15[list1]

sort6To15[x_] := Sort[proc6To15[x],Less]

sort6To15[list1]

Collision?

A train pulls out of a station. It moves along the tracks following the equation s = 0.1 t^2, where s is the distance along the track and t is time.
Another train arrives at the station at high-speed and moves along the track according to the equation s = -4 + 5 t - t^2 - t^3. The second train eventually comes to a stop and moves backwards.

Question: Use Plot[…] to deter ine if the two trains collide.

Plot[{0.1` (t^2),-4+5 t-(t^2)-(t^3)},{t,0,4}]

Therefore, the two trains do not collide.

Find the Function

Below you'll find four graphs generated using the Plot and ListPlot commands. In each case, the expression ploted (or "list-plotted") was a combination of polynomials (like x, x^2, x^3,…),  basic trig functions (Sin and Cos), and the If command (used for the last plot).

Can you duplicate these plots using either Plot[…] or ListPlot[Table[…]]?

Plot[x+Sin[3 x],{x,0,9}]

ListPlot[Table[{x,1+(((Cos[x]+1))^2)},{x,-10,10,0.1}],PlotRange->{0,6}]

ListPlot[Table[{Sin[y],y+Sin[2 y]},{y,0,2 π,0.1}],PlotRange->{0,6}]

Plot[If[x>0.5&&x<1.5,1.-(x^2),2-x],{x,-2,3}]