# [LON-CAPA-users] formula response question

Peter Riegler lon-capa-users@mail.lon-capa.org
Sun, 22 Feb 2009 07:59:38 +0100

Hi,

I have tested your code on my 2.8 server:
The problem is related to the +-2 in
$solution=7*exp(2*x)+-2*exp(-1*-7/4*x) . So you should write$solution="$M1*exp($d*x)+($M2)*exp(-1*$b/$a*x) in your script. Note the parentheses around$M2.
I can't explain that to you perlwise because "...+-2*..." is legal perl.
As your script is written $M2 becomes negative very infrequently, hence you don't encounter such problems often. Peter James Mueller wrote: > A student in a calculus course is entering an answer to a formula > response problem and keeps getting "Unable to understand formula" even > when they enter something simple like "x" for their answer. The rest > of the students are reported to be not having troubles. I assumed it > must be some problem with the script tat was triggered by the numbers > used for this particular problem. After a quick look, I can't see > anything, but I have to admit my perl is rusty. Anybody else se anything? > > The script is > > <problem> > <meta name="isbasedontime" content="1235265561" /> > <meta name="isbasedonres" content="\%2fres\%2fpitt\%2fathanas\%2fc2\ > %2ddiffeq\%2d21\%2eproblem" /> > <script type="loncapa/perl"> >$b=0; $d=0; while($b==0 || $d==0){$b=&random(-10,10,1);
> $d=&random(-10,10,1);} >$a=-1*$b/$d; while($a==-1*$b/$d){$a=&random(1,10,1);}
> $c=&random(1,10,1);$i=&random(1,50,1);
> if($b<0){$s=" ";} if($b>0){$s="+";}
> $M1=$c/($a*$d+$b);$M2=$i-$M1;
> $solution="$M1*exp($d*x)+$M2*exp(-1*$b/$a*x) ";
>  </script>
>  <startouttext />
> <br />
> Determine the solution to the initial value differential equation <m
> eval="on"> $a y' s b y = c e^{d x} \hspace{.2in} y ( 0 )= i >$</m>
> <endouttext />
>
> <p />
> <startouttext /><m>$y ( x ) =$</m><endouttext />
> <formularesponse samples="x@1:3#4" answer="$solution" id="11"> > <responseparam name="tol" default="0.001" type="tolerance" > description="Numerical Tolerance" /> > <textline readonly="no" size="35" /> > </formularesponse> > </problem> > > And the students variables for this problem are > > %! > =(E2BIG=>0,EACCES=>0,EADDRINUSE=>0,EADDRNOTAVAIL=>0,EAD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=>0,EOVERFLOW=>0,EOWNERDEAD=>0,EPERM=>0,EPFNOSUPPORT=>0,EPIPE=>0,EPROTO=>0,EPROTONOSUPPORT=>0,EPROTOTYPE=>0,ERANGE=>0,EREMCHG=>0,EREMOTE=>0,EREMOTEIO=>0,ERESTART=>0,EROFS=>0,ESHUTDOWN=>0,ESOCKTNOSUPPORT=>0,ESPIPE=>0,ESRCH=>0,ESRMNT=>0,ESTALE=>0,ESTRPIPE=>0,ETIME=>0,ETIMEDOUT=>0,ETOOMANYREFS=>0,ETXTBSY=>0,EUCLEAN=>0,EUNATCH=>0,EUSERS=>0,EWOULDBLOCK=>0,EXDEV=>0,EXFULL=>0) > >$M1=7
> $M2=-2 >$a=4
> $b=-7 >$c=7
> $d=2 >$deg2rad=0.0174532925199433
> $i=5 >$pi=3.14159265358979
> $rad2deg=57.2957795130823 >$s=
> \$solution=7*exp(2*x)+-2*exp(-1*-7/4*x)
>
>
>
>
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users

--
Peter Riegler
Fachhochschule Braunschweig/Wolfenbüttel
Salzdahlumer Str. 46/48, 38302 Wolfenbüttel
Tel. +49 5331 939 6314, Fax. +49 5331 939 6002
email: p.riegler@fh-wolfenbuettel.de
http://public.rz.fh-wolfenbuettel.de/~riegler