ExplicitSequence1

From WeBWorK_wiki
Revision as of 21:17, 1 December 2010 by Pearson (talk | contribs) (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 …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Sequences with Explicit Formulas

This PG code shows how to evaluate answers that are (possibly alternating) sequences with explicit formulas.

  • Download file: File:Sequences2.txt (change the file extension from txt to pg when you save it)
  • File location in NPL: NationalProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/Sequences2.pg

Templates by Subject Area

PG problem file Explanation

Problem tagging data

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!");

@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:

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
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area