You are looking at the HTML representation of the XML format.
HTML is good for debugging, but probably is not suitable for your application.
See complete documentation, or API help for more information.
<?xml version="1.0"?>
<api>
  <query-continue>
    <allpages gapfrom="RecursivelyDefinedFunctions" />
  </query-continue>
  <query>
    <pages>
      <page pageid="2676" ns="0" title="Real (MathObject Class)">
        <revisions>
          <rev xml:space="preserve">=== Real class ===

The Real class implements real numbers with &quot;fuzzy&quot; comparison (governed by the same tolerances and settings that control student answer checking).  For example, &lt;code&gt;Real(1.0) == Real(1.0000001)&lt;/code&gt; will be true, while &lt;code&gt;Real(1.0) &amp;lt; Real(1.0000001)&lt;/code&gt; will be false.  Reals can be created in any Context, but the &lt;code&gt;Numeric&lt;/code&gt; Context is the most frequently used for Reals.


=== Creation ===

Reals are created via the &lt;code&gt;Real()&lt;/code&gt; function, or by &lt;code&gt;Compute()&lt;/code&gt;.  Reals can be added, subtracted, and so on, and the results will still be MathObject Reals.  Similarly, &lt;code&gt;sin()&lt;/code&gt;, &lt;code&gt;sqrt()&lt;/code&gt;, &lt;code&gt;ln()&lt;/code&gt;, and the other functions return Real objects if their arguments are Reals.  For example:

    Context(&quot;Numeric&quot;);
    
    $a = Real(2);
    $b = $a + 5;     # same as Real(7);
    $c = sqrt($a);   # same as Real(sqrt(2));

This allows you to compute with Reals just as you would with native Perl real numbers.


=== Pre-defined Reals ===

The value &lt;code&gt;pi&lt;/code&gt; can be used in your Perl code to represent the value of &lt;math&gt;\pi&lt;/math&gt;.  Note that you must use &lt;code&gt;-(pi)&lt;/code&gt; for &lt;math&gt;-\pi&lt;/math&gt; in Perl expressions (but not in strings that will be parsed by MathObjects, such as student answers or arguments to &lt;code&gt;Compute()&lt;/code&gt;). For instance:

    $a = pi + 2;              # same as Real(&quot;pi + 2&quot;);
    $b = 2 - (pi);            # same as Real(&quot;2 - pi&quot;);
    $c = sin(pi/2);           # same as Real(1);
    $d = Compute(&quot;2 - pi&quot;);   # parens only needed in Perl expressions

The value &lt;code&gt;e&lt;/code&gt;, for the base of the natural log, &lt;math&gt;e&lt;/math&gt;, can be used in student answers and parsed strings.

    $e = Compute(&quot;e&quot;);
    $p = Compute(&quot;e^2&quot;);


=== Answer Checker ===

As with all MathObjects, you obtain an answer checker for a Real object via the &lt;code&gt;cmp()&lt;/code&gt; method:

    ANS(Real(2)-&gt;cmp);

The Real class supports the [[Answer_Checker_Options_(MathObjects)| common answer-checker options]], and the following additional options:

{| class=&quot;wikitable&quot;
! Option !! Description !! style=&quot;padding:5px&quot; | Default
|- style=&quot;vertical-align: top&quot;
| style=&quot;padding: 5px; white-space: nowrap&quot; | &lt;code&gt;ignoreInfinity =&gt; 1&lt;/code&gt; or &lt;code&gt;0&lt;/code&gt;
| style=&quot;padding: 5px&quot; | Do/don't report type mismatches if the student enters an infinity.
| style=&quot;text-align:center&quot; | &lt;code&gt;1&lt;/code&gt;
|}


=== Methods ===

The Real class supports the [[Common MathObject Methods]].  There are no additional methods for this class.

The command

    Parser::Number::NoDecimals();

will add a check so that a number with decimal places is not allowed.  This can be used to require students to enter values in terms of `pi` or `sqrt(2)` for example.  You can also supply a Context as an argument to disallow decimals in that context:

    Parser::Number::NoDecimals($context);

Without a parameter, the current context is assumed.


=== Properties ===

The Real class supports the [[Common MathObject Properties]], and the following additional ones:

{| class=&quot;wikitable&quot;
! Property !! Description !! style=&quot;padding:5px&quot; | Default

|- style=&quot;vertical-align: baseline&quot;
| style=&quot;padding: 5px; white-space: nowrap&quot; | &lt;code&gt;$r-&gt;{period}&lt;/code&gt;
| style=&quot;padding: 5px&quot; | When set, this value indicates that the real is periodic, with period given by this value.  So angles might use &lt;code&gt;period&lt;/code&gt; set to &lt;code&gt;2*pi&lt;/code&gt;.

'''Example:'''
: &lt;code&gt;$r = Real(pi/3)-&gt;with(period =&gt; 2*pi);&lt;/code&gt;
: &lt;code&gt;$r == 7*pi/3;  # will be true&lt;/code&gt;
| style=&quot;text-align:center&quot; | &lt;code&gt;undef&lt;/code&gt;

|- style=&quot;vertical-align: baseline&quot;
| style=&quot;padding: 5px; white-space: nowrap&quot; | &lt;code&gt;$r-&gt;{logPeriodic}&lt;/code&gt;
| style=&quot;padding: 5px&quot; | When &lt;code&gt;period&lt;/code&gt; is defined, and &lt;code&gt;logPeriodic&lt;/code&gt; is set to &lt;code&gt;1&lt;/code&gt; this indicates that the periodicity is logarithmic (i.e., the period refers to the log of the value, not the value itself).

'''Example:'''
: &lt;code&gt;$r = Real(4)-&gt;with(period =&gt; 10, logPeriodic =&gt; 1);&lt;/code&gt;
: &lt;code&gt;$r == 88105;  # true since 88105 is nearly exp(10+log(4))&lt;/code&gt;
| style=&quot;text-align:center&quot; | &lt;code&gt;0&lt;/code&gt;
|}


&lt;br&gt;

[[Category:MathObject_Classes]]
[[Category:MathObjects]]</rev>
        </revisions>
      </page>
      <page pageid="1447" ns="0" title="RecursiveSequence1">
        <revisions>
          <rev xml:space="preserve">&lt;h2&gt;Sequences and Recursively Defined Functions&lt;/h2&gt;

[[File:RecursiveSequence1.png|300px|thumb|right|Click to enlarge]]
&lt;p style=&quot;background-color:#f9f9f9;border:black solid 1px;padding:3px;&quot;&gt;
This PG code shows how to add a named function to the context and use it to ask students to come up with a recursive formula.
&lt;/p&gt;
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Sequences/RecursiveSequence1.pg FortLewis/Authoring/Templates/Sequences/RecursiveSequence1.pg]
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Sequences/RecursiveSequence1_PGML.pg FortLewis/Authoring/Templates/Sequences/RecursiveSequence1_PGML.pg]

&lt;br clear=&quot;all&quot; /&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;
[[SubjectAreaTemplates|Templates by Subject Area]]
&lt;/p&gt;

&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; border=&quot;0&quot;&gt;

&lt;tr valign=&quot;top&quot;&gt;
&lt;th&gt; PG problem file &lt;/th&gt;
&lt;th&gt; Explanation &lt;/th&gt;
&lt;/tr&gt;


&lt;!-- Problem tagging section --&gt;

&lt;tr valign=&quot;top&quot;&gt;
&lt;td style=&quot;background-color:#eeeeee;border:black 1px dashed;&quot;&gt;
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]
&lt;/td&gt;
&lt;td style=&quot;background-color:#eeeeee;padding:7px;&quot;&gt;
&lt;p&gt;
&lt;b&gt;Problem tagging:&lt;/b&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;


&lt;!-- Initialization section --&gt;

&lt;tr valign=&quot;top&quot;&gt;
&lt;td style=&quot;background-color:#ddffdd;border:black 1px dashed;&quot;&gt;
&lt;pre&gt;
DOCUMENT();

loadMacros(
&quot;PGstandard.pl&quot;,
&quot;MathObjects.pl&quot;,
&quot;parserFunction.pl&quot;,
);

TEXT(beginproblem());
&lt;/pre&gt;
&lt;/td&gt;
&lt;td style=&quot;background-color:#ddffdd;padding:7px;&quot;&gt;
&lt;p&gt;
&lt;b&gt;Initialization:&lt;/b&gt;
We will be defining a new named function and adding it to the context, and the easiest way to do this is using &lt;code&gt;parserFunction.pl&lt;/code&gt;.  There is a more basic way to add functions to the context, which is explained in example 2 at
[http://webwork.maa.org/wiki/AddingFunctions AddingFunctions]
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;


&lt;!-- Setup section --&gt;

&lt;tr valign=&quot;top&quot;&gt;
&lt;td style=&quot;background-color:#ffffdd;border:black 1px dashed;&quot;&gt;
&lt;pre&gt;
Context(&quot;Numeric&quot;)-&gt;variables-&gt;are(n=&gt;&quot;Real&quot;);
parserFunction(f =&gt; &quot;sin(pi^n)+e&quot;);

$fn = Formula(&quot;3 f(n-1) + 2&quot;);
&lt;/pre&gt;
&lt;/td&gt;
&lt;td style=&quot;background-color:#ffffcc;padding:7px;&quot;&gt;
&lt;p&gt;
&lt;b&gt;Setup:&lt;/b&gt; 
We define a new named function &lt;code&gt;f&lt;/code&gt; as something the student is unlikely to guess.  The named function &lt;code&gt;f&lt;/code&gt; is, in some sense, just a placeholder since the student will enter expressions involving &lt;code&gt;f(n-1)&lt;/code&gt;, WeBWorK will interpret it internally as &lt;code&gt;sin(pi^(n-1))+e&lt;/code&gt;, and the only thing the student sees is &lt;code&gt;f(n-1)&lt;/code&gt;.   If the 
recursion has an closed-form solution (e.g., the Fibonacci numbers are given by f(n) = (a^n - (1-a)^n)/sqrt(5) where a = (1+sqrt(5))/2) and you want to allows students to enter the closed-form solution, it would be good to define f using that explicit solution in case the student tries to answer the question by writing out the explicit solution (a^n - (1-a)^n)/sqrt(5) instead of using the shorthand f(n).
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;!-- Main text section --&gt;

&lt;tr valign=&quot;top&quot;&gt;
&lt;td style=&quot;background-color:#ffdddd;border:black 1px dashed;&quot;&gt;
&lt;pre&gt;
Context()-&gt;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()-&gt;normalStrings;
&lt;/pre&gt;
&lt;td style=&quot;background-color:#ffcccc;padding:7px;&quot;&gt;
&lt;p&gt;
&lt;b&gt;Main Text:&lt;/b&gt;
We should tell students to use function notation rather than subscript notation so that they aren't confused about syntax.
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;!-- Answer evaluation section --&gt;

&lt;tr valign=&quot;top&quot;&gt;
&lt;td style=&quot;background-color:#eeddff;border:black 1px dashed;&quot;&gt;
&lt;pre&gt;
$showPartialCorrectAnswers=1;

ANS( $fn-&gt;cmp() );
&lt;/pre&gt;
&lt;td style=&quot;background-color:#eeccff;padding:7px;&quot;&gt;
&lt;p&gt;
&lt;b&gt;Answer Evaluation:&lt;/b&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;!-- Solution section --&gt;

&lt;tr valign=&quot;top&quot;&gt;
&lt;td style=&quot;background-color:#ddddff;border:black 1px dashed;&quot;&gt;
&lt;pre&gt;

Context()-&gt;texStrings;
BEGIN_SOLUTION
Solution explanation goes here.
END_SOLUTION
Context()-&gt;normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();
&lt;/pre&gt;
&lt;td style=&quot;background-color:#ddddff;padding:7px;&quot;&gt;
&lt;p&gt;
&lt;b&gt;Solution:&lt;/b&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p style=&quot;text-align:center;&quot;&gt;
[[SubjectAreaTemplates|Templates by Subject Area]]
&lt;/p&gt;

[[Category:Top]]
[[Category:Sample Problems]]
[[Category:Subject Area Templates]]</rev>
        </revisions>
      </page>
    </pages>
  </query>
</api>