# Mathematica Instructions

Here are instructions on how to use Mathematica for Calculus I:

Introductory Instructions:

2. Basic Functions (note the capitalization of first letter)
• For ex use: ` Exp[x]`
• For π use: ` Pi`
• For sin(x) use: ` Sin[x]` – all other trigonometric functions are similar
• For sin–1(x) use: ` ArcSin[x]` – all other trigonometric functions are similar
• For | x | use: ` Abs[x]`
• For √x use: ` Sqrt[x]`
• For ∞ use: ` Infinity`
• For ln(x) use: ` Log[x]`
• For logb(x) use: ` Log[b, x]`
• For ≤ use: ` <=`
• For ≥ use: ` >=`
• For sinh(x) use: ` Sinh[x]` – all other hyperbolic functions are similar
• For sinh–1(x) use: ` ArcSinh[x]` – all other inverse hyperbolic functions are similar
3. To execute mathematica code
• Hold `SHIFT` key and press `ENTER`

Algebra:

1. Evaluate f(x) at x = a
• Define function using: `f[x_] := expression`, then use: `f[a]`
note: expression is any algebraic expression
note: After evaluating, you should clear the function using: `Clear[f]`
2. Evaluate f(x) at x = a
• `expression /. x -> a`
note: expression is any algebraic expression
note: You can quickly evaluate the expression at several values of x using: `expression /. x -> {a1, a2, a3}` [where a1, a2, a3, etc. are different x-values]
3. Evaluate
• `N[expression, d]`
note: expression is any expression to be evaluated
note: d is the number of digits needed in answer
4. Define piecewise-defined function
• Define function using: `f[x_] := Piecewise[{{function1, condition1},{function2, condition2}}, {x}]`
5. Plot a function
• `Plot[expression, {x, xmin, xmax}]`
note: To change the y-values shown on the graph, use the additional argument: `PlotRange -> {ymin, ymax}`
note: To center the graph at the origin, use the additional argument: `AxesOrigin -> {0, 0}`
6. Plot a function
• Define a function (see above), then use: `Plot[f[x], {x, xmin, xmax}]`
7. Plot the real part of a radical function
• `Plot[Sign[x]*Abs[x]^(1/n), {x, xmin, xmax}]`
note: 1/n is the nth root function
8. Plot multiple functions on same graph
• `Plot[{expression1, expression2, expression3}, {x, xmin, xmax}]`
note: expression1, expression2, expression3, etc. are different functions
9. Implicitly plot an equation
• `ContourPlot[expression1 == expression2, {x, xmin, xmax}, {y, ymin, ymax}, AxesOrigin -> {0, 0}] `
note: the last two arguments may not be needed
10. Factor/Simplify an expression
• `Factor[expression]`
11. Simplify an expression
• `Simplify[expression, var]`
note: var is the independent variable
• `FullSimplify[expression, var]`
note: var is the independent variable
12. Expand an expression
• `Expand[expression]`
13. Combine rational expressions
• `Together[expression1 + expression2]`
note: You may have more than two rational expressions and can add or subtract the expressions
14. Find real roots of polynomial equations
• `Solve[polynomial == 0, x, Reals]`
note: For approximate solutions, use `NSolve[polynomial == 0, x, Reals]`

Precalculus:

1. Expand a trigonometric expression
• `TrigExpand[expression]`
2. Find real roots of trignometric equation (if NSolve does not work)
• Plot function, then use: `FindRoot[expression == 0, {x, xval}]`
note: xval is an x-value near the x-intercept of the function

Section 2.2:

1. Evaluate bidirectional limits
• `Limit[expression, var -> a]`
2. Evaluate limits from left
• `Limit[expression, var -> a, Direction -> 1]`
3. Evaluate limits from right
• `Limit[expression, var -> a, Direction -> -1]`

Section 2.5:

1. Evaluate limits at infinity
• `Limit[expression, var -> Infinity]`

Section 2.6:

1. Find the derivative at a point x = a
• Define a function (see above), then use: `Limit[(f[a + h] - f[a])/h, h -> 0]`; OR
• Define a function (see above), then use: `f'[a]`

Section 2.7:

1. Find the derivative function
• Define a function (see above), then use: `Limit[(f[x + h] - f[x])/h, h -> 0]`; OR
• `D[function, var]`
note: var is the independent variable; OR
• Define a function (see above), then use: `f'[x]`

Section 2.8:

1. Multiple derivatives
• `D[function, {var, n}]`
note: var is the independent variable and n is the nth derivative; OR
• Define a function (see above), then use: `f''[x]`
note: use as many `'` as needed
2. Graph derivative functions
• Define a function (see above), then use: `Plot[f'[x], {x, xmin, xmax}]`
note: you can graph any multiple derivative by using as many `'` as needed
3. Find location(s) of local maximum(s) and local minimum(s)
• Define a function (see above), then use: `NSolve[f'[x] == 0, x, Reals]`
4. Find location(s) of inflection point(s)
• Define a function (see above), then use: `NSolve[f''[x] == 0, x, Reals]`

Section 1.7:

1. Find the parametric equations
• `ParametricPlot[{x-function, y-function}, {t, tmin, tmax}]`

Section 3.5:

1. Implicit differentiation
1. Store the equation into the variable equation1: `equation1 = expression1 == expression2`, then `SHIFT-ENTER`
2. Convert all y-variables into a function of x, i.e., y[x], and store into new variable: `equation2 = equation1 /. y -> y[x]`, then `SHIFT-ENTER`
3. Differentiate each side of the equation and store into new variable: `equation3 = D[equation2[[1]], x] == D[equation2[[2]], x]`, then `SHIFT-ENTER`
4. Solve the last equation for y'[x]: `Solve[equation3, y'[x]]`, then `SHIFT-ENTER`

Section 4.5:

1. l'Hôpital's Rule
• Define numerator function as f[x_] and denominator function as g[x_] (see above), then use: `Limit[f'[x]/g'[x], x -> a]`

Section 4.7:

1. Newton's Method
1. Define function as f[x_] (see above)
2. copy and paste the entire algorithm below, then `SHIFT-ENTER`:

```recursiveNewton[f_, x_?NumberQ, previousX_: 0, tolerance_: (N[10^-20])] :=
If[Abs[x - previousX] > tolerance, Print[N[x, 20]];
recursiveNewton[f, N[x - f[x]/f'[x], 30], x, tolerance], x  (*return result*)]```

3. then use: `recursiveNewton[f, guess]`
note: where guess is an x-value near the root of the function

Section 4.8:

1. Antiderivatives/Indefinite Integrals
• Define numerator function as f[x_] (see above), then use: `Integrate[f[x], x]`; OR
• `Integrate[expression, x]`

Section 5.2

1. Evaluating sums (e.g., sum of i from 1 to n)
• `Sum[i, {i, 1, n}]`
2. Evaluating Riemann sums
1. Store integrand into f(x) using: `f[x_]:=function`
2. Store Δx into variable dx using: `dx=(b-a)/n` – where a is lower limit of integration and b is upper limit of integration
3. Find xi and store into variable xi using: `xi=expression`
4. Evaluate the sum and store into sum variable: `sum = Sum[f[xi]*dx,{i,1,n}]`
5. Evaluate the limit of the sum as n → ∞: `Limit[sum, n -> Infinity]`

Section 5.2 & 5.3:

1. 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

Section 5.4:

1. 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

Still need to code:

• Graphing Riemann sums (Section 5.1)