PREP 2015 Question Authoring - Archived

Scientific Notation Error in OPL problem

Scientific Notation Error in OPL problem

by tim Payer -
Number of replies: 2
Hello,

I am writing solutions to a number of selected OPL problems and came across a possible error in a problem that had the original file path of:

Library/Rochester/setDerivatives2Formulas/c2s5p3

The (algorithmic) problem answer has a number of zeros after the decimal before significant figures are encountered. As a hint to use scientific notation the student is given a prompt  in the wording of the problem that states:

"Tip: You can enter an answer such as 3.14e-1 for 0.314."

The problem is that when entered in this form the numerical value of e = 2.718241824.. is used in the calculation of the students answer.

I checked the course configuration and did not see a feature where scientific notation could be enabled for student answers in this way. Is there something else I should have checked to enable scientific notation?

Thanks,  tim

Below is the altered code for the problem with solutions:

## DESCRIPTION
##   The Chain Rule
## ENDDESCRIPTION

## Tagged by nhamblet

## DBsubject(Calculus - single variable)
## DBchapter(Differentiation)
## DBsection(Chain rule (without trigonometric functions))
## Institution(Rochester)
## Level(2)
## MO(1)
## KEYWORDS('Derivative', 'Polynomial', 'Chain')
## Library/Rochester/setDerivatives2Formulas/c2s5p3

DOCUMENT();        # This should be the first executable line in the problem.

loadMacros("PG.pl",
           "PGbasicmacros.pl",
           "PGchoicemacros.pl",
           "PGanswermacros.pl",
           "PGauxiliaryFunctions.pl",
           "MathObjects.pl"
            );

TEXT(beginproblem());
$showPartialCorrectAnswers = 1;

Context("Numeric");
$denom= 0;
while ($denom <= 0 ) {
$t1 = random(-4,4,1);
$a=   non_zero_random(-4,4,1);
$a2 = $a*2;
$b=   non_zero_random(-4,4,1);
$gcd = ($a2,$b);
$a3 = $a2/$gcd;
$b3 = $b/$gcd;
$gc8 = $gcd*(-8);
$at3 = $a3*$t1;
$tsq = $t1*$t1;
$bt1 = $b*$t1;
$abt3 = $at3+$b3;
$atsq = $a*$tsq;
$c=   non_zero_random(-4,4,1);
$btc = $bt1 + $c;
$num =$gc8*$abt3;
$den1 = $atsq+$btc;
$den2 = $den1**9;
$gcd = gcd($num,$den2);
$num3 =$num/$gcd;
$den3 =$den2/$gcd;
$ans = $num/$den1**9;
$d =  random(-4,4,1);
$denom = $a*$t1**2 +$b*$t1 +$c;
}
$fp= Compute("-8*$denom**(-9)*(2*$a*$t1 + $b)");

# Present the text.
TEXT(EV2(<<EOT));
Calculate \( f'($t1) \) to 3 significant figures where
\[ f(t) = ($a t^2 + $b t + $c )^{-8} \]

\( f'( $t1 ) = \)\{ ans_rule(20) \}

$PAR
Tip: You can enter an answer such as 3.14e-1 for 0.314. $PAR
EOT

ANS($fp->cmp);

SOLUTION(EV3(<<'END_SOLUTION'));
$PAR SOLUTION $PAR

Use the chain rule to find the derivative of composed functions. $BR   
The function of  \( f(t) = ($a t^2 + $b t + $c )^{-8}   \)  is a composed function because the outer function of the negative exponent is "holding" the inner function of a quadratic equation. The chain rule applies the derivative on the outermost function first and then works inward applying the derivative to each successive inner function in a series of products. With each application of the derivative on the outer function the inner contents are left alone. In this way a "chain" of derivative products are formed. The chain rule can be expressed with notation as shown below: $BR
 $BR
Given that `p(x) = f(g(x))`, $BR
$BR
The derivative is applied by the chain rule: $BR
$BR
\( p'(x) = f'(g(x)) \cdot g'(x) \)   $BR
$BR
Apply the derivative to `f(t)`: $BR
$BR
\( f(t) = ($a t^2 + $b t + $c )^{-8}\) $BR
$BR
Apply the prime tics for the chain rule:$BR
$BR
\( f'(t) = \left(($a t^2 + $b t + $c )^{-8}\right)' \left($a t^2 + $b t + $c \right)'\) $BR
$BR
Apply the derivative: $BR
$BR
\( f'(t) = -8($a t^2 + $b t + $c )^{-9} \left($a2 t + $b \right)\) $BR
$BR
Push the quantity of the negative exponent down to the denominator: $BR
$BR
\( \displaystyle{f'(t) = \frac{-8($a2 t + $b) }{($a t^2 + $b t + $c )^{9}} } \) $BR
$BR
Pull any common factors from the numerator: $BR
$BR
\( \displaystyle{f'(t) = \frac{-8 \cdot $gcd($a3 t + $b3) }{($a t^2 + $b t + $c )^{9}} } \) $BR
$BR
Combine factors for the reduced derivative: $BR
$BR
\( \displaystyle{f'(t) = \frac{$gc8($a3 t + $b3) }{($a t^2 + $b t + $c )^{9}}}  \) $BR
$BR
Evaluate the derivative at `t = $t1`: $BR
$BR
\( \displaystyle{f'($t1) = \frac{$gc8($a3 \cdot ($t1) + $b3) }{($a \cdot ($t1)^2 + $b \cdot ($t1) + $c )^{9}}}  \) $BR
$BR
Combine factors and squared values:$BR
$BR
\( \displaystyle{f'($t1) = \frac{$gc8($at3 + $b3) }{($a \cdot $tsq + $bt1 + $c )^{9}}}  \) $BR
$BR
Combine factors and terms:$BR
$BR
\( \displaystyle{f'($t1) = \frac{$gc8($abt3) }{($atsq + $btc )^{9}}}  \) $BR
$BR
Combine factors and terms:$BR
$BR
\( \displaystyle{f'($t1) = \frac{$num }{($den1 )^{9}} =\frac{$num }{$den2} }  \) $BR
$BR
An exact value:
$BR
\( \displaystyle{f'($t1) = \frac{$num3 }{$den3} }  \) $BR
$BR
A decimal approximation:$BR
$BR
\( \displaystyle{f'($t1) = $ans}  \) $BR
$BR

END_SOLUTION

ENDDOCUMENT();        # This should be the last executable line in the problem.

In reply to tim Payer

Re: Scientific Notation Error in OPL problem

by Arnold Pizer -
Hi Tim,

The hint should read "Tip: You can enter an answer such as 3.14E-1 for 0.314." See http://webwork.maa.org/wiki/Available_Functions

I don't remember but ages ago before we had the constants pi and e and/or before the current parser, maybe 3.14e-1 did work for scientific notation or it could be a typo in the problem.  

Arnie
In reply to Arnold Pizer

Re: Scientific Notation Error in OPL problem

by tim Payer -
Thanks, Arnie,

I just discovered the correction on my own, and yes the original problem used a lower case "e" which results in an error.

thanks, Tim