Parametric equations: parametric curve in space
Download file: Spacecurve.pg
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'parserMultiAnswer.pl', 'PGcourse.pl');
$showPartialCorrectAnswers = 0;
Preamble
These standard macros need to be loaded.Context()->variables->are(t => 'Real');
Context()->variables->set(t => { limits => [ 0, 10 ] });
$a = random(-5, -2);
$x = Formula("$a * t^2");
$y = Formula('0');
$z = Formula('t');
$multians = MultiAnswer($x, $y, $z)->with(
singleResult => 1,
checker => sub {
my ($correct, $student, $self) = @_;
my ($xstu, $ystu, $zstu) = @$student;
return 0 unless $xstu->isFormula;
return $xstu == $a * $zstu**2 && $ystu == 0 ? 1 : 0;
}
);
Setup
The parserMultiAnswer.pl is used to check the answers together since they are interdependent.
The option singleResult => 1 is used since it doesn’t
make sense to say that x(t) is correct but
z(t) is incorrect since they depend on one another.
The checker first ensures that the student has not given a bogus
constant solution such as x = y = z = 0 by requiring the
x-coordinate to be a non-constant formula via
return 0 unless $xstu->isFormula;Then, it checks that the student answers satisfy the curve equation.
BEGIN_PGML
Find a parametrization of the curve [`x = [$a]z^2`] in the [`xz`]-plane. Use
[`t`] for the parameter.
[`x(t) =`] [_]{$multians}{15}
[`y(t) =`] [_]{$multians}{15}
[`z(t) =`] [_]{$multians}{15}
END_PGML
Statement
Notice that $multians is used for the answer for all
answer rules.
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.