# Difference between revisions of "FormulaTestPoints"

m |
|||

Line 7: | Line 7: | ||

<p> |
<p> |
||

This can, of course, be done with new and old-style answer evaluators. An example of the latter appears below. Also note that we may want to do this in two different ways: either by setting the <em>domain</em> on which the formula is evaluated (that is, the <em>limits of evaluation</em>), or by setting specific <em>test points</em> on which the formula should be considered. These are both shown below. |
This can, of course, be done with new and old-style answer evaluators. An example of the latter appears below. Also note that we may want to do this in two different ways: either by setting the <em>domain</em> on which the formula is evaluated (that is, the <em>limits of evaluation</em>), or by setting specific <em>test points</em> on which the formula should be considered. These are both shown below. |
||

+ | </p> |
||

+ | |||

+ | <p style="text-align:center;"> |
||

+ | [[IndexOfProblemTechniques|Problem Techniques Index]] |
||

</p> |
</p> |
||

Line 126: | Line 130: | ||

</tr> |
</tr> |
||

</table> |
</table> |
||

+ | <p style="text-align:center;"> |
||

+ | [[IndexOfProblemTechniques|Problem Techniques Index]] |
||

+ | </p> |

## Revision as of 16:21, 23 January 2008

## Formula Test Points for Evaluation: PG Code Snippet

*This code snippet shows the essential PG code to specify the points on which a formula is evaluated when a student's answer is checked. Note that these are insertions, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.*

This can, of course, be done with new and old-style answer evaluators. An example of the latter appears below. Also note that we may want to do this in two different ways: either by setting the *domain* on which the formula is evaluated (that is, the *limits of evaluation*), or by setting specific *test points* on which the formula should be considered. These are both shown below.

PG problem file | Explanation |
---|---|

Context()->variables->set(x=>{limits=>[-1,1]}); $func = Compute("sqrt(x+1)"); ## Alternately: # Context()->flags->set(limits=>[-1,1]); # $func = Compute("sqrt(x+1)"); ## Or, setting the limits only for the given ## formula, we don't need to reset the Context, ## and just include # $func = Compute("sqrt(x+1)"); # $func->{limits} = [-1,1]; $gunc = Compute("sqrt(x^2 - 4)"); $gunc->{test_points} = [[-3],[-2],[2],[3],[4]]; |
We don't have to change anything in the documentation and tagging or initialization sections of the PG file. In the problem set-up, we can specify the limits on which all Formulas are evaluated by setting the
It is also possible to specify the actual points on which the Formula will be evaluated. This is an attribute of the Formula itself; the call is shown for our formula
One final note: if the formula is a function of more than one variable and we're specifying limits in the formula, we need to specify the limits for all variables. Thus, we'd have something like |

BEGIN_TEXT Enter \( $func \): \{ ans_rule(35) \} $BR Enter \( $gunc \): \{ ans_rule(35) \} END_TEXT |
The text portion of the file is the same as usual. |

ANS( $func->cmp() ); ANS( $gunc->cmp() ); |
And the answer evaluation is as we'd expect. |

With old-style answer evaluators, we can do the same thing:

PG problem file | Explanation |
---|---|

$func = "sqrt(x+1)"; $gunc = "sqrt(x^2 - 4)"; |
We define the functions as expected in the problem set-up section of the file. |

BEGIN_TEXT Enter \( \sqrt{x+1} \): \{ ans_rule(35) \} $BR Enter \( \sqrt{x^2 - 4} \): \{ ans_rule(35) \} END_TEXT |
And the text portion of the file is similarly mundane. |

ANS(fun_cmp($func, limits=>[-1,1])); ANS(fun_cmp($gunc, test_points=>[-3,-2,2,3,4])); |
The limits or test points are specified in the |