Difference between revisions of "ExplicitSequence1"
Jump to navigation
Jump to search
(Created page with '<h2>Sequences with Explicit Formulas</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> This PG code shows how to evaluate answers that are (possibly …') |
Paultpearson (talk | contribs) (PGML example link) |
||
(9 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<h2>Sequences with Explicit Formulas</h2> |
<h2>Sequences with Explicit Formulas</h2> |
||
− | <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
+ | [[File:ExplicitSequence1.png|300px|thumb|right|Click to enlarge]] |
||
+ | <p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"> |
||
This PG code shows how to evaluate answers that are (possibly alternating) sequences with explicit formulas. |
This PG code shows how to evaluate answers that are (possibly alternating) sequences with explicit formulas. |
||
− | <ul> |
||
− | <li>Download file: [[File:Sequences2.txt]] (change the file extension from txt to pg when you save it)</li> |
||
− | <li>File location in NPL: <code>NationalProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/Sequences2.pg</code></li> |
||
− | </ul> |
||
</p> |
</p> |
||
+ | * File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Sequences/ExplicitSequence1.pg FortLewis/Authoring/Templates/Sequences/ExplicitSequence1.pg] |
||
+ | * PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Sequences/ExplicitSequence1_PGML.pg FortLewis/Authoring/Templates/Sequences/ExplicitSequence1_PGML.pg] |
||
+ | <br clear="all" /> |
||
<p style="text-align:center;"> |
<p style="text-align:center;"> |
||
[[SubjectAreaTemplates|Templates by Subject Area]] |
[[SubjectAreaTemplates|Templates by Subject Area]] |
||
Line 68: | Line 68: | ||
$answer = Compute("(-1)^n / n!"); |
$answer = Compute("(-1)^n / n!"); |
||
+ | $answer->{test_points} = [[1],[2],[3],[4],[5],[6]]; |
||
@seq = ( |
@seq = ( |
||
Line 80: | Line 81: | ||
$sequence = join(", ", @seq); |
$sequence = join(", ", @seq); |
||
− | |||
</pre> |
</pre> |
||
</td> |
</td> |
||
Line 86: | Line 86: | ||
<p> |
<p> |
||
<b>Setup:</b> |
<b>Setup:</b> |
||
+ | We set the test points to be positive integers to avoid errors when evaluating the answer. Even if you expect students to enter answers such as <code>cos(pi * n) / n!</code>, you should still restrict the domain to positive integers, because some students may simplify this to <code>(-1)^n / n!</code> and receive errors because the answer checker is substituting things such as <code>n=0.5</code> into their formula. |
||
+ | </p> |
||
+ | <p> |
||
+ | We create an array of strings <code>@seq</code> and use Perl's join function to paste the entries in this array together into one long string with entries separated by commas. |
||
</p> |
</p> |
||
</td> |
</td> |
||
Line 136: | Line 140: | ||
Context()->texStrings; |
Context()->texStrings; |
||
BEGIN_SOLUTION |
BEGIN_SOLUTION |
||
− | ${PAR}SOLUTION:${PAR} |
||
Solution explanation goes here. |
Solution explanation goes here. |
||
END_SOLUTION |
END_SOLUTION |
||
Line 159: | Line 162: | ||
[[Category:Top]] |
[[Category:Top]] |
||
− | [[Category: |
+ | [[Category:Sample Problems]] |
+ | [[Category:Subject Area Templates]] |
Revision as of 22:23, 13 June 2015
Sequences with Explicit Formulas
This PG code shows how to evaluate answers that are (possibly alternating) sequences with explicit formulas.
- File location in OPL: FortLewis/Authoring/Templates/Sequences/ExplicitSequence1.pg
- PGML location in OPL: FortLewis/Authoring/Templates/Sequences/ExplicitSequence1_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", ); TEXT(beginproblem()); |
Initialization: |
Context("Numeric"); Context()->variables->are(n=>"Real"); $answer = Compute("(-1)^n / n!"); $answer->{test_points} = [[1],[2],[3],[4],[5],[6]]; @seq = ( "a_0 = 1", "a_1 = -1", "a_2 = \frac{1}{2}", "a_3 = -\frac{1}{6}", "a_4 = \frac{1}{24}", "a_5 = -\frac{1}{120}", "\ldots" ); $sequence = join(", ", @seq); |
Setup:
We set the test points to be positive integers to avoid errors when evaluating the answer. Even if you expect students to enter answers such as
We create an array of strings |
Context()->texStrings; BEGIN_TEXT Find a formula for \( n^{th} \) term of the sequence \( $sequence \). $BR $BR \( a_n = \) \{ ans_rule(20) \} \{ AnswerFormatHelp("formulas") \} END_TEXT Context()->normalStrings; |
Main Text: |
$showPartialCorrectAnswers = 1; ANS( $answer->cmp() ); |
Answer Evaluation: |
Context()->texStrings; BEGIN_SOLUTION Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |