# [LON-CAPA-users] square roots in formula response

Peter Riegler lon-capa-users@mail.lon-capa.org
Tue, 04 Sep 2007 14:12:09 +0200

Hi Justin,

Justin Gray wrote:

> Hi Peter,
>
> Are you sure that Maxima does not simplify expressions when comparing
> them?

ahm, well, sorry, no.

What's PRECISELY going on is the following:
lonmaxima, loncapa's interface to maxima, inputs
to maxima. Here, RESPONSE is the student's response, ANSWER the correct

In the example you have given maxima would not simplify
to zero, but applying trigreduce will do so.
Obviously trigreduce includes some sort of rational simplification which
affects your example but doesn't affect the one with the sqrt you had
given yesterday.

When it comes to simplification I have to confess that I only have a gut
feeling which command will have which effects. Basically this is based
on my experience with these commands, but I am still lacking a thorough
understanding.

Also this issue here brings up my uneasy feelings that lonmaxima's
is not a good idea. It should be
If an author wishes/needs to have simplification it should be his task
to put in the proper/desired command using the 2nd interface called
mathresponse.

While I am typing this, Gerd's email on this issue is coming in.

In general, I agree with Gerd's view. Here in my group we are struggling
almost every day with solving that "make sure that the original problem
sometimes, sometimes it's proper use of simplification commands or a
combination of both.

What I am dreaming of is investigating the tree representation of the
expression under investigation (such as Mathematica's FullForm returns)
and decide on this tree whether the student's answer is simple enough.

Anyway, here is how I would solve the current problem given my current
knowledge of maxima:

<problem>
<script type="loncapa/perl">
$answer = "(x^2 + 3)/((x + 3)(x^2 + 9))"; </script> <startouttext /> Simplify: <p></p> <m>$\Large{\frac{x^3 - 3x^2 + 3x - 9}{x^4 - 81}} = $</m> <endouttext /> <mathresponse cas="maxima" answerdisplay="$answer" args="$answer"> <answer> is(RESPONSE=LONCAPALIST); </answer> <textline readonly="no" size="40" /> </mathresponse> </problem> Note however, that this will not accept responses where products are expanded. To allow that you would have to use e.g. is(factor(RESPONSE)=LONCAPALIST); the args attribute will pass a perl array to a maxima array named LONCAPALIST (technically this is not quite true, but details are not important here). Finally I give another version which I call the "lazy programmer's solution": <problem> <script type="loncapa/perl">$fun = "(x^3 - 3*x^2 + 3*x - 9)/(x^4 - 81)";
$answer = &cas("maxima","factor(ratsimp($fun));");
</script>
<startouttext />
Simplify: <p></p>

<m>$\Large{\frac{x^3 - 3x^2 + 3x - 9}{x^4 - 81}} =$</m>
<endouttext />

<mathresponse cas="maxima" answerdisplay="$answer" args="$answer">
is(RESPONSE=LONCAPALIST);
</mathresponse>
</problem>

Have fun with it

Peter

I was under the impression that Maxima tries to simplify the
> difference of two equivalent expressions and verify that it is zero.
> Consider the following problem.
>
> <problem>
>     <startouttext />
> Simplify: <p></p>
>
> <m display = jsmath>$\Large{\frac{x^3 - 3x^2 + 3x - 9}{x^4 - 81}} =$</m>
>     <endouttext />
>
>     <formularesponse answer="(x^2 + 3)/((x + 3)(x^2 + 9))">
>     </formularesponse>
> </problem>
>
> This appears to accept the LHS as a correct answer.
>
> Thanks,
> Justin
>
> On 9/3/07, *Justin Gray* <jgray@math.sfu.ca <mailto:jgray@math.sfu.ca>>
> wrote:
>
>     Many thanks, Peter. This is exactly what I was looking for.
>
>     Justin
>
>
>     On 9/3/07, * Peter Riegler* <p.riegler@fh-wolfenbuettel.de
>     <mailto:p.riegler@fh-wolfenbuettel.de>> wrote:
>
>         Hi Justin,
>
>         does "elegant" include two seperate input fields, for
>         demoninator and
>         numerator? Or did you come up with two input fields because
>         otherwise
>         the lhs (i.e. non-rationalized) would be accepted if using sampling?
>         If so, I would suggest something like
>         <formularesponse answer="(m - 4)*(sqrt(m) + 4)/(m-16)">
>
>         (I would prefer the students enter sqrt(m) rather than sqrtm).
>
>         What the above does is to ask maxima
>         is( STUDENTSRESPONSE = (m - 4)*(sqrt(m) + 4)/(m-16));
>
>         The important point here is that a student's reponse
>         (m-4)/(sqrt(m)-4)
>         would return false. The reason is, maxima does not simplify before
>         comparison.
>
>         Hope this will help.
>
>         Peter
>
>         Justin Gray wrote:
>
>>  Does anyone know a more elegant way to write the problem below?
>>
>>  Thanks,
>>  Justin
>>
>>  <problem>
>>  <startouttext />Rationalize the denominator and
>         simplify:<p></p><br></br>
>>  Use sqrtm for <m display = jsmath>$\sqrt{m}</m>.<p></p> >> <table> >> >> <tr> >> <td><m display="jsMath">\, \, \, \,$m - 4$</m></td> <td></td> >> <td><endouttext /> >> <formularesponse samples="m,sqrtm@-3,-3:3,3#5" answer="(m - > 4)(sqrtm + >> 4)" id="11"> >> >> <textline readonly="no" size="20" /> >> >> </formularesponse><startouttext /></td> >> </tr> >> <tr> >> <td><hr width="60"></hr></td> <td><m > display="jsMath">$\mbox{ } =
>>  \mbox{ }$</m></td> <td><hr width="140"></hr></td> >> </tr> >> <tr> >> <td><m display="jsMath">$\sqrt{m} - 4\$</m></td> <td></td>
>>  <td><endouttext />
>>  <formularesponse samples="m@-3:3#5" answer="m - 16" id="12">
>>
>>
>>  </formularesponse><startouttext /></td>
>>  </tr>
>>  </table><p></p><endouttext />
>>  </problem>
>>
>>
>>  --
>>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>  Justin Gray                                                  Tel.
>>  778-782-4237
>>  Dept. of Mathematics                                   Fax.
>         778-782-4947
>>  Simon Fraser University
>>  8888 University Drive
>>  Burnaby, B.C. V5A 1S6
>>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>         --
>         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
>         <mailto:p.riegler@fh-wolfenbuettel.de>
>         http://public.rz.fh-wolfenbuettel.de/~riegler
>         <http://public.rz.fh-wolfenbuettel.de/%7Eriegler>
>         _______________________________________________
>         LON-CAPA-users mailing list
>         LON-CAPA-users@mail.lon-capa.org
>         <mailto:LON-CAPA-users@mail.lon-capa.org>
>         http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>
>
>
>
>     --
>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>     Justin Gray                                                  Tel.
>     778-782-4237
>     Dept. of Mathematics                                   Fax. 778-782-4947
>     Simon Fraser University
>     8888 University Drive
>     Burnaby, B.C. V5A 1S6
>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Justin Gray                                                  Tel.
> 778-782-4237
> Dept. of Mathematics                                   Fax. 778-782-4947
> Simon Fraser University
> 8888 University Drive
> Burnaby, B.C. V5A 1S6