DigitsTolType: Difference between revisions
(first draft of page.) |
(change explanation of how digits tolType is supposed to work) |
||
Line 59: | Line 59: | ||
<b>Setup:</b> | <b>Setup:</b> | ||
<ul> | <ul> | ||
<li>The <code>tolType=>'digits'</code> switches from the default 'relative' tolerance type to the 'digits' tolerance type.</li> | |||
<li>The <code>tolType=>'digits'</code> | <li>The <code>tolerance=>3</code> sets the number of digits to 3. The default value is the default for other tolerance types, 0.001, but any tolerance that is between 0 and 1 is converted via log10 and rounding to an integer (in this case, to 3).</li> | ||
<li> The <code>tolerance=>3</code> sets the number of digits to 3 | <li>The <code>tolTruncation</code> parameter is either 1 (true) or 0 (false). Details are explained below.</li> | ||
<li> The <code>tolTruncation</code> parameter is either 1 (true) or 0 (false). Details are explained below.</li> | <li>The <code>tolExtraDigits</code> parameter sets the number of extra digits for checking answers. This is explained below.</li> | ||
<li> The <code>tolExtraDigits</code> parameter sets the number of extra digits for checking answers. This is explained below. </li> | |||
</ul> | </ul> | ||
</p> | </p> | ||
<p> | <p> | ||
The goal is that the student must enter at least the first <code>tolerance</code> digits correctly. The last digits that they enter might be rounded (always accepted) or truncated (only accepted if <code>tolTruncation</code> is true). For example, if the correct answer is e=2.7182818... and <code>tolerance</code> is 3, the student can answer with 2.72. Or they can answer with 2.71 if <code>tolTruncation</code> is true. But for example 2.7 and 2.73 are not accepted. | |||
</p> | |||
</ | |||
<p> | <p> | ||
If the student enters additional digits, the first additional <code>tolExtraDigits</code> digits (which has default 1) are examined in the same manner. For example, if the correct answer is pi=3.1415926... and default flag values are used, the student can answer with 3.14, 3.141, 3.142, 3.1415, and even 3.1418 since that 8 is beyond the extra digits checking. But for example 3.143 is not accepted, since the first extra digit is not right. (And if <code>tolTruncation</code> is false, 3.141 would not be accepted. | |||
</p> | </p> | ||
</td> | </td> | ||
</tr> | </tr> |
Revision as of 17:19, 30 April 2021
Digits TolType
This describes an alternative way for determining the tolerance type based on the number of digits.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGML.pl" ); TEXT(beginproblem()); |
Initialization: The tolType of type digits is built-in to MathObjects. |
Context("Numeric") Context()->flags->set(tolType=>'digits', tolerance=>3, tolTruncation=>1); $answer = Real("pi"); |
Setup:
The goal is that the student must enter at least the first
If the student enters additional digits, the first additional |
BEGIN_PGML This section is with [|tolTruncation|] set to true (1). The exact answer is [`\pi`]. Enter 3.14, 3.15, 3.141, 3.142 to see if it accepts the answer. [`\pi=`][_]{$answer} END_PGML |
First Section: This tests the default characteristic of this answer checker. It should accept 3.14, 3.141 and 3.142 as correct, but not 3.15. |
Context("Numeric"); Context()->flags->set(tolType=>'digits', tolerance=>3, tolTruncation=>0); $answer2 = Real("pi"); |
Second block explanation: First, reset the context with |
BEGIN_PGML This section is with [|tolTruncation|] set to false (0). The exact answer is [`\pi`]. Enter 3.14, 3.15, 3.141, 3.142 to see if it accepts the answer. [`\pi=`][_]{$answer2} END_PGML |
Second Section: This tests the default characteristic of this answer checker. It should accept 3.14, 3.142 as correct, but not 3.141 or 3.15. |
Context("Numeric"); Context()->flags->set(tolType=>'digits', tolerance=>3, tolTruncation=>0,tolExtraDigits=>2); $answer3 = Real("3.14"); |
Second block explanation: First, reset the context with |
BEGIN_PGML If we want to consider only answers to some number to digits. Enter 3.14, 3.15, 3.141, 3.142 to see if it accepts the answer. Enter [`\pi`] to the first 2 decimal places after the decimal point [_]{$answer3} END_PGML |
Third Section: This allows only to the given number of digits (3). It should accept only 3.14 as correct. |