Math 225: Calculus III     Assignment 1

Name:

Section:

I affirm that the solutions presented in this assignment are entirely my own work.

Signature:

Instructions

This notebook is an introduction to Mathematica  and some of its basic functions which we shall be using throughout the course. You should look through the notebooks in the Notebook folder (most of these are reprinted in the back of the Lecture Notes). Mathematica  reference books are available in the labs. Be sure to check out the Help menu.

Below you will find some simple examples of how to execute Mathematica  commands. Each example is followed by a problem for which you must type in a solution, mimicking the preceding example. Before you move on to the next problem, you should "clear" the variables you used in the current probem, so Mathematica won't remember any special values or expression you may have assigned to them. To do this use the command,
    Clear[x,y,...]
listing any variable names you used. If you get unexpected expressions back from Mathematica, try clearing the variable names and starting over. You may need to use the command Remove[x,y,...] (a more "powerful' version of Clear[]) or even save, quit, and restart Mathematica to get back to normal.

If a section of this notebook seems to "disappear" it may be because a "cell" has been "closed". A cell is one or more lines in a notebook grouped together. The cell is indicated by a bar on the right hand side of the cell. To select a cell, click on this bar. To open or close a cell double-click on this bar.

Before you print out the assignment, make sure Show In/Out Names is not checked in the Kernel menu. It would also be a good idea to close this Intructions cell and all of the Example cells  (double-click on the bar on the far right) before printing.

The following Initialization cell should always be executed before you type in any other statements. You were asked when you opened the notebook if you wanted to do this. You should normally click OK to such a question. If you did not click OK, select the cell below by clicking on the bar on the right and then hit the ENTER key.

Initialization

<<Calculus`Math225`

Example 1

Find the value of (2 + 5*Sqrt[3])^3/2 to 10 significant digits.

Solution

Arithmetic operations are the usual : + - * / and parentheses are used to group expressions. Exponents are indicated by ^.  Sqrt[x] stands for the square root, x^(1/2).
Multiplication is normally indicated by *, but you can use a SPACE instead, for example,
2 x is the same as 2*x. However, be careful not to enter something like x2 when you mean x*2 since Mathematica will read x2 as a variable with the name "x2". Although Mathematica  is smart enough to recognize 2x as 2*x,  you should get in the habit of always using a space or * for multiplication.

To solve the problem, first type (2 + 5*Sqrt[3])^3/2 and the hit the ENTER key (not the RETURN key which will just take you to the next line). A substitute for ENTER is SHIFT-RETURN.

(2 + 5*Sqrt[3])^3/2

Mathematica  has left the expression in its original form since it tries to keep all expressions in their most exact form. To get a decimal approximation we must apply the function N[] that converts an expression to a decimal.

N[(2 + 5*Sqrt[3])^3/2]

To get 10 significant digits, we must add the optional second argument to N[].

N[(2 + 5*Sqrt[3])^3/2, 10]

To find out more information about a function you can enter ? followed by the function name. For example,

?N

You can also get information in the "Help" menu.

Problem 1

Find the value of  (2*Pi + Sqrt[3])^(5/2) to 20 significant digits. (Pi is a constant built into Mathematica  that represents the exact mathematical value of π. Other important constants to be aware of like this are E == 2.71828... for the base of the natural logarithms and I == Sqrt[-1]). Click in the line BELOW the word "Solution" to enter the expression. Then hit ENTER (not RETURN).

Solution

Example 2

Find the first and second derivatives of x^2 Sin[Cos[x]].

Solution

The function to use here is D[f,x] which takes the derivative of f with respect to x.

D[ x^2 Sin[Cos[x]] , x ]

The second derivative is the derivative of the previous output:

D[ %, x ]

The symbol % stands for the previous output. Be careful when you use this that you know what statement is being substituted for %. Each output also has a number (check "Show In/Out names" in the "Kernel" menu to see them). To substitute the 17th output into another expression, use %17. Another way to take the second derivative is to enter D[f,x,x] or
D[f,{x,2}].

D[ x^2 Sin[Cos[x]] , x, x ]

You can also set up a function as follows (the underscore _ is VERY important):

f[x_] = x^2 Sin[Cos[x]]

After entering this, you can take the derivatives of f by entering f'[x] and f''[x]:

f'[x]

f''[x]

Notice how all built in functions in Mathematica , like Sin[] and Cos[], are capitalized and that functions always use SQUARE braces, NOT parentheses.

Problem 2

Find the first and second derivatives of the function Sin[Log[Sqrt[1-x^2]]] using the function D[] and using the prime notation f'[x], f''[x] as above.

Solution

Example 3

Find an anti-derivative of 1/(1-x^2). Integrate 1/(1-x^2) from 0 to 1/2. Find an approximation to the integral of 1/Sqrt[1+x^3] from 0 to 1.

Solution

To find an antiderivative, use the function Integrate[f,x]:

Integrate[  1/(1-x^2), x ]

The definite integral is found by grouping the limits of integration with the variable:
{x,0,1/2}. (By the way, curly braces, {, }, are always used to lists things in Mathematica  and it is the usual way arguments are grouped together in functions.)

Integrate[  1/(1-x^2), {x, 0, 1/2} ] //Simplify

A numerical approximation is given by

N[%]

If you only want a numerical approximation to begin with, then use the function NIntegrate[] (limits MUST be provided for this function).

NIntegrate[  1/(1-x^2), {x, 0, 1/2} ]

To do the other integral:

Integrate[  1/Sqrt[1+x^3], x ]

To find the value numerically:

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

Problem 3

Find an anti-derivative of 2/(1-x^2). Integrate 2/(1-x^2) from 2 to 3. Find an approximation to the integral of 1/(2 + E^Sqrt[x]) from 0 to 1.

Solution

Example 4

Solve the system of equations 2 x^2 - 2 x y - x^2 y + x y^2 == 0,
x^2 + y^2 == 1.

Solution

Note that EQUATIONS in Mathematica  are represented by a DOUBLE equal sign, ==. A single equal sign, =, means you want to assign what is on the right hand side to the variable on the left hand side. This is a very common mistake, so beware. To solve the system "by hand",  we factor the first equation x(y-x)(y-2) == 0, so that x == 0, or y == x, or y == 2. Plugging these possibilities into the second equation gives 0^2 + y^2 == 1, or 
x^2 + x^2 == 1, or x^2 + 2^2 == 1, respectively. The soultions are then {0,±1}, or ±{1/Sqrt[2],1/Sqrt[2]}. The Solve[] function does this in one step. The equations must be grouped in curly braces {, }.

Solve[{2 x^2 - 2 x y - x^2 y + x y^2 == 0, 
       x^2 + y^2 == 1}]

To convert to decimal approximations:

N[%]

Note that some of these answers contain I which stands for Sqrt[-1]. You should ignore
solutions that have I in them.

You can also use NSolve[]:

NSolve[{2 x^2 - 2 x y - x^2 y + x y^2 ==0,
        x^2 + y^2 ==1}]

Problem 4

Solve the system of equations x^2 y - x y + x y^2 == 0,
x^2 + y - y^2 == 10.

Solution

Example 5

Plot the graph of the function x + Sin[x].
Plot the graph of the function  x y + Sin[x y].
Plot the graph of the curve {t^2, t^3}.
Plot the graph of the curve {t, t^2, t^3}.

Solution

To plot a function of 1 variable use Plot[].

Plot[x + Sin[x], {x,0,4Pi}]

For a function of two variables, use Plot3D[]:

Plot3D[x y + Sin[x y], {x,0,2Pi}, {y,0,2Pi}]

For a curve in the plane use ParametricPlot[]:

ParametricPlot[{t^2,t^3}, {t,-1,1}]

There are many options you can give to the plotting functions. You may want to override Mathematica's choices for scaling the axes and cropping the plot. For example, to get a more "natural" picture of the above graph, I set the scale for both axes to be the same (AspectRatio->1) and explicitly gave the range for the x and y axes.

ParametricPlot[{t^2,t^3}, {t,-1,1}, AspectRatio->1,
PlotRange->{{0,1},{-1,1}}]

For curves in space, use ParametricPlot3D[]:

ParametricPlot3D[{t,t^2,t^3}, {t,-1,1}]

This curve is a bit hard to see. We'll talk about how to better render such pictures later in the course.

Problem 5

Plot the graph of the function Cos[x]/(9+x^2).
Plot the graph of the function  Sin[2*x] - Cos[y/2].
Plot the graph of the curve {3*Cos[t], 2*Sin[t]}.
Plot the graph of the curve {t, Cos[2*Pi*t], Sin[2*Pi t]}.
Plot the graph of the curve {t, Cos[2*Pi*t], Sin[3*Pi*t]}.

Solution