Two-D Vector Field

Vector Calculus: graph of a 2D vector field

Complete Code

Download file: VectorFieldGraph2D.pg

POD for Macro Files

PG problem file

Explanation

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

Preamble

The macro PGtikz.pl is used to produced the vector field graph.

$graph = createTikZImage();
$graph->texPackages(['ifthen']);
$graph->BEGIN_TIKZ
\filldraw[
    draw = LightBlue,
    fill = white,
    rounded corners = 10pt,
    thick,
    use as bounding box
] (-6, -6) rectangle (6, 6);
\draw[dotted] (-5, -5) grid (5, 5);
\draw[->] (-5, 0) -- (5.25, 0) node[above right] {\(x\)};
\foreach \x in {-5, ..., -1, 1, 2, ..., 5} \draw (\x, -5) node[below] {\x};
\draw[->] (0, -5) -- (0, 5.25) node[above right] {\(y\)};
\foreach \y in {-5, ..., -1, 1, 2, ..., 5} \draw (-5, \y) node[left] {\y};
\foreach \x in {-4, ..., 4} {
    \foreach \y in {-4, ..., 4} {
        \ifthenelse{\equal{\x}{0} \AND \equal{\y}{0}}{}{
            \draw[thick, blue, ->]
                (\x, \y) --
                (
                    {\x + \x / (\x * \x + \y * \y)},
                    {\y + \y / (\x * \x + \y * \y)}
                );
        }
    }
}
END_TIKZ

Setup

The graph of the vector field is created. The vector field is <x / (x^2 + y^2), y / (x^2 + y^2)> which is not defined at the origin. The ifthen package is loaded and the \ifthenelse command from that package used to skip the vector at the origin.

The vector is created using the \draw command.

BEGIN_PGML
This is a velocity vector field for an explosion at the origin
that decreases in speed the farther the distance is from the origin.

[``\vec{v} =  \left< \frac{x}{x^2+y^2}, \frac{y}{x^2+y^2} \right>``]

>>[!a vector field!]{$graph}{400}<<
END_PGML

Statement

Insert the graph into the problem text using the PGML image syntax.

Note that the alternate text given here is not sufficient to appropriately describe the image for screen reader users.

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.