VectorParametric2: Difference between revisions
(Created page with '<h2>Motion and Velocity with a Parametric Curve</h2> 300px|thumb|right|Click to enlarge <p style="background-color:#f9f9f9;border:black solid 1px;…') |
(add historical tag and give links to newer problems.) |
||
(4 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{historical}} | |||
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/VectorParametricDerivative.html a newer version of this problem]</p> | |||
<h2>Motion and Velocity with a Parametric Curve</h2> | <h2>Motion and Velocity with a Parametric Curve</h2> | ||
Line 5: | Line 9: | ||
This PG code shows how to construct a custom answer checker that extracts the component functions from the student's answer and makes some derivative calculations with them. | This PG code shows how to construct a custom answer checker that extracts the component functions from the student's answer and makes some derivative calculations with them. | ||
</p> | </p> | ||
* | * File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/VectorParametric2.pg FortLewis/Authoring/Templates/Parametric/VectorParametric2.pg] | ||
* | * PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/VectorParametric2_PGML.pg FortLewis/Authoring/Templates/Parametric/VectorParametric2_PGML.pg] | ||
<br clear="all" /> | <br clear="all" /> | ||
Line 67: | Line 71: | ||
<pre> | <pre> | ||
Context("Vector2D"); | Context("Vector2D"); | ||
#Context("Vector"); # for | #Context("Vector"); # for 3d vectors | ||
Context()->variables->are(t=>"Real"); | Context()->variables->are(t=>"Real"); | ||
Context()->variables->set(t=>{limits=>[0,5]}); | Context()->variables->set(t=>{limits=>[0,5]}); | ||
Context()->flags->set( ijk=>0 ); | Context()->flags->set( ijk=>0, ijkAnyDimension => 1 ); | ||
$answer = Vector("<2t,(2t)^2>"); | $answer = Vector("<2t,(2t)^2>"); | ||
Line 78: | Line 82: | ||
<p> | <p> | ||
<b>Setup:</b> | <b>Setup:</b> | ||
We choose not to display the answer using ijk notation. | We choose not to display the answer using ijk notation. Also, use <code>ijkAnyDimension => 1</code> to require a dimension match between i,j,k vectors and either the student or the correct answer when doing vector operations. | ||
</p> | </p> | ||
</td> | </td> | ||
Line 115: | Line 119: | ||
<pre> | <pre> | ||
$showPartialCorrectAnswers = 1; | $showPartialCorrectAnswers = 1; | ||
sub mycheck { | sub mycheck { | ||
my ($correct, $student, $ansHash) = @_; | my ($correct, $student, $ansHash) = @_; | ||
my | my $xstu = $student . Vector(1,0); | ||
my $ystu = $student . Vector(0,1); | |||
my $ystu = | |||
if ( ($xstu->D('t')==Formula("2")) && | if ( ($xstu->D('t')==Formula("2")) && | ||
($ystu->D('t')==Formula("8t")) ) | ($ystu->D('t')==Formula("8t")) ) | ||
Line 160: | Line 134: | ||
<p> | <p> | ||
<b>Answer Evaluation:</b> | <b>Answer Evaluation:</b> | ||
Use dot products of the student answer with the vectors <code>Vector(1,0)</code> and <code>Vector(0,1)</code> to get the components <code>$xstu</code> and <code>$ystu</code> of the student answer. Then, we can differentiate the components just like any MathObject formula. Notice that the argument to <code>cmp( checker => ~~&mycheck )</code> is our subroutine that is a custom answer checker. | |||
</p> | </p> | ||
</td> | </td> | ||
Line 172: | Line 146: | ||
Context()->texStrings; | Context()->texStrings; | ||
BEGIN_SOLUTION | BEGIN_SOLUTION | ||
Solution explanation goes here. | Solution explanation goes here. | ||
END_SOLUTION | END_SOLUTION | ||
Line 195: | Line 168: | ||
[[Category:Top]] | [[Category:Top]] | ||
[[Category: | [[Category:Sample Problems]] | ||
[[Category:Subject Area Templates]] |
Latest revision as of 11:52, 18 July 2023
This problem has been replaced with a newer version of this problem
Motion and Velocity with a Parametric Curve

This PG code shows how to construct a custom answer checker that extracts the component functions from the student's answer and makes some derivative calculations with them.
- File location in OPL: FortLewis/Authoring/Templates/Parametric/VectorParametric2.pg
- PGML location in OPL: FortLewis/Authoring/Templates/Parametric/VectorParametric2_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserVectorUtils.pl", "AnswerFormatHelp.pl", ); TEXT(beginproblem()); |
Initialization:
Although not necessary for the code below, we load |
Context("Vector2D"); #Context("Vector"); # for 3d vectors Context()->variables->are(t=>"Real"); Context()->variables->set(t=>{limits=>[0,5]}); Context()->flags->set( ijk=>0, ijkAnyDimension => 1 ); $answer = Vector("<2t,(2t)^2>"); |
Setup:
We choose not to display the answer using ijk notation. Also, use |
Context()->texStrings; BEGIN_TEXT 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 \). $BR $BR \( \vec{r}(t) = \) \{ ans_rule(20) \} \{ AnswerFormatHelp("vectors") \} END_TEXT Context()->normalStrings; |
Main Text: |
$showPartialCorrectAnswers = 1; sub mycheck { my ($correct, $student, $ansHash) = @_; my $xstu = $student . Vector(1,0); my $ystu = $student . Vector(0,1); if ( ($xstu->D('t')==Formula("2")) && ($ystu->D('t')==Formula("8t")) ) { return 1; } else { return 0; } } ANS( $answer->cmp( checker=>~~&mycheck ) ); |
Answer Evaluation:
Use dot products of the student answer with the vectors |
Context()->texStrings; BEGIN_SOLUTION Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |