Vector Calculus: Basic vector operations
Download file: VectorOperations.pg
DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'parserVectorUtils.pl', 'PGcourse.pl');
Preamble
We load parserVectorUtils.pl
to have access to functions on vectors like norm and unit.
Context('Vector'); $U = non_zero_vector3D(-9, 9, 1); $V = non_zero_vector3D(-9, 9, 1); # value works only for vectors of constants @Uarray = $U->value; $Ucomp2 = $Uarray[1]; $UdotV = $U . $V; $UcrossV = $U x $V; $Vlength = norm($V); $Vunit = unit($V); # Prevent students from entering the dot and cross products, # and the vector functions norm and unit. Context()->operators->undefine('.', "><"); Context()->functions->disable('Vector'); BEGIN_PGML Suppose [` \vec{u} = [$U] `] and [` \vec{v} = [$V] `]. a. The second component of [` \vec{u} `] is [___________]{$Ucomp2} b. [` \vec{u} \cdot \vec{v} = `] [___________]{$UdotV} c. [` \vec{u} \times \vec{v} = `] [________________]{$UcrossV} d. [` \left\| \vec{v} \right\| = `] [___________]{$Vlength} e. Enter a unit vector in the direction of [` \vec{v} `]. [______________]{$Vunit} f. Enter a vector parallel to [` \vec{v} `]. [________________]{$V->cmp( parallel=>1 )} g. Enter a vector in the same direction as [` \vec{v} `]. [__________]{$V->cmp( parallel=>1, sameDirection=>1 )} END_PGML
Setup
We use non_zero_vector3D(low,high,increment)
to randomly generate some vectors. Calling $U->value
returns a (Perl) array of numbers. (Note that ->value
does not work on a vector whose components are non-constant formulas.) MathObjects defines the operators .
and x
to be the dot product and cross product when they occur between two vectors (that is, these operations are overloaded). The functions norm and unit calculate the length of a vector and a unit vector in the same direction. We undefine the dot and cross product as well as the functions norm and unit so that students cannot enter them in their answers.
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.