Difference between revisions of "EquationImplicitFunction1"
Paultpearson (talk | contribs) m |
Paultpearson (talk | contribs) |
||
Line 5: | Line 5: | ||
This PG code shows how to have an answer that is an equation that implicitly defines a function. |
This PG code shows how to have an answer that is an equation that implicitly defines a function. |
||
</p> |
</p> |
||
− | * Download file: [[File:EquationImplicitFunction1.txt]] (change the file extension from txt to pg when you save it) |
||
+ | * File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Algebra/EquationImplicitFunction1.pg FortLewis/Authoring/Templates/Algebra/EquationImplicitFunction1.pg] |
||
− | * File location in NPL: <code>FortLewis/Authoring/Templates/Algebra/EquationImplicitFunction1.pg</code> |
||
<br clear="all" /> |
<br clear="all" /> |
Revision as of 22:18, 15 June 2013
Answer is an Equation that Implicitly Defines a Function
This PG code shows how to have an answer that is an equation that implicitly defines a function.
- File location in OPL: FortLewis/Authoring/Templates/Algebra/EquationImplicitFunction1.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserImplicitEquation.pl", "AnswerFormatHelp.pl", ); TEXT(beginproblem()); |
Initialization: |
Context("ImplicitEquation"); Context()->{error}{msg}{ "Can't find any solutions to your equation"} = " "; Context()->{error}{msg}{ "Can't generate enough valid points for comparison"} = " "; Context()->variables->set( x=>{limits=>[-6,11]}, y=>{limits=>[-6,11]}, ); $a = random(1,5,1); $b = random(1,5,1); $r = random(2,5,1); $answer = ImplicitEquation( "(x-$a)^2 + (y-$b)^2 = $r^2", solutions=>[ [$a,$b+$r], [$a,$b-$r], [$a+$r,$b], [$a-$r,$b], [$a+$r*sqrt(2)/2,$b+$r*sqrt(2)/2], ] ); |
Setup:
We quash some error messages by redefining them to be a blank string
|
Context()->texStrings; BEGIN_TEXT Enter an equation for a circle in the xy-plane of radius \( $r \) centered at \( ($a,$b) \). $BR $BR \{ ans_rule(40) \} \{ AnswerFormatHelp("equation") \} END_TEXT Context()->normalStrings; |
Main Text: |
$showPartialCorrectAnswers = 1; ANS( $answer->cmp() ); |
Answer Evaluation: The answer evaluator used is very sensitive and finicky. We strongly recommended that you read about it at parserImplicitEquation.pl.html |
Context()->texStrings; BEGIN_SOLUTION ${PAR}SOLUTION:${PAR} Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT("MathObject version."); ENDDOCUMENT(); |
Solution: |