Calculus II Partial Solutions to
Mathematica Introduction

Author: Barry McQuarrie
University of Minnesota, Morris
Aug 2015

For the first part of the semester, Mathematica will mostly be used to verify things we have done by hand. We will use it more extensively in the second half of the semester.

Use the Mathematica Reference and file Mathematica Basics to help you answer these questions. You may want to skim through Mathematica Basics before starting, since everything you need to answer these questions is in that file. Certainly you should have the Mathematics Basics file open while you work through this!

This is not going to be graded. The goal is to spend some quality time using Mathematica to do things for us, and familiarizing ourselves with Mathematica syntax. You will become proficient with Mathematica syntax as the semester progresses, I do not expect you to have mastered it all today!

1. Syntax Checks

Clear[f,g,h]

The following Mathematica commands have syntax errors. Fix the errors so the commands will work.

Problem 1

plot[x^2,(x,-2,2)]

Correction

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

Problem 2

h[x]=Exp[x]
h[1]

Correction

h[x_]=Exp[x]
h[1]

Problem 3

a=0.1
g[x]=(3x-4)/(ax)
Plot[g[x],{x,1,3}]

Correction

a=0.1
g[x_]=(3x-4)/(a*x)
Plot[g[x],{x,1,3}]

Problem 4

Solve[3x^2-4x=2,x]

Correction

Solve[3x^2-4x==2,x]

Problem 5

f[x_]=e^{-3x}
Plot[f[x],{x,-2,2}]

Correction

f[x_]=E^(-3x)
Plot[f[x],{x,-2,2}]

Problem 6

f[t_]=Log[t^2]
Solve[f[x]==3,t]

Correction

f[t_]=Log[t^2]
Solve[f[t]==3,t]

Problem 7

Here we are trying to compute the (723^rd) derivative with respect to t and evaluate at t=-e. Can you get both an exact and decimal approximation to the result?

f[t_]=Log[t^2]
Differentiate[f,x,723][-e]

Correction

f[t_]=Log[t^2]
Derivative[723][f][-E]
N[%]

Problem 8

Here we are trying to integrate f(t) for t from 0 to 12.

Aside: What happens to the integrand at t=0? This is an example of an Improper Integral, which we will study in a couple of weeks.

f[t_]=Log[t^2]
Integral[f,x,1,2]

Correction

f[t_]=Log[t^2]
Integrate[f[t],{t,1,12}]

f[0]

Problem 9

Note: to change the formatting on a cell you have already typed in (like the ones below) you have to select the cell by highlighting the bracket on the right hand side before you make the change. Selecting the text will not work as you expect, you have to select the cell.

Typeset this sentence as a subsection.

Typeset this sentence as a subsubsection.

Typeset this sentence as text.

Take a moment to look over the other typesetting options available.

2. Using Mathematica to Do Things

Clear[f,g,h]

Use Mathematica to perform the following tasks.

Problem 1

Evaluate cos(π/9) to 12 decimals of accuracy. Then evaluate π to 10 000 decimals, just so we can say we did.

Solution

SetPrecision[Cos[Pi/9],12]
N[Pi,10000]

Problem 2

Factor 816 (x^2)-58 (x^3)+(x^4)+10 x y-(y^2)

Solution

Factor[816(x^2)-58(x^3)+(x^4)+10x*y-(y^2)]

Problem 3

Multiply out the quantity (((1+b))^34).

Solution

Expand[(((1+b))^34)]

Problem 4

Plot the function f(x)=(x/((x^2)+1)).

Your plot should look like this:

Solution

Plot[x/(x^2+1),{x,-2,2}]

Problem 5

Plot the implicit function x+y=sin x tan y, for -2≤x≤2 and -2≤y≤2.

Solution

ContourPlot[x+y==Sin[x]Tan[y],{x,-2,2},{y,-2,2}]

ContourPlot[x+y==Sin[x]Tan[y],{x,-2,2},{y,-2,2},PlotPoints->40]

Problem 6

Plot the function y=sin(x)-cos(x) as a dashed, thick, purple line.

Solution

Plot[Sin[x]-Cos[x],{x,-Pi,Pi},PlotStyle->{Dashed,Thick,Purple}]

Problem 7

Define the piecewise defined function

f(x) = (Piecewise[{{x
5, x<5
5≤x<12}, {-sin(2x), x≥12}}])

Then, plot f(x) and f'(x) on the same set of axes.

Solution

f[x_]=Piecewise[{{x,x<5},{5,5≤x≤12},{-Sin[2x],x≥12}}]

Plot[{f[x],f'[x]},{x,0,23},PlotRange->All]

Problem 8

Plot the three functions on the same set of axes: f(t)=t, g(t)=sin t, h(t)=(Sqrt[t])

Solution

Plot[{t,Sin[t],Sqrt[t]},{t,-3,3}]

Problem 9

Find the roots of f(x)=3(x^4)+(x^2)-1. Verify the roots you find make f zero. Hint: Define f(x), use Solve, then copy/paste to evaluate f at the roots. You may need to use Simplify to verify the roots make f zero.

Solution

f[x_]=3x^4+x^2-1

Solve[f[x]==0,x]

f[-(Sqrt[(1/6) (-1+(Sqrt[13]))])]//Simplify
f[(Sqrt[(1/6) (-1+(Sqrt[13]))])]//Simplify
f[-I (Sqrt[(1/6) (1+(Sqrt[13]))])]//Simplify
f[I (Sqrt[(1/6) (1+(Sqrt[13]))])]//Simplify

Problem 10

Find f∘g when f(x)=cos x and g(x)  = arcsin x. What is the value of (g ∘f)(2) ?

Solution

f[x_]=Cos[x]
g[x_]=ArcSin[x]
g[f[2]]

Problem 11

Sketch the region that is bounded by y=x-1 and (y^2)=x+1. Then find the points of intersection of the two curves. If you want to challenge yourself, try to get the region as a shaded region using RegionPlot.

Solution

p1=Plot[x-1,{x,-3,5}];
p2=ContourPlot[(y^2)==x+1,{x,-3,5},{y,-3,5},ContourStyle->Red];
p3=Show[p1,p2,AspectRatio->1]

The points of intersection are:

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

Here is the plot with the region shaded:

p4=RegionPlot[(y^2)≤x+1&&y>x-1,{x,-3,5},{y,-3,5},PlotPoints->50]

Show[p4,p3]

Problem 12

Sketch the region that is bounded by y=(e^x), y=(e^(-x)), and x=1.

Solution

p1=Plot[{Exp[x],Exp[-x]},{x,-1,2}];
p2=ContourPlot[x==1,{x,-1,2},{y,-1,4},ContourStyle->Red];
p3=Show[p1,p2,AspectRatio->1]

Here is the plot with the region shaded:

p4=RegionPlot[x≤1&&y≤Exp[x]&&y≥Exp[-x],{x,-1,2},{y,-1,4},PlotPoints->50]

Show[p4,p3]

3. Homework 1 Check of Solutions

Homework 1 should be completed entirely by hand, but it is a good idea to check your answers using Mathematica. You should do that here.

Problem 1

Simplify cos(arcsin(t/2)).

Problem 2

Solve ln(x)-(1/2)ln(x+4)=0 for real valued solutions.

Problem 3

Determine the points of intersection and sketch the region enclosed by y-3=2(x^2) and (x^2)+(((y-3))^2)=1.

Problem 4

Use logarithmic differentiation to find y' when y=(((cos(x)))^(3x)).

Problem 5

Evaluate ∫sin(2x)cos(3cos(2x))dx.