Curves in the Plane

Alfred Gray

Computing Curvature of Plane Curves

Let us plot and compute the curvature of the figure eight curve
parametrized by

eight[t_]:={Sin[t],Sin[t]Cos[t]}

The figure eight curve is also called the lemniscate of Gerono.
To plot it use

ParametricPlot[eight[t]//Evaluate,{t,0,2Pi},
AspectRatio->Automatic];

The formula for the curvature of the figure eight curve is given by

kappa2[eight][t]

and plotted by

Plot[kappa2[eight][t]//Evaluate,
{t,0,2Pi}];

The semicolon at the end of a graphics command prevents Mathematica
from printing out "Graphics" after it does the graph. Mathematica
uses AspectRatio to set the height-to-width ratio in various plotting
commands.  For example, the default for AspectRatio  for
ParametricPlot and Plot is  about  0.618. This number is
the reciprocal of the so-called golden ratio, which in Mathematica is
GoldenRatio

?GoldenRatio

On the other hand, the option AspectRatio->Automatic will
insure that one unit in the vertical direction is the same as one unit in
the horizontal direction.

Computing Lengths of Plane Curves

Mathematica can be used to compute the length of a curve.  We define

length[a_,b_][alpha_]:= Integrate[
        Sqrt[alpha'[t].
        alpha'[t]//Factor//Simplify]
                //PowerExpand,{t,a,b}]

Mathematica's command PowerExpand does the following conversion:

PowerExpand[(a b)^s]

Sometimes this is correct mathematically, but sometimes it is not.

Thus  PowerExp should  be used with great care.  In the definition of
length the expression  alpha'[t].alpha'[t]  is nonnegative so
in this case  PowerExpand  will give correct results.  The command
Factor  factors polynomials.

For example the semicubical parabola can be defined in
  Mathematica   by

sc[t_]:={t^2,t^3}

To compute the length of this curve  with Mathematica we can use

length[a,b][sc]//Simplify

Numerical values of lengths can be found using Mathematica's
command N.  For example

length[0,1][sc]//N

Filling Curves

The command ParametricPlot carries out its work by drawing a
large number of very short lines in such a way that the resulting picture
is indistinguishable from the actual curve to the naked eye.  This fact is
illustrated in the following miniprogram filledcurve, which has the same
syntax as ParametricPlot.  Instead of drawing a closed curve
the command  filledcurve will fill it in with a desired gray level or
color.

filledcurve[curve_,{u_,u0_,u1_},opts___]:=
  Module[{plottmp,grtmp},
        plottmp = ParametricPlot[
        curve//Evaluate,{u,u0,u1},
              AspectRatio->Automatic,
                    DisplayFunction->Identity,
                    opts];
    grtmp=plottmp/.(Line[pts_]:> Polygon[pts]);
           Show[grtmp,
       DisplayFunction->$DisplayFunction]]

We illustrate the use of  filledcurve  
by filling the plot of the figure eight curve

filledcurve[eight[t]//Evaluate,
{t,0,2Pi},Axes->None,
AspectRatio->Automatic,
Prolog->GrayLevel[0.5]];

Examples of Curves in R2

In this section we give several examples of curves in R2.  In addition
to showing how to define and plot each curve using Mathematica,
 we also graph its curvature, when appropriate.

Circles

A circle of radius a with center (0,0) is usually described by the equation

x^2+y^2=a^2

This is the nonparametric or implicit form of the circle. The simplest
parametrization of the circle is

t-->{Cos[t],Sin[t]}

Another parametrization is

t-->{Cos[2t],Sin[2t]}

Either of these parametrizations will trace out a circle.
However, let us use a standard definition of a
parametrization of a circle of radius a, namely,

circle[a_][t_]:={a Cos[t],a Sin[t]}

To plot a circle of radius 2 with center at the origin we use

ParametricPlot[circle[2][t]//Evaluate,
{t,0,2Pi},
AspectRatio->Automatic];

Since the curvature of a circle is easily seen to be constant,
it is unnecessary to graph the curvature in this simple case.

kappa2[circle[a]][t]//PowerExpand

Let us make two remarks on how  Mathematica  handles circles.

Although we have explained how to define and graph a circle
centered at the origin, it is easy to plot one or more circles
with centers at other points.  Here is an example of
a plot  of two circles centered at  (1,2)  and  (2,0):

ParametricPlot[Evaluate[
{circle[2][t]+{1,2},
circle[3][t]+{2,0}}],
{t,0,2Pi},
AspectRatio->Automatic];

Mathematica has an internal command Circle for drawing circles.
We have defined  circle[a] as a function so that we can perform
on it the standard operations of calculus such as differentiation.

Ellipses

Perhaps the next simplest curves after the circle are the ellipses.
The nonparametric form of the ellipse centered at the origin
with axes of lengths a and b is

(x/a)^2+(y/b)^2=1

and the standard parametrization is

ellipse[a_,b_][t_]:={a Cos[t],b Sin[t]}

For example, let us compute the curvature of the ellipse
                ellipse[a,b].

kappa2[ellipse[a,b]][t]

The ellipse ellipse[2,1] is drawn with the command

ParametricPlot[
ellipse[2,1][t]//Evaluate,{t,0,2Pi},
AspectRatio->Automatic];

and the graph of the curvature of the ellipse is drawn with the command

Plot[kappa2[ellipse[2,1]][t]//Evaluate,
{t,0,2Pi}];

The traditional definition of the ellipse is the locus of points such
that the sum of the distances from two fixed points  F1 and  F2  is
constant.  The points F1 and F2 are called the foci of the ellipse.
In the case of ellipse[a,b] with  a>b the foci are (c,0),
where c is plus or minus the squareroot of a^2-b^2.

Show[ParametricPlot[
Evaluate[ellipse[1.5,1][t]],{t,0,2Pi},
Axes->None,
DisplayFunction->Identity],
Graphics[Thickness[.008],
Line[{{Sqrt[1.5^2-1],0},ellipse[1.5,1][Pi/6],
    {-Sqrt[1.5^2-1],0}}],
Line[{{Sqrt[1.5^2-1],0},ellipse[1.5,1][2Pi/3],
    {-Sqrt[1.5^2-1],0}}],
Text[FontForm[
    "F2",{"Helvetica-Bold",12}],
    {Sqrt[1.5^2-1],-.2}],
Text[FontForm[
    "F1",{"Helvetica-Bold",12}],
    {-Sqrt[1.5^2-1],-.2}],
Text[FontForm[
    "P",{"Helvetica-Bold",12}],
     ellipse[1.5,1][2Pi/3]+{0,.1}],
Text[FontForm[
    "P",{"Helvetica-Bold",12}],
    ellipse[1.5,1][Pi/6]+{.13,0}],
PointSize[.03],Point[{Sqrt[1.5^2-1],0}],
Point[ellipse[1.5,1][2Pi/3]],
Point[{-Sqrt[1.5^2-1],0}],Point[ellipse[1.5,1][Pi/6]],
DisplayFunction->Identity],
AspectRatio->Automatic,
PlotRange->All,
DisplayFunction->$DisplayFunction];

Logarithmic Spirals

One of the simplest spirals is the  logarithmic spiral  parametrized by

logspiral[a_,b_][t_]:=
       a{E^(b t)Cos[t],E^(b t)Sin[t]}

A small value of b makes the curve spiral more tightly.  Here is how
  to draw the logarithmic spiral when  b = 0.08.

ParametricPlot[
logspiral[1,.08][t]//Evaluate,
{t,0,12Pi},
AspectRatio->Automatic,
Ticks->None,PlotPoints->50];

The option Ticks->None takes out al the ticks along the axes, and
the option PlotPoints->50 plots the curve more accurately
than Mathematica's default (which is PlotPoints->25).

The command to  graph the curvature of a logarithmic spiral is

Plot[kappa2[
logspiral[1,.08]][t]//Evaluate,
{t,0,12Pi}];

Also, Mathematica tells us the formula for the curvature:

PowerExpand[Simplify[
        kappa2[logspiral[a,b]][t]]]

Plotting Piecewise Defined Curves

An equilateral triangle may be defined in Mathematica  using the
command  If,  which takes  3 arguments.  The first argument is a condition
(an inequality in our case).  The second argument specifies
what happens if the condition is true, and the third argument
whose definition requires several conditions, we can nest If
several times.  The definition of an equilateral triangle in Mathematica
is thus:

triangle[t_]:=If[t<1,t{1,0},
   If[t<2,{1,0}+(t-1){-1/2,Sqrt[3]/2},
    {1/2,Sqrt[3]/2}+(t-2){-1/2,-Sqrt[3]/2}]]

ParametricPlot[
triangle[t]//Evaluate,
{t,0,3},
AspectRatio->Automatic];

The disadvantage of this method of definition is that Mathematica  will not
take derivatives of functions defined by If without
further programming.  However, it is sometimes possible to define
piecewise linear functions using the fact that  x ->|x|   can be represented
in Mathematica  as x ->Öx2 .  For example, a diamond shape curve
can be defined by

diamond[a_][t_]:=
  {a Cos[t]Sqrt[Cos[t]^2],
     a Sin[t] Sqrt[Sin[t]^2]}

ParametricPlot[
diamond[2][t]
//Evaluate,{t,0,2Pi},
AspectRatio->Automatic];

Exercises

Parabolas

The parabola parabola[a,b] is defined by

parabola[a_][t_]:={2 a t,a t^2}

Find the formula for the curvature of a parabola.
Plot several parabolas as one graph and their curvatures as another graph.

Simplify[
kappa2[parabola[a]][t]]//PowerExpand

ParametricPlot[
Evaluate[{parabola[2][t],
parabola[1][t],
parabola[0.5][t],
parabola[-2.5][t],
parabola[-1.5][t],
parabola[-0.7][t]}],
{t,-2,2},
AspectRatio->Automatic,
PlotRange->{Automatic,{-2.2,2.2}}];

Plot[Evaluate[
{kappa2[parabola[2]][t],
kappa2[parabola[1]][t],
kappa2[parabola[0.5]][t],
kappa2[parabola[-2.5]][t],
kappa2[parabola[-1.5]][t],
kappa2[parabola[-0.7]][t]}],
{t,-2,2},PlotRange->All];

Hyperbolas

The hyperbola  hyperbola[a,b] is defined by

hyperbola[a_,b_][t_]:={a Cosh[t],b Sinh[t]}

Find the formula for the curvature of a hyperbola.
Plot several hyperbolas as one graph and their curvatures as another graph.

kappa2[hyperbola[a,b]][t]

ParametricPlot[
{hyperbola[2,1][t],hyperbola[1,1][t],
hyperbola[0.5,1][t],hyperbola[-2,1][t],
hyperbola[-1,1][t],
hyperbola[-0.5,1][t]}//Evaluate,
{t,-2,2},PlotRange->All];

Plot[
{kappa2[hyperbola[2,1]][t],
kappa2[hyperbola[1,1]][t],
kappa2[hyperbola[0.5,1]][t],
kappa2[hyperbola[-2,1]][t],
kappa2[hyperbola[-1,1]][t],
kappa2[hyperbola[-0.5,1]][t]}//Evaluate,
{t,-2,2},PlotRange->All];

Catenaries

The catenary is the curve formed by a perfectly flexible
inextensible chain of uniform density hanging from two supports.
It is given by the equation

x = c Cosh[y/c]

or parametrically,

catenary[c_][t_]:={c Cosh[t/c],t}

Find the formulas for the arc length and curvature of catenary[c]
and plot several catenaries and their curvatures.

PowerExpand[Simplify[
    kappa2[catenary[c]][t] /.
        1+Sinh[t/c]^2->Cosh[t/c]^2]]

ParametricPlot[{
catenary[0.5][t],
catenary[1][t],
catenary[2][t]}//Evaluate,
{t,-2,2},
AspectRatio->Automatic];

Plot[
    {kappa2[catenary[0.5]][t],
         kappa2[catenary[1]][t],
              kappa2[catenary[2]][t]}
              //Evaluate,
                  {t,-2,2},
                 AspectRatio->Automatic];

Astroids

The astroid  astroid[n,a,b] is defined by

astroid[n_,a_,b_][t_]:=
        {a Cos[t]^n,b Sin[t]^n}

Plot astroid[3,1,1] and its curvature.

ParametricPlot[
astroid[3,1,1][t]
//Evaluate,{t,0,2Pi},
AspectRatio->Automatic];

It takes Mathematica a long time to find the formula for the curvature
of  astroid[n,a,b].

kappa2[astroid[n,a,b]][t]//PowerExpand

To avoid recomputation, we define the result as a function, that is

kappa2[astroid[n_,a_,b_]][_t]:=
    (a*b*(2 - n)*n^2*Cos[t]^(-1 + n)*
    Sin[t]^(-1 + n))/
  (a^2*n^2*Cos[t]^(-2 + 2*n)*Sin[t]^2 + 
  b^2*n^2*Cos[t]^2*
  Sin[t]^(-2 + 2*n))^(3/2)

In particular,

kappa2[astroid[3,1,1]][t]//PowerExpand

Plot[kappa2[astroid[3,1,1]][t]//Evaluate,
{t,0,2Pi}];

Generalized diamonds

The (generalized) diamond diamond[n,a,b]is defined by

diamond[n_,a_,b_][t_]:=
        {a Cos[t]^(n-1)Sqrt[Cos[t]^2],
             b Sin[t]^(n-1)Sqrt[Sin[t]^2]}

We plot  diamond[4,1,1]; other values of  n,a,b result in
more complicated shapes.

ParametricPlot[
diamond[4,1,1][t]
//Evaluate,{t,0,2Pi},
AspectRatio->Automatic];

Initialization

J[{p1_,p2_}]:={-p2,p1}

kappa2[alpha_][t_]:=
        Simplify[alpha''[t].J[alpha'[t]]]/
        Simplify[alpha'[t].alpha'[t]]^(3/2)

length[a_,b_][alpha_]:= Integrate[
        Sqrt[alpha'[t].
        alpha'[t]//Factor//Simplify]
                //PowerExpand,{t,a,b}]