Introduction to Mathematica for High School Math (for Students and Teachers) #11
Author
Ruth Dover
Title
Introduction to Mathematica for High School Math (for Students and Teachers) #11
Description
Introduction to Mathematica for High School Math
Category
Educational Materials
Keywords
Mathematics, education
URL
http://www.notebookarchive.org/2021-09-6h2efwy/
DOI
https://notebookarchive.org/2021-09-6h2efwy
Date Added
2021-09-14
Date Last Modified
2021-09-14
File Size
52.58 kilobytes
Supplements
Rights
Redistribution rights reserved



Tutorial 11: Calculus
Tutorial 11: Calculus
R. Dover, IMSA
Naturally, Mathematica® is pretty good at calculus. However, we will begin in a not-so-obvious place—with piecewise-defined functions. Then we will go back to limits and other calculus topics. For the most part, the examples should be self-explanatory. Create your own problems and examples as you go. (Note that the material in this notebook is optional. It is not required for subsequent notebooks.):
f[x_]:=Piecewise[{{-x+2,x≤1},{,x>1}}]
2
(x-1)
f[x]
The function was defined in a linear format, but when asked again, Mathematica offers nicer notation. Functions may be entered in this format using keystrokes.
To obtain the bracket, enter pw . Then enter Ctrl+Enter (or Ctrl+Return ). The four placeholders appear. Fill in each box and move from box to box with the Tab key. To add additional lines to your function, press Ctrl+Enter again as necessary:
Plot[f[x],{x,-2,3}]
Limits
Limits
Limit,x0
Sin[x]
x
Limit+1,x∞
2-4x
3
x
3
x
Remember that you can use the word "Infinity" instead of the symbol. (This is not to suggest that is better, but it is to remind you that it is an option.)
The notation for one-sided limits is different from the usual or notation used in books and handwritten work. When we write , is coming from the right, from above. Hence, the Wolfram Language™ uses . Similarly, for , is coming from the left, from below, so we use . With the function defined in the previous section, check out the following:
x
+
a
x
-
a
x
+
a
x
Direction->"From Above"
x
-
a
x
Direction->"From Below"
f
Limit[f[x],x1,Direction"FromAbove"]
Limit[f[x],x1,Direction"FromBelow"]
And the Wolfram Language cooperates nicely when the is not specified:
Direction
Limit[f[x],x1]
Clear[f]
Here is a different type of example. It should be recognizable:
Limit,h0
Tan[x+h]-Tan[x]
h
Derivatives
Derivatives
Be sure to indicate the variable in each case (note that this is one of the few cases where the Wolfram Language does not require the full English word for the command):
D[xLog[x],x]
D,x
f[x]
g[x]
Dg+t+,t
-1
2
2
t
v
0
s
0
To find the third derivative, y, the coding at the end changes:
3
d
3
dx
D[Tan[x],{x,3}]
Alternatively, you can define the function first and then use more standard notation:
f[x_]:=Sin[Sin[Sin[x]]]
f'[x]
f''[x]
On the Classroom Assistant palette, for the familiar derivative in single-variable calculus, use :
∂
∂
x
For multivariable functions, use (note that the parentheses following are necessary):
∂
,
∂
x,y
3
x
4
y
Piecewise Again
Piecewise Again
Look at the original again. (Well, reenter it.):
f
Clear[f];f[x_]:=Piecewise[{{-x+2,x≤1},{,x>1}}]
2
(x-1)
f'[x]
Pretty clever at the point where :
x=1
f'[1]
Clear[f]
Implicit Functions
Implicit Functions
Implicitly defined functions require some special care. First, we will name our equation. (Watch the equal signs!):
equat1=-4xy+12
3
x
2
y
We should not take a derivative with respect to yet, since Mathematica would interpret as a constant. We must first express as :
x
y
y
f[x]
equat1/.yf[x]
D[%,x]
Solve[%,f'[x]]
A Max-Min Problem
A Max-Min Problem
Consider the function over the interval . Find the area of the largest rectangle that may be constructed with two vertices on the axis and the other two vertices on the graph of the function.
y=cos(x)
(−π/2,π/2)
x
First, we will draw a picture to help understand the problem a little better, beginning with the graph of :
cos(x)
grcosx=Plot[Cos[x],{x,-2,2},PlotStyleThick]
The next group of commands is new. We construct a typical rectangle and then show the rectangle and the graph together. (Hopefully, the syntax will be clear. We will return to this idea later.):
rect={Magenta,Rectangle[{-1.1,0},{1.1,Cos[1.1]}]};Show[{Graphics[rect],grcosx},AxesTrue]
We now define the area function, where the base is and the height :
2x
cos(x)
areaofrect[x_]:=2xCos[x]
We will solve this problem using two different methods. First, find the derivative and solve for the stationary point. will be most helpful and appropriate here:
FindRoot
FindRoot[areaofrect'[x]0,{x,1}]
Substitute the value of to find the area:
x
areaofrect[x]/.%
As a second method—avoiding calculus—we will use a built-in Mathematica command:
FindMaximum[areaofrect[x],{x,1}]
Integrals
Integrals
Integrate[Cos[x],x]
3
x
+1x
1
4
x
As usual, the command may be entered in words or with the integral sign, using the palette, or use int and dd to obtain the special . As you would expect, Mathematica will integrate lots of functions, but there are some that cannot be done. It is not just that Mathematica cannot handle them; rather, they do not have elementary antiderivative formulas. Check these out:
∫Sin[Sin[x]]x
t
Sin[t]
t
Definite integrals may be done exactly or approximately, with choices for notation. For definite integrals, type dintt :
5
∫
3
x+1
2
x
Integrate[(x+1)/(x^2-4),{x,3,5}]
NIntegrate[(x+1)/(x^2-4),{x,3,5}]
Note that if is used around the symbolic integral sign, then Mathematica first does the integral exactly if possible. Then it changes the answer into decimal form. Using would generally be faster.
N[]
NIntegrate
An improper integral may be done as well:
∞
∫
1
1
3
x
Or try plotting an antiderivative (but this will be a little slow…):
PlotCos[t]t,{x,0,2π}
x
∫
0
Series
Series
The Taylor series in about of degree 6 for is found with the following code:
x
a=0
x
Series[,{x,0,6}]
x
The represents the error or remainder. To eliminate this (before graphing or using the polynomial in some other way), use the command :
7
O[x]
Normal
Normal[%]
Find several terms of the series for . Plot the polynomial and together.
sin(x)
sin(x)
Differential Equations
Differential Equations
As with implicit derivatives, be sure to indicate that is a function of by using . See the following:
y
t
y[t]
DSolve[y''[t]-y'[t]-6y[t]t,y[t],t]
Of course, Mathematica can do lots more with differential equations. If interested, check it out in the Documentation Center.
Exercises
Exercises
This time, we will do various things to one function. This will provide both practice and learning.
Enter the piecewise-defined function .
g(x)=
|
Plot the function. Then evaluate the function at a few values of , including .
x
x=−2
Evaluate the two one-sided limits and the general limit as .
x−2
Take the derivative of .
g
Now find the definite integral from to 3.
−2


Cite this as: Ruth Dover, "Introduction to Mathematica for High School Math (for Students and Teachers) #11" from the Notebook Archive (2021), https://notebookarchive.org/2021-09-6h2efwy

Download

