Difference between revisions of "VectorValuedFunctions"
Jump to navigation
Jump to search
(New page: <h2>Vector Valued Functions as Answers</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> <em>T...) |
|||
Line 163: | Line 163: | ||
<ul> |
<ul> |
||
− | <li>POD documentation: </li> |
||
+ | <li>POD documentation: [http://webwork.maa.org/doc/cvs/pg_CURRENT/macros/parserParametricLine.pl.html parserParametricLine.pl.html]</li> |
||
− | <li>PG macro: </li> |
||
+ | <li>PG macro: [http://cvs.webwork.rochester.edu/viewcvs.cgi/pg/macros/parserParametricLine.pl parserParametricLine.pl]</li> |
||
</ul> |
</ul> |
||
+ | |||
+ | |||
<ul> |
<ul> |
Revision as of 18:05, 4 March 2010
Vector Valued Functions as Answers
This shows the PG code to check student answers that are vectors whose components are formulas.
- Example 1: Vector Parametric Lines
Example 1: Vector Parametric Lines
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserVectorUtils.pl", "parserParametricLine.pl", "answerCustom.pl", "PGcourse.pl", ); TEXT(beginproblem()); |
Initialization:
To do ..(what you are doing)........., we don't have to change the
tagging and documentation section of the problem file.
In the initialization section, we need to include the macros file |
Context("Vector"); Context()->variables->are(t=>"Real"); $P = non_zero_point3D(); $V = non_zero_vector3D(); $Q = Point($P + $V); $speed = random(3,9,1); |
Setup:
We specify that the Context should be Notes: on using this and related Contexts. |
Context()->texStrings; BEGIN_TEXT A particle starts at the point \( P = $P \) when \( t = 0 \) and moves along a straight line toward \( Q = $Q \) at a speed of \( $speed \) cm/sec. Let x, y, and z be measured in cm, and t in seconds. $BR $BR (a) Find any vector parametric equation for the line through points \( P \) and \( Q \). \( L(t) = \) \{ ans_rule(40) \} $BR $BR (b) Find a vector parametric equation for the position of the object. $BR \( \vec{r}(t) = \) \{ans_rule(40)\} END_TEXT Context()->normalStrings; |
Main Text: The problem text section of the file is as we'd expect. |
$showPartialCorrectAnswers = 1; $T = Formula("$speed * t / norm($V)"); $L = $P + $T * $V; ANS( ParametricLine("$L")->cmp() ); sub mycheck { my ($correct, $student, $ansHash) = @_; if ( ($correct . i == $student . i) && ($correct . j == $student . j) && ($correct . k == $student . k) ) { return 1; } else { return 0; } } ANS( custom_cmp( $L, ~~&mycheck, showCoordinateHints=>1 ) ); ENDDOCUMENT(); |
Answer Evaluation: For more on custom answer evaluators, see CustomAnswerCheckers and answerCustom.pl.html |
- POD documentation: parserParametricLine.pl.html
- PG macro: parserParametricLine.pl
- POD documentation: answerCustom.pl.html
- PG macro: answerCustom.pl