Math 230, Spring 1999
Mathematica assignment 1
Sample Solutions

The following problems are taken from pages 31 to 34  of the 
Differential Equations with Mathematica book.  These are strictly 
optional, but I recommend going through at least some of them in
order to refresh your memory of Mathematica syntax.

Problem 1  ( b and d only)  :

b.

2^123

c.

N[Pi,  10]N[22/7, 10]     N[311/99, 10]N[355/113,  10]

355/113 is the best approximation of π,and 22/7 is the worst.

\(\(



\)\)

Problem 2:

a.

N[Sin[ .1]/ .1, 10]

b.

N[Sin[ .01]/ .01, 10]

c.

N[Sin[ .001]/ .001, 10]

\(\(



\)\)

Problem 3:

Factor[x^3 - y^3]

\(\(




\)\)

Problem 4 (d and e):

d.

Plot[ Tan[x],  {x, -π/2, π/2},  PlotRange -> {-5, 5}]

(Notice that I used the PlotRange Option to keep the scale on the vertical axis reasonable.)

e.

Plot[E^(-x^2), {x, -2, 2}]

\(\(





\)\)

Problem 5:

I'm going to record all my attempts here.  Fiddling around a bit is part of the game...

Plot[{x^4,  2^x}, {x, -1, 1}]

OK, looks like we've got a crossing at about x = -.9.

FindRoot[x^4  -  2^x  ==  0,  {x, - .9}]

Plot[{x^4,  2^x}, {x, -2, 2}]

We've got another crossing at about 1.3

FindRoot[x^4  -  2^x  ==  0,  {x, 1.3}]

\(TextForm
    \`Now\ \(x\^4\) goes\ to\ infinity\ as\ x\ goes\ to\ negative\ infinity, 
    \ but\ \(2\^\(x\ \)\) goes\ to\ \(zero--\) not\ likely\ that\ we' ll\ find
      \ any\)\(TextForm
    \`more\ crossings\ for\ negative\ values\ of\ x . \ \ On\ the\ other\ hand
      \ \(2\^\(x\ \)\) grows\ much\ more\ quickly\ than\ \(x\^4\) as\ x\ goes
      \ to\)\(TextForm
    \`infinity . \ \ There\ must\ be\ at\ least\ one\ more\ positive\ value\ 
      of\ x\ at\ which\ the\ graphs\ \(cross . \)\)

Plot[{x^4,  2^x}, {x, 1, 10}]

Didn't learn much from this one!  Try again...

Plot[{x^4,  2^x}, {x, 1, 3}]

Maybe I didn't try for a large enough x:

Plot[{x^4,  2^x}, {x, 1, 20}]

Aha!  Looks like there's a crossing near x = 16.

FindRoot[{2^x == x^4},  {x,  16}]

So x=16 was a pretty good guess!  All told, we found crossings at x = -.861, x= 1.23, and x =16.

\(\(





\)\)

Problem 6 (a and c):

a.

ContourPlot[ 3  y + y^3  - x^3,  {x, -1, 1}, {y, -1, 1},  
      ContourShading  ->  False]

ContourPlot[ 3  y + y^3  - x^3,  {x, -20, 20}, {y, -20, 20}, 
       ContourShading  ->  False]

c.

Since f(1,1) = 0, we only want the level curve f(x,y) = 0.  We need to be careful with the ranges for x and y, since the natural log function
isn't defined at zero or at negative numbers.

ContourPlot[y Log[x]  +  x Log[y],  {x,  .1,  3},  {y,  .1, 3}, 
      Contours  -> {0},  ContourShading  ->  False]

\(\(





\)\)

Problem 7 (c only):

D[ArcSin[2  x + 3], x]

\(\(





\)\)

Problem 8:

a.

polly  =  
      x^6  -  21  x^5  +  175  x^4 - 735  x^3 +  1624  x^2  -  
        1764  x  +  720

Factor[polly]

b.

Solve[polly  ==  0, x]

c.

Plot[polly, {x,  .5, 6.5}]

d.

dpolly  =  D[polly, x]

Plot[{polly,  dpolly}, {x,  .5, 6.5}]

\(\(




\)\)

Problem 9 (a and d):

a.

Limit[Sin[x]/x, x -> 0]

d.

Limit[1/(x - 1), x -> 1,  Direction -> 1]

\(\(



\)\)

Problem 10 (a and g):

a.

Integrate[Sin[x], {x, 0, Pi/2}]

g.

Integrate[Exp[Cos[x]], x]

Looks like not even Mathematica can handle this one.  Nonetheless, we can differentiate the
unevaluated integral to see whether we get back the original function:

D[%, x]

\(\(





\)\)

Problem 11 (b only)

NIntegrate[Sqrt[x^4 + 1], {x, 0,  1}]