Lab & Writing Assignment 2A

Instructor: Michael Pelsmajer
Teaching Assistant: Francisco Hernandez
Monday October 20 or Thursday October 23, 2014

(Double-click the right bracket of each cell to view contents.)

Introduction

Today, your task is to make nice graphs.

I want to be able to see all the interesting features of the function, such as:
•  local maximums and local minimums
•  inflection points
•  asymptotes
And all the other stuff that you’ve been studying.

Example

Here’s a plot of (x^2)-19x.  Is it nice?

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

Is it nice?  No, y=(x^2)-19x  isn’t a line, so it shouldn’t look like a line.

Whenever you make a plot you must specify the interval of x-values that will be shown.
In the previous plot, that was [-1,1].

Apparently [-1,1] wasn’t the best choice?  
(Well, it’s easy to criticize, but how should we do it?)

How does one know where to look for all the interesting features of a graph?

This is what we’ve been discussing in class!  It's mainly these:

•  Find where the function Does Not Exist. (vertical asymptotes)
•  Find where the derivative equals 0 or Does Not Exist. (critical numbers)
•  Find where the second derivative equals 0 or Does Not Exist. (possible inflection points)
•  Find the Limit at Infinity and the Limit at Negative Infinity. (horizontal asymptotes or otherwise)

Example

For a quick demonstration, let’s not do all of that.  
Rather, we’ll just set the derivative equal to 0 and solve...

f[x_]:=x^2-19x
NSolve[f'[x]==0,Reals]

...then make a plot that shows x-values near x = 9.5.

Plot[f[x],{x,4.5,14.5}]

(That’s already much better, no?)

Tools

How to Find the Second Derivative with Mathematica

First find the derivative. Then take the derivative of the result.

For example, try it for (x^3)-2 Sin[x]. (Press shift-Enter in the next cell.)

f[x_]:= x^3-2Sin[x]
f''[x]

Optional: Another Way to Find the Second Derivative with Mathematica. (Double-click the right bracket to view.)

You might recall:
•  You can also take the derivative of (x^3)-2 Sin[x] directly, without first naming it f(x), with this: D[(x^3)-2 Sin[x],x].
•  “%” means “the result of the most recent calculation”.

Hence, you can also find the second derivative like this:

D[x^3-2Sin[x],x]
D[%,x]

Or, the same thing in a single line:

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

How to Solve an Equation Numerically in Mathematica

Mathematica can sometimes find exact solutions to an equation, but let’s instead ask it to find approximate solutions with “NSolve”.
For example, try it for (x^2)=Sin[x].

NSolve[x^2==Sin[x],Reals]

If you look carefully, you’ll see that the equation within NSolve is written with a double equals sign “==”. 
You must use a double equals sign.

Optional: Understand what just happened, in two ways. (Double-click the right bracket to view.)

(1) Mathematica says that 0 and 0.876726 are approximate solutions to the equation (x^2)=Sin[x].
So, if we graph (x^2) and Sin[x], what should we see at x = 0 and x = 0.876726?

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

(2) Mathematica says that 0 and 0.876726 are approximate solutions to the equation (x^2)=Sin[x].
So, if we plug those numbers into (x^2)-Sin[x], we should get (approximately) zero.
Try it:

g[x_]:=x^2-Sin[x]
g[0]
g[0.876726]

How to Find Limits at +/- Infinity in Mathematica

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

Limit[(2x^5-34x)/Sqrt[7x^10-91],x->-Infinity]

How to Select the visible x-values and y-values

Ordinarily Mathematica chooses what y-range to disply, and the x-range matched your chosen domain.
But you can choose the visible x-range and y-range.

For comparison, we plot a function with domain [-10,10] in the usual way, 
then again where we specify the visible ranges to be 0 ≤ x ≤ 4 and -5 ≤ y ≤ 25.

Plot[x^2+Sin[10x],{x,-10,10}]
Plot[x^2+Sin[10x],{x,-10,10},PlotRange->{{0,4},{-5,25}}]

Exercises

Your task is to make nice graphs.  I want to be able to see all the interesting features of the function.

Specifically, you must choose a good interval of visible x-values.  
And you must find derivatives, limits, etc. using Mathematica, as needed to help you choose a good interval.
(In some cases, you’ll find that you need two or more plots on different intervals, in order to be able to see all the interesting features.)

You must also write something for every exercise: 
Discuss the choices you made using precise language, explaining why you made those choices.

See Writing Assignment Guidelines (on web page or handout) for instructions about how to write up the results.

Exercise 1

f1[x_]:=1/(137-2x)
Plot[f1[x],{x,-10,10}]

Exercise 2

f2[x_]:=-x^3/1.02^x
Plot[f2[x],{x,-10,10}]

Exercise 3

f3[x_]:=2472+3338 x+1788 x^2+469 x^3+60 x^4+3 x^5
Plot[f3[x],{x,-10,10}]

Exercise 4

f4[x_]:=-100-(1/3)^(1/(700x^2))+800*2^(-50/x^2)
Plot[f4[x],{x,-10,10}]

Exercise 5

f5[x_]:=(x^5-2x^4+20x^2-10)/(x-20)
Plot[f5[x],{x,-10,10}]