Parametric equations: parametric curve in space
Download file: VectorParametricDerivative.pg
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'parserVectorUtils.pl', 'PGcourse.pl');
Preamble
Although not necessary for the code demonstrated in this example, you might want to load parserVectorUtils.pl. It provides methods that are useful for vector problems.
Context('Vector2D');
Context()->variables->are(t => 'Real');
Context()->variables->set(t => { limits => [ 0, 5 ] });
Context()->flags->set(ijk => 0, ijkAnyDimension => 1);
$ans = Vector('<2t, 4t^2>')->cmp(
checker => sub {
my ($correct, $student, $ansHash) = @_;
return 0 unless $student->length == $correct->length;
my $xstu = $student . i;
my $ystu = $student . j;
return
$ystu == $xstu**2
&& $xstu->D('t') == Formula('2')
&& $ystu->D('t') == Formula('8t') ? 1 : 0;
}
);
Setup
The context flag ijk => 0 disables the display of
correct answer vectors using ijk form. Note that it does
not prevent students from using ijk form in answers, and if
the student enters an answer in that form it will also still be
displayed in that form. Furthermore, the vector constants i
and j are still available in the context for the problem
author to use (as is done in the checker in this example). The vector
constant k is also available in the 3 dimensional
Vector context.
Setting the context flag ijkAnyDimension => 1 means
that trailing zero vector entries are added or removed so that vector
dimensions match when vector comparisons are made. Although, this only
has any effect if ijk => 1, and is only here to
demonstrate the availability of the option.
Also note that the values of the flags described above are the default values for these flags. So there is no need to set the flags in this problem at all. This is only done here to demonstrate the flags and their meaning.
The custom answer checker checks that the student answer has the
correct dimension, satisfies the equation for the curve, and that
derivatives of the components of the student answer equal the
derivatives of the components of the correct answer. The dot product of
the student answer with the vectors i and j is
used to get the x and y components,
$xstu and $ystu respectively, of the student
answer. Then, the components are differentiated and compared to the
derivatives of the components of the correct answer.
BEGIN_PGML
Find a vector parametric function [`\vec{r}(t)`] for a bug that moves along the
parabola [`y = x^2`] with velocity [`\vec{v}(t) = \langle 2, 8t \rangle`] for
all [`t`].
[`\vec{r}(t) =`] [_]{$ans}{15}
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.