Difference between revisions of "ParametricEquationAnswers"
(add historical tag and give links to newer problems.) |
|||
(5 intermediate revisions by 4 users 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/ParametricEquationAnswers.html a newer version of this problem]</p> |
||
+ | |||
<h2>Parametric Equations</h2> |
<h2>Parametric Equations</h2> |
||
Line 8: | Line 12: | ||
<p style="text-align:center;"> |
<p style="text-align:center;"> |
||
− | [[ |
+ | [[Problem Techniques|Problem Techniques Index]] |
</p> |
</p> |
||
Line 101: | Line 105: | ||
<b>Setup:</b> |
<b>Setup:</b> |
||
We use a <code>MultiAnswer()</code> answer checker that will verify that the students answers satisfy the equation for the circle and have the required starting and ending points. This answer checker will allow students to enter any correct parametrization. For example, both <code>x = cos(t), y = sin(t), 0 ≤ t ≤ pi/3</code> and <code>x = cos(2t), y = sin(2t), 0 ≤ t ≤ pi/6</code> will be marked correct. |
We use a <code>MultiAnswer()</code> answer checker that will verify that the students answers satisfy the equation for the circle and have the required starting and ending points. This answer checker will allow students to enter any correct parametrization. For example, both <code>x = cos(t), y = sin(t), 0 ≤ t ≤ pi/3</code> and <code>x = cos(2t), y = sin(2t), 0 ≤ t ≤ pi/6</code> will be marked correct. |
||
+ | </p> |
||
+ | <p> |
||
+ | When evaluating student's answers, it is important <b>not</b> to use quotes. For example, if the code were <code>$xstu->eval(t=>"$t1stu")</code> with quotes, then if a student enters <code>pi</code> the answer checker will interpret it as the string <code>"pi"</code> which will need to be converted to a MathObject Real and numerical error will be introduced in the conversion. The correct code to use is <code>$xstu->eval(t=>$t1stu)</code> without quotes so that the answer is interpreted without a conversion that may introduce error. |
||
</p> |
</p> |
||
</td> |
</td> |
||
Line 159: | Line 166: | ||
<p style="text-align:center;"> |
<p style="text-align:center;"> |
||
− | [[ |
+ | [[Problem Techniques|Problem Techniques Index]] |
</p> |
</p> |
||
Line 166: | Line 173: | ||
<ul> |
<ul> |
||
− | <li>POD documentation: [http://webwork.maa.org/ |
+ | <li>POD documentation: [http://webwork.maa.org/pod/pg/macros/parserMultiAnswer.html parserMultiAnswer.pl]</li> |
− | <li>PG macro: [http:// |
+ | <li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/parserMultiAnswer.pl?view=log parserMultiAnswer.pl]</li> |
</ul> |
</ul> |
Latest revision as of 10:58, 16 July 2023
This problem has been replaced with a newer version of this problem
Parametric Equations
This PG code shows how to check student answers that are parametric equations.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserMultiAnswer.pl", ); TEXT(beginproblem()); |
Initialization:
We need to include the macros file |
Context("Numeric"); Context()->variables->are(t=>"Real"); Context()->variables->set(t=>{limits=>[-5,5]}); $x = Formula("cos(t)"); $y = Formula("sin(t)"); $t0 = Compute("0"); $t1 = Compute("pi/3"); ($x0,$y0) = (1,0); ($x1,$y1) = (1/2,sqrt(3)/2); $multians = MultiAnswer($x, $y, $t0, $t1)->with( singleResult => 0, checker => sub { my ( $correct, $student, $self ) = @_; my ( $xstu, $ystu, $t0stu, $t1stu ) = @{$student}; if ( ( ($xstu**2 + $ystu**2) == 1 ) && ( ($xstu->eval(t=>$t0stu)) == $x0 ) && ( ($ystu->eval(t=>$t0stu)) == $y0 ) && ( ($xstu->eval(t=>$t1stu)) == $x1 ) && ( ($ystu->eval(t=>$t1stu)) == $y1 ) ) { return [1,1,1,1]; } elsif ( ( ($xstu**2 + $ystu**2) == 1 ) && ( ($xstu->eval(t=>$t0stu)) == $x0 ) && ( ($ystu->eval(t=>$t0stu)) == $y0 ) ) { return [1,1,1,0]; } elsif ( ( ($xstu**2 + $ystu**2) == 1 ) && ( ($xstu->eval(t=>$t1stu)) == $x1 ) && ( ($ystu->eval(t=>$t1stu)) == $y1 ) ) { return [1,1,0,1]; } elsif ( ( ($xstu**2 + $ystu**2) == 1 ) ) { return [1,1,0,0]; } else { return [0,0,0,0]; } } ); |
Setup:
We use a
When evaluating student's answers, it is important not to use quotes. For example, if the code were |
Context()->texStrings; BEGIN_TEXT Find a parametrization of the unit circle from the point \( \big(1,0\big) \) to \( \big(\frac{1}{2},\frac{\sqrt{3}}{2}\big) \). Use \( t \) as the parameter for your answers. $BR $BR \( x(t) = \) \{$multians->ans_rule(30)\} $BR \( y(t) = \) \{$multians->ans_rule(30)\} $BR $BR for \{ $multians->ans_rule(5) \} \( \leq t \leq \) \{ $multians->ans_rule(5) \} END_TEXT Context()->normalStrings; |
Main Text: The problem text section of the file is as we'd expect. |
$showPartialCorrectAnswers = 1; ANS( $multians->cmp() ); ENDDOCUMENT(); |
Answer Evaluation: As is the answer. |
- POD documentation: parserMultiAnswer.pl
- PG macro: parserMultiAnswer.pl