Difference between revisions of "RecursivelyDefinedFunctions"
(add historical tag and give links to newer problems.) |
|||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | <h2>Recursively Defined Functions</h2> |
||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Sequences/RecursiveSequence.html a newer version of this problem]</p> |
||
+ | |||
+ | |||
+ | <h2>Recursively Defined Functions (Sequences)</h2> |
||
<!-- Header for these sections -- no modification needed --> |
<!-- Header for these sections -- no modification needed --> |
||
Line 66: | Line 71: | ||
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
+ | Context()->texStrings; |
||
BEGIN_TEXT |
BEGIN_TEXT |
||
The current value \( f(n) \) is three |
The current value \( f(n) \) is three |
||
Line 74: | Line 80: | ||
\( f(n) \) = \{ ans_rule(20) \} |
\( f(n) \) = \{ ans_rule(20) \} |
||
END_TEXT |
END_TEXT |
||
+ | Context()->normalStrings; |
||
</pre> |
</pre> |
||
<td style="background-color:#ffcccc;padding:7px;"> |
<td style="background-color:#ffcccc;padding:7px;"> |
||
Line 108: | Line 115: | ||
[[Category:Problem Techniques]] |
[[Category:Problem Techniques]] |
||
+ | |||
+ | |||
+ | |||
+ | <ul> |
||
+ | <li>POD documentation: [http://webwork.maa.org/pod/pg/macros/parserFunction.html parserFunction.pl]</li> |
||
+ | <li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/parserFunction.pl?view=log parserFunction.pl]</li> |
||
+ | </ul> |
Latest revision as of 13:48, 16 July 2023
This problem has been replaced with a newer version of this problem
Recursively Defined Functions (Sequences)
This PG code shows how to check student answers that are recursively defined functions.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserFunction.pl", ); TEXT(beginproblem()); |
Initialization:
We will be defining a new named function and adding it to the context, and the easiest way to do this is using |
Context("Numeric")->variables->are(n=>"Real"); parserFunction(f => "sin(pi^n)+e"); $fn = Formula("3 f(n-1) + 2"); |
Setup:
We define a new named function |
Context()->texStrings; BEGIN_TEXT The current value \( f(n) \) is three times the previous value, plus two. Find a recursive definition for \( f(n) \). Enter \( f_{n-1} \) as \( f(n-1) \). $BR \( f(n) \) = \{ ans_rule(20) \} END_TEXT Context()->normalStrings; |
Main Text: The problem text section of the file is as we'd expect. We should tell students to use function notation rather than subscript notation so that they aren't confused about syntax. |
$showPartialCorrectAnswers=1; ANS( $fn->cmp() ); ENDDOCUMENT(); |
Answer Evaluation: As is the answer. |
- POD documentation: parserFunction.pl
- PG macro: parserFunction.pl