Parametric curves on Mathematica
D. McClendon

Defining functions; basic operations

Recall that to define a function ℝ -> ℝ, we use a command like this:

f[x_] = x - Sin[2x]

To define a function ℝ -> (ℝ^m), use similar syntax.  The difference is that the coordinates of the output should be separated by commas and surrounded by braces.  For example, to define f(t) = (cos t, (t^4), 2 sin 3t), execute this:

f[t_] = {Cos[t], t^4, 2 Sin[3t]}

As with single-variable functions, we need the underscore after the t, which tells Mathematica that you are defining f to be a function of t (not a number).

Once a function like this is defined, expressions involving the function can be evaluated using usual Mathematica syntax.  For example, if f is as above, then we would evaluate f(3) × f’(t-1) by this command:

Cross[f[3], f'[t-1]]

We can find indefinite or definite integrals term-by-term, with the same syntax as used with single-variable functions (remember, though, that Mathematica forgets the “+C” on indefinite integrals):

Integrate[f[t], t]

Use the Table command to get a table of values for such a function:

Table[{t, f[t]}, {t, 0, 6, 2}] // TableForm

For example, the above table indicates that f(0) = (1,0,0), etc.

ParametricPlot:  paths in (ℝ^2)

To produce a graph of the image of a function f : ℝ -> (ℝ^m), we use one of two commands, depending on whether m = 2 or 3.  (If m > 3, we can’t get a good picture of the image of f.)

When m = 2, (i.e. the image of the function is a path in the plane), use the ParametricPlot command.  To sketch the image of f(t) = (3 cos 2t, 2 sin 3t), here is the appropriate syntax:

f[t_] = {3 Cos[2t], 2 Sin[3t]};
ParametricPlot[f[t], {t, 0, 2 Pi}]

The 0 and 2 Pi are the minimum and maximum values of t for which Mathematica plots the image.  To get a good picture, it is often necessary to adjust these values so that you see more or less of the graph (but if this range is too large, your computer may have a hard time executing the command for lack of memory).

It is not necessary to assign the function a name (like "f") to plot its image.  The following command plots a graph just as well (notice that the components of the function are inside braces):

ParametricPlot[{4 Cos[t] + Sin[2t], 2 Cos[3t]}, {t, -3, 3}]

If you used Plot instead of ParametricPlot, Mathematica would think you were asking it to graph two functions ℝ -> ℝ, and produce the graphs of y = 4 cos t + sin 2t and y = 2 cos 3t:

Plot[{4 Cos[t] + Sin[2t], 2 Cos[3t]}, {t, -3, 3}]

The ParametricPlot command can be modified in a variety of ways:

Plotting multiple paths on the same axis:

Replace the single function with a list of functions enclosed with braces.  Notice that each function is ostensibly a list of component functions, surrounded by their own braces.

ParametricPlot[{{1 + Cos[t], Sin[2t]}, {2 Cos[3t] + 1, Sin[t] + Cos[t]}}, {t, 0, 2Pi}]

Specifying a range of x- or y-values:

If you want both x- and y- axes to begin and end at the same numbers, after the {t, tmin, tmax} part of the Plot command, add the phrase PlotRange -> {min, max}.

ParametricPlot[{3Cos[t], Sin[t] + Cos[t]}, {t, -6, 6}, 
PlotRange -> {-4,4}]

If you want different ranges for the x- and y- axes, use PlotRange -> {{xmin, xmax}, {ymin, ymax}}.

ParametricPlot[{3Cos[t], Sin[t] + Cos[t]}, {t, -6, 6}, 
PlotRange ->{ {-4,6}, {-2,3}}]

Making the scales on the x-axis and y-axis line up:

As with Plot, use the AspectRatio -> Automatic command to make the x- and y- axes have the same scale:

ParametricPlot[{3Cos[t], Sin[t] + Cos[t]}, {t, -6, 6}, 
PlotRange ->{ {-4,6}, {-2,3}},
AspectRatio -> Automatic]

Changing the tick-marks on the axes:

Use the Ticks command, exactly as with the Plot command:

ParametricPlot[{3Cos[2t], Sin[t] + Cos[3t]}, {t, -2 Pi, 2 Pi}, 
PlotRange ->{ {-4,6}, {-2,3}},
AspectRatio -> Automatic,
Ticks -> {{-3,0,4},{-2,-1, 0,2}}]

Changing the aesthetic appearance of the graphs:

Use the PlotStyle command, exactly as with the Plot command:

ParametricPlot[{{3 Cos[t], 3 Sin[t]},{3Cos[2t], Sin[t] + Cos[3t]}}, {t, -2 Pi, 2 Pi}, 
PlotStyle -> {{Thick, Red}, {Blue, Dashed}}]

ParametricPlot3D:  paths in (ℝ^3)

When m = 3, (i.e. the image of the function is a path in 3-D space), use the ParametricPlot3D command.  To sketch the image of f(t) = (3 cos 2t, 2 sin 3t, t/4), here is the appropriate syntax:

f[t_] = {3 Cos[2t], 2 Sin[3t], t/4};
ParametricPlot3D[f[t], {t, 0, 2 Pi}]

As before, the 0 and 2 Pi are the minimum and maximum values of t for which Mathematica plots the image; you may have to adjust these  to get a good picture.

The ParametricPlot3D command can be modified in a variety of ways:

How to display which axis is which

Note that in the picture above, it is hard to tell which direction is x, which is y and which is z.  To fix this, I suggest inserting an AxesLabel command after the {t, tmin, tmax} as follows:

f[t_] = {3 Cos[2t], 2 Sin[3t], t/4};
ParametricPlot3D[f[t], {t, 0, 2 Pi},
AxesLabel -> {"x","y","z"}]

This shows you which direction is x, which is y and which is z.  If you need bigger (easier to read letters), try this:

f[t_] = {3 Cos[2t], 2 Sin[3t], t/4};
ParametricPlot3D[f[t], {t, 0, 2 Pi},
AxesLabel -> {"x","y","z"},
AxesStyle -> Larger]

Specifying a range of x- or y-values:

If you want the x-, y- and z- axes to begin and end at the same numbers, after the {t, tmin, tmax} part of the Plot command, add the phrase PlotRange -> {min, max}.

f[t_] = {3 Cos[2t], 2 Sin[3t], t/4};
ParametricPlot3D[f[t], {t, 0, 2 Pi},
AxesLabel -> {"x","y","z"},
AxesStyle -> Larger,
PlotRange ->{-5,5}]

If you want different ranges for the x-, y- and z- axes, use PlotRange -> {{xmin, xmax}, {ymin, ymax}, {zmin, zmax}}.

f[t_] = {3 Cos[2t], 2 Sin[3t], t/4};
ParametricPlot3D[f[t], {t, 0, 2 Pi},
AxesLabel -> {"x","y","z"},
AxesStyle -> Larger, 
PlotRange -> {{-4,3},{-3,6},{-2,2}}]

Getting rid of the box

If you don’t like the box around the 3D picture Mathematica produces, insert Boxed -> False:

f[t_] = {3 Cos[2t], 2 Sin[3t], t/4};
ParametricPlot3D[f[t], {t, 0, 2 Pi},
AxesLabel -> {"x","y","z"},
AxesStyle -> Larger, 
Boxed -> False]

Making the scales on the axes line up:

Use BoxRatios -> Automatic command to make the x-, y- and z- axes have the same scale:

f[t_] = {3 Cos[2t], 2 Sin[3t], t/4};
ParametricPlot3D[f[t], {t, 0, 2 Pi},
AxesLabel -> {"x","y","z"},
AxesStyle -> Larger, 
BoxRatios -> Automatic]

BoxRatios -> {a,b,c} makes the length of the boxes shown on your screen have the ratios a:b:c, as shown here (notice the x-direction is three times the y-direction, and the z-direction is twice the y-direction in length):

f[t_] = {3 Cos[2t], 2 Sin[3t], t/4};
ParametricPlot3D[f[t], {t, 0, 2 Pi},
AxesLabel -> {"x","y","z"},
AxesStyle -> Larger, 
BoxRatios -> {3,1,2}]

Multiple graphs on the same picture:

This is the same ideas as with ParametricPlot (surround the list of functions you want to plot with a set of braces):

f[t_] = {3 Cos[2t], 2 Sin[3t], t/4};
g[t_] = {Cos[t], t, Sin[2t]};
ParametricPlot3D[{f[t],g[t]}, {t, 0, 2 Pi},
AxesLabel -> {"x","y","z"},
AxesStyle -> Larger]

Changing the tick-marks on the axes:

Use the Ticks command, exactly as with the Plot command.

Changing the aesthetic appearance of the graphs:

Use the PlotStyle command, exactly as with the Plot command.

f[t_] = {3 Cos[2t], 2 Sin[3t], t/4};
g[t_] = {Cos[t], t, Sin[2t]};
ParametricPlot3D[{f[t],g[t]}, {t, 0, 2 Pi},
AxesLabel -> {"x","y","z"},
AxesStyle -> Larger,
PlotStyle -> {{Red, Thick}, {Blue, Dashed}}]