[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>&lt;problem&gt;</div><div>&lt;part&gt;</div><div>&lt;startouttext /&gt=
;&lt;p&gt;&lt;b&gt;Formula Response with point sampling:&lt;/b&gt;&lt;/p&gt=
;&lt;p&gt;Solve &lt;m&gt;$x^2 =3D 9/4$&lt;/m&gt; for &lt;m&gt;$x &gt; 0$&lt=
;/m&gt;.&lt;/p&gt;</div>

<div>&lt;m&gt;$x =3D $&lt;/m&gt;&lt;endouttext /&gt;</div><div>&lt;formular=
esponse answer=3D&quot;sqrt(3/2)&quot; samples=3D&quot;x@1&quot;&gt;</div><=
div>=A0=A0 =A0&lt;responseparam description=3D&quot;Numerical Tolerance&quo=
t; type=3D&quot;tolerance&quot; default=3D&quot;0.01&quot; name=3D&quot;tol=
&quot; /&gt;</div>

<div>=A0=A0 =A0 &lt;textline =A0readonly=3D&quot;no&quot; /&gt; =A0</div><d=
iv>&lt;/formularesponse&gt;</div><div>&lt;/part&gt;</div><div>&lt;part&gt;<=
/div><div>&lt;startouttext /&gt;&lt;p&gt;&lt;b&gt;Formula Response with col=
lection of answers:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Solve &lt;m&gt;$x^2 =3D 9/4=
$&lt;/m&gt; for &lt;m&gt;$x &gt; 0$&lt;/m&gt;.&lt;/p&gt;</div>

<div>&lt;m&gt;$x =3D $&lt;/m&gt;&lt;endouttext /&gt;</div><div>&lt;formular=
esponse answer=3D&quot;sqrt(3/2)&quot;&gt;</div><div>=A0=A0 =A0&lt;answergr=
oup type=3D&quot;ordered&quot;&gt;</div><div>=A0=A0 =A0 =A0 =A0&lt;answer n=
ame=3D&quot;floating point&quot; type=3D&quot;ordered&quot;&gt;</div>

<div>=A0=A0 =A0 =A0 =A0 =A0 =A0&lt;value&gt;sqrt(1.5)&lt;/value&gt;</div><d=
iv>=A0=A0 =A0 =A0 =A0&lt;/answer&gt;</div><div>=A0=A0 =A0&lt;/answergroup&g=
t; =A0 =A0 =A0 =A0</div><div>=A0=A0 =A0&lt;textline =A0readonly=3D&quot;no&=
quot; /&gt;</div><div>=A0=A0 =A0&lt;hintgroup showoncorrect=3D&quot;no&quot=
;&gt;</div>

<div>=A0=A0 =A0&lt;startouttext /&gt;&lt;endouttext /&gt;</div><div>=A0=A0 =
=A0&lt;/hintgroup&gt;</div><div>&lt;/formularesponse&gt;</div><div>&lt;/par=
t&gt;</div><div>&lt;part&gt;</div><div>&lt;startouttext /&gt;&lt;p&gt;&lt;b=
&gt;Math Response with tolerance included in answer algorithm:&lt;/b&gt;&lt=
;/p&gt;&lt;p&gt;Solve &lt;m&gt;$x^2 =3D 9/4$&lt;/m&gt; for &lt;m&gt;$x &gt;=
 0$&lt;/m&gt;.&lt;/p&gt;</div>

<div>&lt;m&gt;$x =3D $&lt;/m&gt;&lt;endouttext /&gt;</div><div>&lt;mathresp=
onse cas=3D&quot;maxima&quot; answerdisplay=3D&quot;sqrt(3/2)&quot;&gt;</di=
v><div>=A0=A0 =A0&lt;answer&gt;is(abs((RESPONSE[1]) - sqrt(3/2)) &lt; 0.01)=
;&lt;/answer&gt;</div>

<div>=A0=A0 =A0&lt;textline readonly=3D&quot;no&quot; /&gt; =A0=A0</div><di=
v>&lt;/mathresponse&gt;</div><div>&lt;/part&gt;</div><div>&lt;/problem&gt;<=
/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">&lt;<a href=3D"mailto:lmitchell2@vcu.edu">lmitchel=
l2@vcu.edu</a>&gt;</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, &quot;is(sqrt(1.5) =3D sqrt(3/2))&quot; returns /false/. =A0Furth=
er, a formula response problem with answer &quot;1+ sqrt(3/2)*x&quot; will =
mark &quot;1 + sqrt(1.5)*x&quot; 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, &quot;x^(1.5)&quot; and &quot;x^(3/2)&quot; are consid=
ered equivalent by Maxima, as are &quot;1.5&quot; and &quot;3/2&quot;.<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--