Parametric Curve Graph (tikz)

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

The PGtikz.pl macro is used 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 = 100, 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 PGtikz.pl macro is used to produce the curve. The basics of such a plot are described in Graphic Images, TikZ.

The initial TikZ code produces the axes and the nice border. The plot of the parametric function is the last command starting with \draw[DarkBlue, very thick] plot [....]. The options for the plot command are as follows.

  • samples is the number of sample points used to create the plot.
  • domain is the plot domain.
  • variable is the variable for the plot. \x is default. \t is switched to as it is standard for parametric plots.
  • The function plotted is ({2 * sin(2 * \t r)}, {2 * sin(3 * \t r)}) where the x function is in the first set of braces, and the y function is in the second. It is important that the functions are wrapped in braces and the variable has the backslash.
BEGIN_PGML
Find the tangent line to the parametric curve

>> [``x(t) = [$x], \quad y(t) = [$y]``] <<

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

>>[!a Lissajous curve!]{$graph}{300}<<

Tangent line in slope-intercept form: [`y =`] [_____]{$line}
END_PGML

Statement

The alternate text provided in this example is not sufficient. I don’t know how one would describe a Lissajous curve to someone who can not see it. Perhaps seek assistance from an expert in assistive technologies to find a better description.

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.