Parametric Curve Graph

Graphing a parametric curve.

Complete Code

Download file: ParametricPlot.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'PGtikz.pl', 'PGcourse.pl');

Preamble

We use PGtikz.pl to generate the graph.

Context()->variables->add(t => 'Real');

$graph = createTikZImage();
$graph->tikzLibraries('arrows.meta');
$graph->BEGIN_TIKZ
\tikzset{>={Stealth[scale=1.5]}}
\filldraw[
    draw=LightBlue,
    fill=white,
    rounded corners=10pt,
    thick,use as bounding box
] (-3.5,-3.5) rectangle (3.5,3.5);
\draw[->] (-3.5,0) -- (3.5,0) node[above left,outer sep=3pt] {\(x\)};
\foreach \x in {-3,-2,-1,1,2,3} \draw (\x,0.15) -- (\x,-0.15) node [below] {\x};
\draw[->] (0,-3.5) -- (0,3.5) node[below right,outer sep=3pt] {\(y\)};
\foreach \y in {-3,-2,-1,1,2,3} \draw (0.15,\y) -- (-0.15,\y) node [left] {\y};
\draw[DarkBlue,very thick]
    plot [samples=250,domain=0:{2*pi},variable=\t]
    ({2*sin(2*\t r)},{2*sin(3*\t r)});
END_TIKZ

$x  = Compute('2sin(2t)');
$x0 = $x->eval(t => 'pi/3');
$y  = Compute('2sin(3t)');
$y0 = $y->eval(t => 'pi/3');

$m    = $y->D('t')->eval(t => 'pi/3') / $x->D('t')->eval(t => 'pi/3');
$line = Compute("$m*(x-$x0)+$y0");

Setup

The package PGtikz.pl is used to produce the curve. Basics of such a plot are described in Graphic Images, TikZ.

Most of the code for the plot produces the axes with the nice border. The parametric plotting routine is the last function call starting with \draw[DarkBlue, very thick] plot [....]. Note that

  • samples is the number of points to create the plot.
  • domain is the plotting domain.
  • variable is the variable for the plot. \x is default. We switch to
  • \t as is standard for parametric plots.
  • The plot is in the ({}, {}) where the first slot is the x function and the second is the y function. It is important that the functions are wrapped in {} and the variable has the backslash.
BEGIN_PGML
Find the tangent line to the parametric curve:
>> [``x(t) = [$x], \qquad y(t) = [$y]``] <<

when [`t=\pi/3`].  The graph of the curve is

>>[@ image($graph, width => 300) @]*<<

Tangent line in slope-intercept form

[`y=`][_____]{$line}
END_PGML

Statement

This is the problem statement in PGML.
BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.