[LON-CAPA-users] formula response and maxima floating point numbers
Justin Gray
lon-capa-users@mail.lon-capa.org
Sun, 19 Sep 2010 14:02:38 -0700
--001636920b8bd53a7c0490a31e97
Content-Type: text/plain; charset=ISO-8859-1
Hi Lon,
I cannot answer your question, but here are a few different ways that you
could code a problem to accept either sqrt(1.5) or sqrt(3/2) as correct
answers:
<problem>
<part>
<startouttext /><p><b>Formula Response with point sampling:</b></p><p>Solve
<m>$x^2 = 9/4$</m> for <m>$x > 0$</m>.</p>
<m>$x = $</m><endouttext />
<formularesponse answer="sqrt(3/2)" samples="x@1">
<responseparam description="Numerical Tolerance" type="tolerance"
default="0.01" name="tol" />
<textline readonly="no" />
</formularesponse>
</part>
<part>
<startouttext /><p><b>Formula Response with collection of
answers:</b></p><p>Solve <m>$x^2 = 9/4$</m> for <m>$x > 0$</m>.</p>
<m>$x = $</m><endouttext />
<formularesponse answer="sqrt(3/2)">
<answergroup type="ordered">
<answer name="floating point" type="ordered">
<value>sqrt(1.5)</value>
</answer>
</answergroup>
<textline readonly="no" />
<hintgroup showoncorrect="no">
<startouttext /><endouttext />
</hintgroup>
</formularesponse>
</part>
<part>
<startouttext /><p><b>Math Response with tolerance included in answer
algorithm:</b></p><p>Solve <m>$x^2 = 9/4$</m> for <m>$x > 0$</m>.</p>
<m>$x = $</m><endouttext />
<mathresponse cas="maxima" answerdisplay="sqrt(3/2)">
<answer>is(abs((RESPONSE[1]) - sqrt(3/2)) < 0.01);</answer>
<textline readonly="no" />
</mathresponse>
</part>
</problem>
Justin
Justin Gray | Senior Lecturer
Department of Mathematics | Simon Fraser University
8888 University Drive, Burnaby | V5A 1S6 | Canada
Tel: +1 778.782.4237
On Thu, Sep 9, 2010 at 6:54 AM, Lon H Mitchell <lmitchell2@vcu.edu> wrote:
> According to the Maxima manual, a shortcut to getting a floating point
> approximation to a function value is to use a decimal argument. For
> example, sqrt(2.0) will return 1.414213562373095 while sqrt(2) will stay as
> sqrt(2).
> This shortcut can result in some seemingly incomprehensible answers. For
> example, "is(sqrt(1.5) = sqrt(3/2))" returns /false/. Further, a formula
> response problem with answer "1+ sqrt(3/2)*x" will mark "1 + sqrt(1.5)*x" as
> incorrect and vice versa. Since the behavior is inherent to Maxima, math
> response problems can be similarly affected.
> Note that this behavior only seems to arise when dealing with a function
> value. For example, "x^(1.5)" and "x^(3/2)" are considered equivalent by
> Maxima, as are "1.5" and "3/2".
>
> While one possible solution is to use sampling rather than algebraic
> checking, my guess would be that sqrt(1.5) = sqrt(3/2) would be an expected
> equivalence on the part of most users.
>
> The question then: is there a way to instruct Maxima to turn this shortcut
> behavior off, and, if so, is it possible to change formula response problems
> (or lonmaxima) to make use of it?
>
> Thanks,
>
> Lon Mitchell
>
>
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>
--001636920b8bd53a7c0490a31e97
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div>Hi Lon,</div><div><br></div><div>I cannot answer your question, but he=
re are a few different ways that you could code a problem to accept either =
sqrt(1.5) or sqrt(3/2) as correct answers:</div><div><br></div><div><div>
<div><problem></div><div><part></div><div><startouttext />=
;<p><b>Formula Response with point sampling:</b></p>=
;<p>Solve <m>$x^2 =3D 9/4$</m> for <m>$x > 0$<=
;/m>.</p></div>
<div><m>$x =3D $</m><endouttext /></div><div><formular=
esponse answer=3D"sqrt(3/2)" samples=3D"x@1"></div><=
div>=A0=A0 =A0<responseparam description=3D"Numerical Tolerance&quo=
t; type=3D"tolerance" default=3D"0.01" name=3D"tol=
" /></div>
<div>=A0=A0 =A0 <textline =A0readonly=3D"no" /> =A0</div><d=
iv></formularesponse></div><div></part></div><div><part><=
/div><div><startouttext /><p><b>Formula Response with col=
lection of answers:</b></p><p>Solve <m>$x^2 =3D 9/4=
$</m> for <m>$x > 0$</m>.</p></div>
<div><m>$x =3D $</m><endouttext /></div><div><formular=
esponse answer=3D"sqrt(3/2)"></div><div>=A0=A0 =A0<answergr=
oup type=3D"ordered"></div><div>=A0=A0 =A0 =A0 =A0<answer n=
ame=3D"floating point" type=3D"ordered"></div>
<div>=A0=A0 =A0 =A0 =A0 =A0 =A0<value>sqrt(1.5)</value></div><d=
iv>=A0=A0 =A0 =A0 =A0</answer></div><div>=A0=A0 =A0</answergroup&g=
t; =A0 =A0 =A0 =A0</div><div>=A0=A0 =A0<textline =A0readonly=3D"no&=
quot; /></div><div>=A0=A0 =A0<hintgroup showoncorrect=3D"no"=
;></div>
<div>=A0=A0 =A0<startouttext /><endouttext /></div><div>=A0=A0 =
=A0</hintgroup></div><div></formularesponse></div><div></par=
t></div><div><part></div><div><startouttext /><p><b=
>Math Response with tolerance included in answer algorithm:</b><=
;/p><p>Solve <m>$x^2 =3D 9/4$</m> for <m>$x >=
0$</m>.</p></div>
<div><m>$x =3D $</m><endouttext /></div><div><mathresp=
onse cas=3D"maxima" answerdisplay=3D"sqrt(3/2)"></di=
v><div>=A0=A0 =A0<answer>is(abs((RESPONSE[1]) - sqrt(3/2)) < 0.01)=
;</answer></div>
<div>=A0=A0 =A0<textline readonly=3D"no" /> =A0=A0</div><di=
v></mathresponse></div><div></part></div><div></problem><=
/div></div></div><div><br></div><div>Justin</div><br clear=3D"all"><div>Jus=
tin Gray | Senior Lecturer</div>
Department of Mathematics | Simon Fraser University<br>8888 University Driv=
e, Burnaby | V5A 1S6 | Canada<br>Tel: +1 778.782.4237<br><div></div><br>
<br><br><div class=3D"gmail_quote">On Thu, Sep 9, 2010 at 6:54 AM, Lon H Mi=
tchell <span dir=3D"ltr"><<a href=3D"mailto:lmitchell2@vcu.edu">lmitchel=
l2@vcu.edu</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
According to the Maxima manual, a shortcut to getting a floating point appr=
oximation to a function value is to use a decimal argument. =A0For example,=
sqrt(2.0) will return 1.414213562373095 while sqrt(2) will stay as sqrt(2)=
. =A0<br>
This shortcut can result in some seemingly incomprehensible answers. =A0For=
example, "is(sqrt(1.5) =3D sqrt(3/2))" returns /false/. =A0Furth=
er, a formula response problem with answer "1+ sqrt(3/2)*x" will =
mark "1 + sqrt(1.5)*x" as incorrect and vice versa. =A0Since the =
behavior is inherent to Maxima, =A0math response problems can be similarly =
affected. =A0 =A0 <br>
Note that this behavior only seems to arise when dealing with a function va=
lue. =A0For example, "x^(1.5)" and "x^(3/2)" are consid=
ered equivalent by Maxima, as are "1.5" and "3/2".<br>
<br>
While one possible solution is to use sampling rather than algebraic checki=
ng, my guess would be that sqrt(1.5) =3D sqrt(3/2) would be an expected equ=
ivalence on the part of most users.<br>
<br>
The question then: is there a way to instruct Maxima to turn this shortcut =
behavior off, and, if so, is it possible to change formula response problem=
s (or lonmaxima) to make use of it?<br>
<br>
Thanks,<br>
<br>
Lon Mitchell<br>
<br>
<br>
_______________________________________________<br>
LON-CAPA-users mailing list<br>
<a href=3D"mailto:LON-CAPA-users@mail.lon-capa.org" target=3D"_blank">LON-C=
APA-users@mail.lon-capa.org</a><br>
<a href=3D"http://mail.lon-capa.org/mailman/listinfo/lon-capa-users" target=
=3D"_blank">http://mail.lon-capa.org/mailman/listinfo/lon-capa-users</a><br=
>
</blockquote></div><br>
--001636920b8bd53a7c0490a31e97--