mathematica quickstart math101c - ohlone librarycosinecurve = plot@5 cos@td, 8t, 0, 4 p
TRANSCRIPT
Mathematica QuickStart for Calculus 101C
Algebra
Solving Equations
Exact Solutions to single equation:
In[88]:= Solve@x^3 + 5 x - 6 ã 0, xD
Out[88]= :8x Ø 1<, :x Ø1
2I-1 - Â 23 M>, :x Ø
1
2I-1 + Â 23 M>>
Exact Solution to a system of equations:
In[89]:= SolveA9x2 + y2 ã 4, x2 + 4 y2 ã 9=, 8x, y<E
Out[89]= ::x Ø -7
3, y Ø -
5
3>, :x Ø -
7
3, y Ø
5
3>,
:x Ø7
3, y Ø -
5
3>, :x Ø
7
3, y Ø
5
3>>
Approximate Solutions to a single equation:
In[90]:= NSolve@x^3 + 5 x - 6 ã 0, xD
Out[90]= 88x Ø -0.5 - 2.39792 Â<, 8x Ø -0.5 + 2.39792 Â<, 8x Ø 1.<<
Factoring
In[91]:= FactorAx2 y3 + 6 x y2 - 7 yE
Out[91]= y H-1 + x yL H7 + x yL
Expansions
In[92]:= ExpandAHx + 2 yL5E
Out[92]= x5 + 10 x4 y + 40 x3 y2 + 80 x2 y3 + 80 x y4 + 32 y5
Partial Fractions
In[93]:= ApartB4 x - 3
x2 - 7 x + 12F
Out[93]=13
-4 + x-
9
-3 + x
Functions
Functions in Mathematica use the notation f[x_] when declaring the function. Notice the underscore character after the variable.
In[94]:= f@x_D = x^2 - 5 x
Out[94]= -5 x + x2
When using the function, you do not need the underscore character.
In[95]:= fAx2E
Out[95]= -5 x2 + x4
In[96]:= f@x + hD - f@xD
h
Out[96]=5 x - x2 - 5 Hh + xL + Hh + xL2
h
In[97]:= ExpandBf@x + hD - f@xD
hF
Out[97]= -5 + h + 2 x
Calculus Operations
2 mathematica_quickstart_math101c.nb
Calculus OperationsMathematica has all the standard calculus operations, including left and right side limits.First create a function.
In[98]:= f@x_D =Sin@xD
x
Out[98]=Sin@xD
x
In[99]:= g@x_D = PiecewiseA99x2, x > 0=, 94 - x2, x < 0==E
Out[99]=
x2 x > 0
4 - x2 x < 00 True
Limits
In[100]:= Limit@f@xD, x Ø 0D
Out[100]= 1
In[101]:= Limit@g@xD, x Ø 0, Direction Ø 1D H*Note this means heading to the right.*L
Out[101]= 4
In[102]:= Limit@g@xD, x Ø 0, Direction Ø -1D H*Note this means heading to the right.*L
Out[102]= 0
Derivatives
The notation is simple for functions.
In[103]:= f'@xD
Out[103]=Cos@xD
x-Sin@xD
x2
mathematica_quickstart_math101c.nb 3
In[104]:= f'Bp
2F
Out[104]= -4
p2
Indefinite Integrals
In[105]:= IntegrateAx3, xE
Out[105]=x4
4
Definite Integrals
In[106]:= IntegrateAx3, 8x, 1, a<E
Out[106]= -1
4+a4
4
Series
To find ⁄k=1
5k2
In[107]:= SumAx2, 8x, 1, 5<E
Out[107]= 55
To find 5 terms of the Taylor series expansion of x7 at c = 1,
In[108]:= SeriesAx7, 8x, 1, 5<E
Out[108]= 1 + 7 Hx - 1L + 21 Hx - 1L2 + 35 Hx - 1L3 + 35 Hx - 1L4 + 21 Hx - 1L5 + O@x - 1D6
To eliminate the “O” notation at the end, use Normal at the end of the command.
In[109]:= SeriesAx7, 8x, 1, 5<E êê Normal
Out[109]= 1 + 7 H-1 + xL + 21 H-1 + xL2 + 35 H-1 + xL3 + 35 H-1 + xL4 + 21 H-1 + xL5
Simple Graphing
4 mathematica_quickstart_math101c.nb
Simple Graphing
Graphing functions
Standard functions are graphed with the Plot function.
In[110]:= Plot@3 Sin@tD, 8t, 0, 4 p<D
Out[110]=2 4 6 8 10 12
-3
-2
-1
1
2
3
To change the style, use the PlotStyle option.
In[111]:= Plot@3 Sin@tD, 8t, 0, 4 p<,PlotStyle Ø 8Red, [email protected]<D
Out[111]=2 4 6 8 10 12
-3
-2
-1
1
2
3
To combine plots, create named plots separately and use the Show command to combine them.
mathematica_quickstart_math101c.nb 5
In[112]:= SineCurve = Plot@3 Sin@tD, 8t, 0, 4 p<, PlotStyle Ø 8Red, [email protected]<D;CosineCurve = Plot@5 Cos@tD, 8t, 0, 4 p<, PlotStyle Ø 8Blue, [email protected]<D;Show@SineCurve, CosineCurve, PlotRange -> AllD
Out[114]=2 4 6 8 10 12
-4
-2
2
4
Fancy Graphing
Polar Curves
Polar curves can be graphed using the PolarPlot command. For example, to graph r = 3cos 2q, use
6 mathematica_quickstart_math101c.nb
In[115]:= PolarPlot@3 Cos@3 thetaD, 8theta, 0, 2 p<D
Out[115]=-1 1 2 3
-2
-1
1
2
Parametric Curves
To graph a set of parametric functions x(t) = cos 3t and y(t) = sin 2t, use the ParametricPlot com-mand.
mathematica_quickstart_math101c.nb 7
In[116]:= ParametricPlot@8Cos@3 tD, Sin@2 tD<, 8t, 0, 2 p<D
Out[116]=-1.0 -0.5 0.5 1.0
-1.0
-0.5
0.5
1.0
In three dimensions, use ParametricPlot3D
8 mathematica_quickstart_math101c.nb
In[117]:= ParametricPlot3D@8Cos@tD, Sin@tD, Sin@4 tD<, 8t, 0, 2 p<D
Out[117]=
-1.0
-0.5
0.0
0.5
1.0
-1.0
-0.5
0.0
0.5
1.0
-1.0
-0.5
0.0
0.5
1.0
Surfaces
To plot the surface f(x, y) = x3 + y3 + 4 sin HxyL, use the Plot3D command.
mathematica_quickstart_math101c.nb 9
In[118]:= Plot3DAx3 + y3 + 4 Sin@x yD, 8x, -2, 2<, 8y, -2, 2<E
Out[118]=
Implicit surfaces such as x2 + y2 + z2 = 4 are graphed using the ContourPlot3D command.
In[119]:= ContourPlot3DAx2 + y2 + z2 ã 4, 8x, -2, 2<, 8y, -2, 2<, 8z, -2, 2<E
Out[119]=
Parametric surfaces are graphed using the ParametricPlot3D command. For example, given
10 mathematica_quickstart_math101c.nb
x Hu, vL = cos u cos vy Hu, vL = cos u sin vz Hu, vL = u
In[120]:= ParametricPlot3D@8Cos@uD Cos@vD, Cos@uD Sin@vD, u<, 8u, 0, 3 p<, 8v, 0, 2 p<D
Out[120]=
To add nice level cures to any of the above, use the MeshFunctions option.
mathematica_quickstart_math101c.nb 11
In[121]:= Plot3DAx2 + y2, 8x, -2, 2<, 8y, -2, 2<,
MeshFunctions Ø 8Function@8x, y, z<, zD<E
Out[121]=
To add nice coloring to any of the above, use the ColorFunction option.
In[122]:= Plot3DAx2 + y2, 8x, -2, 2<, 8y, -2, 2<,MeshFunctions Ø 8Function@8x, y, z<, zD<,ColorFunction Ø Function@8x, y, z<, Hue@zDDE
Out[122]=
To eliminate the corners from sticking up, use the RegionFunction option.
12 mathematica_quickstart_math101c.nb
In[123]:= Plot3DAx2 + y2, 8x, -2, 2<, 8y, -2, 2<,MeshFunctions Ø 8Function@8x, y, z<, zD<,ColorFunction Ø Function@8x, y, z<, Hue@zDD,RegionFunction Ø Function@8x, y, z<, x^2 + y^2 < 4DE
Out[123]=
mathematica_quickstart_math101c.nb 13