[LON-CAPA-users] Extracting the numerical value from a solve()Maxima command

Seema Ali sali at vsb.bc.ca
Wed Feb 8 21:29:08 EST 2012


I believe I asked about this question before and made changes so that it would extract the user's response and plug it into a formula to see if both sides are equal.  Unfortunately the question produces a weird error sometimes when calculating the solution.
 
I can't tell what is causing the error.  It works with other negative solutions.
 
Thanks.
 
ERROR: Computer's answer is incorrect ("-1.24"). It is likely that the tolerance range [-1.24200376392202, -1.24000376392203] needs to be adjusted.
This error occurred while processing response 1_7 in part 0
 
The answer to the question is correct:
Solve for $x$ to the nearest hundredth where $6^{3 x} = 9^{-4 x - 8}$
 
<problem>
<script type="loncapa/perl">
$base1 = &random(2,9,1);
do {
   $base2 = &random(2,9,1);
} while ($base1==$base2);
$a = &random(2,3,1);
$b = &random(-7,-4,1);
$c = &random(1,10,1);

if (&random(0,1,1)) {
  $power1 = "$a x";
  $power2 = "$b x - $c";
  $power1maxima = "$a * x";
  $power2maxima = "$b * x - $c";
} else {
  $power1 = "$a x + $c";
  $power2 = "$b x";
  $power1maxima = "$a * x + $c";
  $power2maxima = "$b * x";
}

$solution = &cas('maxima',"float(solve(($power1maxima)*log($base1) = ($power2maxima)*log($base2),x))");
$solution=~/\=\s*(.+)\s*\]/;
$answer=$1;
</script>
<startouttext />Solve for <m>$x$</m> to the nearest hundredth where <m eval='on'>\[$base1^{$power1} = $base2^{$power2}\]</m>
<br /><endouttext />
<numericalresponse answer="$answer" format="2F">
<responseparam name="tol" type="tolerance" description="Numerical Tolerance" default="0.001" />
    <textline readonly="no" />
  
</numericalresponse>
</problem>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20120208/98af5337/attachment.html>


More information about the LON-CAPA-users mailing list