Vector-valued Parametric Line Segment (General)

A Vector-value parametric line segment with a general paramterization

Complete Code

Download file: VectorLineSegment1.pg

PG problem file

Explanation

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

Preamble

The parserParametricLine.pl macro provides the ParametricLine function which us used to check the answer. The parserMultiAnswer.pl macro is needed since the answers are interdependent.

Context('Vector');
Context()->variables->are(t => 'Real');

$P = Point(4, 0);
$Q = Point(0, 2);
$V = Vector(-4, 2);

$t    = Formula('t');
$line = Vector("$P + $t * $V");

$multians = MultiAnswer($line, Real(0), Real(1))->with(
    singleResult => 0,
    checker      => sub {
        my ($correct, $student, $ansHash) = @_;

        my ($linecor, $acor, $bcor) = @$correct;
        my ($linestu, $astu, $bstu) = @$student;

        if ((ParametricLine("$line") == $linestu)
            && ($linestu->eval(t => $astu) == $line->eval(t => 0))
            && ($linestu->eval(t => $bstu) == $line->eval(t => 1)))
        {
            return [ 1, 1, 1 ];

        } elsif ((ParametricLine("$line") == $linestu)
            && ($linestu->eval(t => $astu) == $line->eval(t => 0)))
        {
            return [ 1, 1, 0 ];

        } elsif ((ParametricLine("$line") == $linestu)
            && ($linestu->eval(t => $bstu) == $line->eval(t => 1)))
        {
            return [ 1, 0, 1 ];

        } elsif ((ParametricLine("$line") == $linestu)) {
            return [ 1, 0, 0 ];

        } else {
            return [ 0, 0, 0 ];
        }

    }
);

Setup

Create a MutiAnswer object that is used to evaluate the student’s vector equation at the starting and ending times provided by the student. For example, both of the student answers <4, 0> + t<-4, 2> for t between 0 and 1, and <4,0> + t<-2,1> for t between 0 and 2 will be marked correct.

BEGIN_PGML
Find a vector equation for the line segment from the point
[`P = [$P]`] to [`Q = [$Q]`] .

[`\vec{r}(t) =`] [__]{$multians}{15}

for [_]{$multians}{4} [` \leq t \leq `] [_]{$multians}{4}
END_PGML

Statement

Use $multians for each answer.

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.