Practice Set B

Problem 1

Let's plot (2^x) and (x^4) and look for points of intersection.  We plot (2^x) in black and (x^4) in gray, first over the interval [-10, 10].

Plot[{x^4,  2^x},  {x,  -10,  10},  
      PlotStyle  ->  {GrayLevel[0.6],  GrayLevel[0]}];

The vertical range is so large that the graph is not very informative, but we do learn that there are no points of intersection between 5 and 10 or -10 and -5.  Let's focus on the interval between -5 and 5.

Plot[{x^4,  2^x},  {x,  -5,  5},  
      PlotStyle  ->  {GrayLevel[0.6],  {}}];

Now we can see that there are at least two intersections between -2 and 2.  So let's focus on that interval.

Plot[{x^4,  2^x}, {x,  -2,  2},  
      PlotStyle  ->  {GrayLevel[0.6],  {}}];

We see that there are points of intersection near -0.9 and 1.2.  Are there any other points of intersection?  To the left of 0, (2^x) is always less than 1, whereas (x^4) goes to infinity as x goes to -∞.  On the other hand, both (x^4) and (2^x) go to infinity as x goes to ∞, so the graphs may cross again to the right of 0.  Let's check.

Plot[{x^4,  2^x},  {x,  10,  20},  
      PlotStyle  ->  {GrayLevel[0.6],  {}}];

We see that they do cross again, near x = 16.  If you know a little calculus, you can show that the graphs never cross again (by taking logarithms, for example), so we have found all the points of intersection.  Now let's use the FindRoot command to find these points of intersection numerically.  This command looks for a solution near a given starting point.  To find the three different points of intersection we will have to use three different starting points. The above graphical analysis suggests appropriate starting points.

r1  =  FindRoot[x^4  ==  2^x,  {x,  -0.9}]

r2  =  FindRoot[x^4  ==  2^x,  {x,  1.2}]

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

Let's check that these "solutions" satisfy the equation.

x^4  -  2^x  /.  r1

x^4  -  2^x  /.  r2

x^4  -  2^x  /.  r3

So r1 and r2 very nearly satisfy the equation, and r3 satisfies it exactly.  It is easily seen that 16 is a solution.  It is also interesting to try Solve on this equation.

sol  =  Solve[x^4  ==  2^x,  x]

Although we get a warning message, Solve finds five solutions.  Let's examine them.

N[x  /.  sol[[1]]]

N[x  /.  sol[[2]]]

N[x  /.  sol[[3]]]

N[x  /.  sol[[4]]]

N[x  /.  sol[[5]]]

So we have two complex solutions, plus the three real solutions found above.  Only the real solutions correspond to points where the graphs intersect.

Problem 2

(a)

ContourPlot[3  y  +  y^3  -  x^3,  {x,  -1,  1}, 
       {y,  -1,  1}];

ContourPlot[3  y  +  y^3  -  x^3,  {x,  -10,  10}, 
       {y,  -10,  10}];

Here is a plot with more level curves.

ContourPlot[3  y  +  y^3  -  x^3,  {x,  -10,  10}, 
       {y,  -10,  10},  Contours  ->  30];

(b)

Now we use the options Contours -> {5} and ContourShading -> False.

ContourPlot[3  y  +  y^3  -  x^3,  {x,  -5,  5}, 
       {y,  -5,  5},  Contours  ->  {5},  
      ContourShading  ->  False];

(c)

We note that f(1, 1) = 0, so the appropriate command to plot the level curve of f through the point (1, 1) is

ContourPlot[y*Log[x]  +  x*Log[y],  {x,  0.1,  2}, 
       {y,  0.1,  2},  Contours  ->  {0},   
      ContourShading  ->  False];

Problem 3

We find the derivatives of the given functions :

(a)

D[6  x^3  -  5  x^2  +  2  x   -  3,  x]

(b)

D[(2  x  -  1)/(x^2  +  1),  x]

Simplify[%]

(c)

D[Sin[3  x^2  +  2],  x]

(d)

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

(e)

D[Sqrt[1  +  x^4],  x]

(f)

D[x^r,  x]

(g)

D[ArcTan[x^2  + 1],  x]

Problem 4

The Limit command doesn't calculate two-sided limits; with the default option, it calculates the limit from the right, except for limits at infinity.  So, if a two-sided limit is requested, we have to calculate both one-sided limits.  Let's begin by reviewing the options to Limit using the online help.

Options[Limit]

?Direction

We calculate a limit from the left with the option Direction -> 1.

(a)

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

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

The (two-sided) limit is 1.

(b)

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

Limit[(1  +  Cos[x])/(x  +  Pi),  x  ->  -Pi]

(c)

Limit[x^2*Exp[-x],  x  ->  Infinity]

(d)

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

(e)

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

This  means that every real number in the interval between -1 and +1 is a "limit point" of sin(1/x) as x tends to zero.  You can see why if you plot sin(1/x) on the interval (0, 1].

Plot[Sin[1/x],  {x,  0,  1}];

Problem 5

We compute the following integrals.

(a)

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

(b)

Integrate[x*Sin[x^2],  x]

To check the indefinite integral, we just differentiate.

D[-Cos[x^2]/2,  x]

(c)

Integrate[Sin[3  x]*Sqrt[1  -  Cos[3  x]],  x]

D[%,  x]

Simplify[%]

FullSimplify[%]

(d)

Integrate[(x^2)*Sqrt[x  +  4],  x]

D[%,  x]  // Simplify

(e)

Integrate[Exp[-x^2],  {x,  -Infinity,  Infinity}]

Problem 6

We approximate the following integrals using the NIntegrate command.

(a)

NIntegrate[Exp[Sin[x]],  {x,  0,  Pi}]

(b)

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

(c)

val  =  
      NIntegrate[Exp[-x^2],  {x,  -Infinity,  Infinity}]

Finally, we compare the numerical answer with the exact answer.

N[Sqrt[Pi]  -  val]

Thus the numerical approximation is good to 10 decimal places.

Problem 7

(a)

Plot3D[Sin[x]*Sin[y],  {x,  -10,  10},  {y,  -10,  10}, 
       PlotPoints  ->  50];

(b)

Plot3D[(x^2  +  y^2)*(Cos[x^2  +  y^2]), 
       {x,  -1,  1},  {y,  -1,  1},  PlotPoints  ->  20];

Problem 8

In this exercise, we illustrate three different approaches to drawing the unit sphere.

(a)

Our first approach is to do a parametric plot.

ParametricPlot3D[{Sin[phi]*Cos[theta],  Sin[phi]*Sin[theta],  
        Cos[phi]},  {phi,  0,  Pi},  {theta,  0,  2*Pi}];

(b)

Our second approach is to use a contour plot.  The ContourPlot3D command is in the Graphics package, and must be loaded before we can use it.

<< Graphics`

We want to plot the contour of the function (x^2) + (y^2) + (z^2) at level 1, so we type

ContourPlot3D[x^2  +  y^2  +  z^2,  {x,  -1,  1}, 
       {y,  -1,  1},  {z,  -1,  1},   Contours  ->  {1}];

(c)

In our third approach we plot the upper hemisphere by considering it as the graph of the function (Sqrt[1 - (x^2) - (y^2)]).

Plot3D[Sqrt[1  -  x^2  -  y^2],  {y,  -1,  1}, 
       {x,  -1,  1}];

That didn't work very well.  The problem is that we'd like to plot the graph of the function over the circular region (x^2) + (y^2) < 1, but in Plot3D, the region must be rectangular.  Here's a technique to truncate the function outside the circular region: we use the If command to set the function to 0 outside the circular region.

?If

Plot3D[
      If[x^2  +  y^2  <=  1,  Sqrt[1  -  x^2  -  y^2],  0], 
       {y,  -1,  1},  {x,  -1,  1},  PlotPoints  ->  20];

Not too bad, but still not as satisfactory as the results in (a) and (b).

Problem 9

The command Series[f, {x, c, n}] produces the Taylor polynomial of order n at c, with remainder expressed as O((((x  -  c))^n)).  The Normal command can be used to produce just the Taylor polynomial; this is useful if the Taylor polynomial is needed for a later calculation.

(a)

Series[Exp[x],  {x,  0,  7}]

p[x_]  =  Normal[%]p[2]

(b)

Series[Sin[x],  {x,  0,  5}]

Series[Sin[x],  {x,  0,  6}]

(c)

Series[Sin[x],  {x,  2,  6}]

(d)

Series[Tan[x],  {x,  0,  7}]

(e)

Series[Log[x],  {x,  1,  5}]

(f)

Series[Erf[x],  {x,  0,  9}]

Problem 10

(a)

Sum[i^2,  {i,  n}]

This is the well-known formula for the sum of the first n squares.

(b)

Sum[r^i,  {i,  0,  n}]

This is the sum of the geometric progression.

(c)

Sum[1/i^2,  {i,  1,  Infinity}]

(d)

Sum[(x^i)/i!,  {i,  0,  Infinity}]

The series is the Taylor series for (e^x).

(d)

Sum[1/(z  -  i)^2,  {i,  -Infinity,  Infinity}]

Problem 11

We first make a table of the indicated plots.

Table[
      ParametricPlot[{4*Cos[k*Pi/8]  +  0.5*Cos[t],  
          4*Sin[k*Pi/8]  +  0.5*Sin[t]},  {t,  0,  2  Pi},  
        PlotRange  ->  {{-5,  5},  {-5,  5}},  
        AspectRatio  ->  Automatic],  {k,  0,  15}];

Next we double-click on the cell bracket for the group of plots, leaving only the first plot visible.  Then we can animate the graphic by clicking on Cell:Animate Selected Graphics (though of course we cannot show that here).