Parametric Curves, Polar Plots and 2D Graphics Fall 2016 In[213]:= Clear "Global`*"
2 2450notes2_fall2016.nb Parametric Equations In chapter 9, we introduced parametric equations so that we could easily work with curves which do not pass the verticle line test. To define such curves, we define the x and y coordinates as functions of a parameter: x = f (t) y = g (t) Often times, we think of the parameter as representing time, as in at time t, the particle is at the point (f(t), g(t)), as if the curve is the path of some particle. If we need to plot a parametric equation by hand, one technique we can use is to make a chart of parameter values and corresponding points, and then plot enough points to get a good idea of what the curve looks like. Conveniently, we can also use Mathematica to plot a parametric curve: In[214]:= ParametricPlot 2 Cos[t], 2 Sin[t], {t, 0, 2 π}, AxesLabel Style "x", Medium, Style "y", Medium, PlotStyle Thick, Purple y 2 1 Out[214]= -2-1 1 2 x -1-2 In[215]:= In[216]:= Clear[x] The first argument is a list containing the parametric equations inside curly brackets. The second argument is a list containing the parameter and the range of parameter values over which we want to plot the curve. The styling options go after those two required arguments, and have just the same format as with the regular Plot function. Suppose that we ve already defined a parametric curve:
2450notes2_fall2016.nb 3 In[217]:= r[t_] = t + 2 Sin[2 t], t + 2 Cos[5 t] ; In[218]:= r[0] Out[218]= {0, 2} We can easily plot this without re-typing it: In[219]:= ParametricPlot r[t], {t, 0, 2 π}, AxesLabel Style "x", Medium, Style "y", Medium, PlotStyle Thick, Orange y 8 6 Out[219]= 4 2 1 2 3 4 5 6 x In[220]:=
4 2450notes2_fall2016.nb Polar Coordinates In chapter 9, we also introduced polar coordinates as an alternative way to describe points in the plane. In polar coordinates, we describe points via their angle with the positive x- axis, and the distance from the origin (don t worry about the code for now, just look at the picture): In[221]:= point = Graphics Black, Disk[{1, 1},.05] ; liner = Graphics Red, Thick, Line[{{0, 0}, {1, 1}}] ; r = Graphics Text Style "r", Large, Red, {.5,.6} ; linex = Graphics Purple, Thick, Line[{{0, 0}, {1, 0}}] ; x = Graphics Text Style "x", Large, Purple, {.5, -.1} ; liney = Graphics Orange, Thick, Line[{{1, 0}, {1, 1}}] ; y = Graphics Text Style["y", Large, Orange], {1.1,.5} ; arc = Graphics Black, Thick, Circle[{0, 0},.2, {0, π / 4}] ; theta = Graphics Text Style["θ", Large], {.3,.1} ; Show liner, r, linex, x, liney, y, arc, theta, point, Axes True, AxesStyle Gray, AxesLabel Style "x", Medium, Gray, Style "y", Medium, Gray y 1.0 0.8 Out[230]= 0.6 r y 0.4 0.2 θ 0.2 0.4 0.6 0.8 1.0 x x From this picture, it should be clear that we can switch back and forth between the two coordinate systems in the following manner: x = r cos (θ) r 2 = x 2 + y 2 y = r sin (θ) tan (θ) = y x
2450notes2_fall2016.nb 5 Polar Curves We can use polar coordinates to define curves, just like we use rectangular coordinates. Usually, when we need to plot a polar curve by hand, we make a table consisting of the radius that results at various angles. Fortunately, we can also use Mathematica to plot polar curves. Below are some examples of common polar curves: In[231]:= PolarPlot 3, {θ, 0, 2 π}, PlotStyle Thick, Red, PlotLabel Style "r = 3", Red, Large r = 3 3 2 1 Out[231]= -3-2 -1 1 2 3-1 -2-3
6 2450notes2_fall2016.nb In[232]:= PolarPlot 3 (1 - Cos[θ]), {θ, 0, 2 π}, PlotStyle Thick, Orange, PlotLabel Style["r = 3(1-Cos[θ])", Orange, Large] r = 3(1-Cos[θ]) 4 2 Out[232]= -6-5 -4-3 -2-1 -2-4
2450notes2_fall2016.nb 7 In[233]:= PolarPlot 2 Cos[4 θ], {θ, 0, 2 π}, PlotStyle Thick, Green, PlotLabel Style["r = 2Cos[4θ]", Green, Large] r = 2Cos[4θ] 2 1 Out[233]= -2-1 1 2-1 -2
8 2450notes2_fall2016.nb In[234]:= PolarPlot 3 Sin[θ], θ, 0, 2 * Pi 3, PlotStyle Thick, Blue, PlotLabel Style "r = 3Sin[θ]", Blue, Large r = 3Sin[θ] 3.0 2.5 2.0 Out[234]= 1.5 1.0 0.5-1.0-0.5 0.5 1.0 1.5
2450notes2_fall2016.nb 9 In[235]:= PolarPlot 3 Cos[θ], {θ, 0, π}, PlotStyle Thick, Purple, PlotLabel Style "r = 3Cos[θ]", Purple, Large 1.5 r = 3Cos[θ] 1.0 0.5 Out[235]= 0.5 1.0 1.5 2.0 2.5 3.0-0.5-1.0-1.5
10 2450notes2_fall2016.nb In[236]:= PolarPlot 3 Cos[θ] + 2, {θ, 0, 2 π}, PlotStyle Thick, Pink, PlotLabel Style "r = 3Cos[θ]+2", Pink, Large 3 r = 3Cos[θ]+2 2 1 Out[236]= 1 2 3 4 5-1 -2-3
2450notes2_fall2016.nb 11 Areas and Lengths in Polar Coordinates Area If we have a polar curve defined by an equation of the form r = f(θ) (all of the previous examples were of this form), then we can calculate the area enclosed by the curve from θ = a to θ = b as A = 1 2 ab (f[θ]) 2 dθ Arc Length The arc length of a polar curve between angles θ = a and θ = b is given by L = a b (f[θ]) 2 + (f'[θ]) 2 dθ
12 2450notes2_fall2016.nb 2D Graphics In addition to all of the styling options for 2D plots, we can also add graphics objects to our plots. This includes things like text, shapes (circles, disks, squares, triangles, etc.), lines, arrows and more. Including these types of objects can help us point out important features of our plot and convey information quickly. Let s look at an example:
2450notes2_fall2016.nb 13 In[237]:= Clear[x] f[x_] = 1 10 x x + 2 3 x - 2 3 ; (* define the function so that we can use it later *) func = Plot f[x], {x, -5, 5}, PlotStyle Thick, Black, AxesLabel Style["x", Large], Style "f[x] = x(x+2 3 )(x-2 3 )", Large, AspectRatio Automatic ; (* we want to give each graphic a name, and then show them all together once we've created everything... make sure to supress intermediary output with a semi-colon *) max = Graphics Red, Disk -2, f[-2],.2 ; (* styling attributes go first, then we tell it what the graphics object is *) maxl = Graphics Red, Text Style "local max", Large, -2, f[-2] +.5 ; min = Graphics Purple, Disk 2, f[2],.2 ; minl = Graphics Purple, Text Style "local min", Large, 2, f[2] -.5 ; infl = Graphics Green, Disk 0, f[0],.2 ; infll = Graphics Green, Text Style "inflection point", Large, 1.5, f[0] +.5 ; Show max, func, maxl, min, minl, infl, infll (* Mathematica will take the style and structure of the axes from the first graphic in the list, so choose it well. It' s best to include all of the graphics inside curly brackets; if some of the objects appear to run outside of the plot, we can then include the phrase "PlotRange->All" after the last curly bracket *) local max Out[246]= inflection point local min
14 2450notes2_fall2016.nb Another Graphics Example Suppose that we want to plot the parametric curve defined by the position vector r(t) = t 2 i + 1 5 t3-1 j t [-2, 2] and then make an arrow that is tangent to the curve at the point corresponding to t = 1. First we need to look up the arrow function to see how that works, so let s look that up in the documentation center... Now, we know the initial point (tail) of the arrow will be given by r(t = 1), but we need to determine the final point (tip) of the arrow. It turns out that the velocity of the curve, v(t) = r' (t), is always a vector lying tangent to the curve; this in fact is the vector we are trying to represent in the plot. To get the final point for our arrow, we can use vector addition... so it will be given by r(t = 1) + v(t = 1): In[247]:= Clear[r] r[t_] = t 2, 1 5 t3-1 ; path = ParametricPlot r[t], {t, -2, 2}, PlotStyle Thick, Black, AxesLabel Style["x", Large], Style["y", Large] ; vel = Graphics Blue, Arrow[{r[1], r[1] +.8 * r'[1]}] ; (* to modify the length of the arrow to make the plot look nice, multiply v by a scalar *) Show path, vel 1.5 y 1.0 0.5 Out[251]= 1 2 3 4 x -0.5-1.0-1.5 In[252]:=