[LON-CAPA-users] exponent in formula response

James Mueller lon-capa-users@mail.lon-capa.org
Fri, 29 Jan 2010 13:35:15 -0500


A faculty member has a math problem that uses formula response with  
samples so that students can enter their final expression without  
having to plug it into a calculator.

/res/athanas/c2-volume-1.problem

an acceptable answer  (depending on the randomization) might be
3.14159*(400/3*19^3-80/4*19^4+4/5*19^5

She has noticed an issue when the end-point of the integration is 10.  
A submission such as
3.14159*(400/3*10^3-80/4*10^4+4/5*10^5)
is evaluated as incorrect, whereas if the student explicitly adds  
parenthesis,
3.14159*(400/3*(10^3)-80/4*(10^4)+4/5*(10^5))
everything works as expected.

So for 10, and only 10, there seems to be a problem.

Any ideas as to How she might fix this problem?
(other than the one I came up with,which is choose random numbers such  
that 10 is never the endpoint of the integration in x)


<problem>
     <script type="loncapa/perl">
$n=1.123; while ($n !=&roundto($n,1) ){
$a=&random(1,5,1); $b=&random(1,20,1); $n=$b/$a;}
for ($x = 0; $x<=$n; $x+= 0.001) {
      push @X1, $x;
      push @Y1, $b*$x-$a*$x**2;   }
$p=($a**2)/5*($n**5)-$a*$b/2*($n**4)+($b**2)/3*($n**3);
$pi=3.14159;
$volume1="$pi*$p";
$example=3.14159*(7**3/3+(7/2)**2-14*exp(2));
  </script>
  <startouttext />
<br />
Determine the volume of the solid formed by rotating about the <m>$x$</ 
m>-axis, the region above the <m>$x$</m>-axis and below the curve <m  
eval="on">$\;\;  y = $b x - $a x^2\,$</m>. <p />
<endouttext />
<gnuplot width="400" grid="on" align="center" font="medium"  
height="300" border="on" bgcolor="xffffff" fgcolor="x000000"  
alttag="dynamically generated plot" transparent="off">
      <xlabel>x</xlabel>
      <curve linestyle="lines" name="" color="x8B0000" pointtype="1"  
pointsize="1">
          <data>@X1</data>
          <data>@Y1</data>
      </curve>
   </gnuplot>
<p />
<startouttext />Volume of the solid is
<formularesponse answer="$volume1" samples="x@1:4#2" id="11">
<responseparam name="tol" default="0.001" description="Numerical  
Tolerance" type="tolerance" />
         <textline size="55" readonly="no" />
     </formularesponse>
  <m> units $^3$.</m>
<br />Use <m>$\pi=3.14159$</m> and round your answer to 3 decimal  
places.
<br />
You do not need to do calculations. For example <m eval="on">$example  
</m> can be given as  3.14159(7^3/3+(7/2)^2-14exp(2)). <endouttext />
</problem>