Mathematica Instructions
Here are instructions on how to use Mathematica for Calculus II:
Introductory Instructions:
- Download Mathematica
- For basic mathematica usage instructions; using mathematica for algebra; using mathematica for precalculus; using mathematica for calculus I:
Section 5.2
- Evaluating sums (e.g., sum of i from 1 to n)
- Evaluating Riemann sums
- Store integrand into f(x) using:
f[x_]:=function
- Store Δx into variable dx using:
dx=(b-a)/n
– where a is lower limit
of integration and b is upper limit of integration
- Find xi and store into variable xi using:
xi=expression
- Evaluate the sum and store into sum variable:
sum = Sum[f[xi]*dx,{i,1,n}]
- Evaluate the limit of the sum as n → ∞:
Limit[sum, n -> Infinity]
- Graphing Riemann sums
Section 5.2 & 5.3:
- Evaluating definite integrals
- Define function as f[x_] (see above), then use:
Integrate[f[x], {x, a, b}]
note: where a is the lower limit of integration and b is the upper limit of integration; OR
Integrate[expression, {x, a, b}]
note: NIntegrate
can be used to find an approximation of the definite integral
- Shading area under the curve
- Define function as f[x_] (see above), then use:
Plot[f[x], {x, a, b}, Filling -> Axis, FillingStyle -> Hue[d]]
note: where [a, b] is a subset of the domain; and
0 ≤ d ≤ 1.
Section 5.4:
- Fundamental Theorem of Calculus, Part 1 (FTC1)
- Define function as f[t_] as function (see above), then use:
D[Integrate[f[t], {t, 1, g(x)}], x]
– where
g(x) is some function of x
Section 5.7 & Appendix G:
- Partial Fractions
- Define rational function as f[x_] as function (see above), then use:
Apart[[f[x]]]
- Solving Systems of Equations [needed to algebraically find partial fractions]
- To solve the system, expr1 = a,
expr2 = b, expr3 = c,
etc, use:
Solve[{expr1, expr2, expr3} == {a, b, c}]
NOTE: You must have the same number of equations as variables; and
the order of the variables in each expression is not important.
Section 5.9:
- Approximate Integration
Section 5.10:
- Improper Integrals
- Infinite Intervals:
- Formal Method: Use Limit function
Limit[Integrate[f[x], {x, a, b}], a -> -Infinity]
where b is the value for the upper limit of integration
Limit[Integrate[f[x], {x, a, b}], b -> Infinity]
where a is the value for the lower limit of integration
- NOTE: If a = –∞ and b = ∞, then you need to split the integral
into two different integrals using x = c and use both of the above improper integrals
NOTE: If Mathematica returns a number, then the improper integral converged to that number; if Mathematica returns either
–∞ or ∞, then the improper integral diverged.
- Informal Method: Use Integrate function directly
Integrate[f[x], {x, a, b}]
where a = –∞, b = ∞, or both
- NOTE: If Mathematica returns a number, then the improper integral converged to that number; if Mathematica returns an error message
including the phrase "does not converge on", then the improper integral diverged.
- Discontinuous Integrands:
- Formal Method: Use Limit function
Limit[Integrate[f[x], {x, a, b}], a -> c, Direction -> -1]
where f(x) is
not continuous at x = c and b is the value for the upper limit of integration
Limit[Integrate[f[x], {x, a, b}], b -> c, Direction -> 1]
where f(x) is
not continuous at x = c and a is the value for the lower limit of integration
- NOTE: If f(x) is not continuous at x = d for
some d in the interval (a, b), then you need to split the integral
into two different integrals using x = d and use both of the above improper integrals
NOTE: If Mathematica returns a number, then the improper integral converged to that number; if Mathematica returns either
–∞ or ∞, then the improper integral diverged.
- Informal Method: Use Integrate function directly
Integrate[f[x], {x, a, b}]
where f(x) is not continuous at
x = a, x = b, or
x = d in the interval (a, b)
- NOTE: If Mathematica returns a number, then the improper integral converged to that number; if Mathematica returns an error message
including the phrase "does not converge on", then the improper integral diverged.
Section 6.1:
- Shading area between two curves
- Define function as f[x_] and g[x_] (see above), then use:
Plot[{f[x], g[x]}, {x, xmin, xmax}, Filling -> {1 -> {{2}, Hue[d]}}]
note: where [a, b] is a subset of the domain;
0 ≤ d ≤ 1; and only change the value for d
in the Filling
option (i.e., do not change the 1 and 2 in the Filling
option)
- Plot two functions of y
- Define function as f[y_] and g[y_] (see above), then use:
ContourPlot[{x == f[y], x == g[y]}, {x, xmin, xmax}, {y, ymin, ymax}, Frame -> False, Axes -> True]
- Find the intersection(s) of two functions of y
- Define function as f[y_] and g[y_] (see above), then use:
Solve[f[y] == g[y], y]
- note: To find the x-coordinates, evaluate f(y) at each value calculated above
Appendix H:
- Plotting polar curves
- Define function as r[t_] (see above), then use:
PolarPlot[r[t], {t, tmin, tmax}]
- Plotting polar curve, θ = a
- Convert to cartesian equation
- Plot two polar curves
- Define function as r1[t_] and r2[t_] (see above), then use:
PolarPlot[{r1[t],r2[t]}, {t, tmin, tmax}]
- Find the intersection(s) of two polar curves
- Define function as r1[t_] and r2[t_] (see above), then use:
Solve[r1[t] == r2[t], t]
- Plot a polar curve along with a cartesian equation
- Define variable plot1 using:
plot1 = PolarPlot[r1[t], {t, tmin, tmax}]
- Define variable plot2 using:
plot2 = Plot[f[x], {x, xmin, xmax}]
- Use:
Show[plot1, plot2]
Section 7.1:
- Find the general solution to differential equation
- Store y′ into variable eqn using:
eqn = y'[t] == f[t, y]
where f[t, y] is the differential equation
Note: Make sure to use y[t] for every dependent variable
- Solve for y using:
y[t]/.DSolve[eqn, y[t], t]
- Solve Initial-Value Problem
- Store y′ into variable eqn using:
eqn = y'[t] == f[t, y]
where f[t, y] is the differential equation
Note: Make sure to use y[t] for every dependent variable
- Solve for y using:
y[t]/.DSolve[{eqn, y[a]==b}, y[t], t]
where y(a) = b is the initial condition
Section 7.2:
- Plotting direction field for y′ = f(x, y)
VectorPlot[{1, f[x, y]}, {x, xmin, xmax}, {y, ymin, ymax}, Axes -> True]
- Euler's method
Section 7.3:
- Solving Separable Equations
DSolve[y'[x] == f[x, y], y[x], x]
where f[x, y] is the separable equation
Section 8.1:
- Sequences
- List first i terms given an,
using:
Table[a_n, {n, nmin, i}]
where a_n is the nth term and i is the number of terms desired
- Plot Sequences
ListPlot[Table[a_n, {n, nmin, i}]]
where a_n is the nth term and i is the number of terms desired
Note: You can use the option PlotRange -> {ymin, ymax}
to keep the y-values of the plot constant
- Evalaute the Limit of Sequences as n → ∞
Limit[a_n, n -> Infinity]
where a_n is the nth term
Section 8.2:
- Series
- Evaluate the sum of the first i terms of a series given an,
using:
Sum[a_n, {n, 1, i}]
where a_n is the nth term and i is the number of terms desired
- Find the partial sums, Si, of a series
Table[Sum[a_n, {n, 1, k}], {k, 1, i}]
where a_n is the nth term and i is the number of sums desired
Note: For decimal output, use //N
after the Table function
- Plot Partial Sums
ListPlot[Table[Sum[a_n, {n, 1, k}], {k, 1, i}]]
where a_n is the nth term and i is the number of terms desired
Note: You can use the option PlotRange -> {ymin, ymax}
to keep the y-values of the plot constant
Section 8.7:
- Maclaurin Series
- Find the first i terms of the Maclaurin series for f(x),
using:
Normal[Series[f[x], {x, 0, i}]]
where i is the number of terms desired
- Taylor Series
- Find the first i terms of the Taylor series for f(x),
using:
Normal[Series[f[x], {x, a, i}]]
where i is the number of terms desired and the series is centered about x = a
using: Normal[Series[f[x], {x, a, i}]]
where i is the number of terms desired and the series is centered about x = a