# [LON-CAPA-users] Code to accept multiple answers

Justin Gray jgray at math.sfu.ca
Wed Jun 17 20:23:34 EDT 2015

One could also do this using mathresponse with the same idea to define
ln(x):=log(x)

<problem>

<script type="loncapa/perl">
$answer=4*log(1/2); </script> <startouttext /> <p>Enter an answer equivalent to <m>$4*\ln(1/2)$</m>.</p> <endouttext /> <mathresponse answerdisplay="4*ln(1/2)" cas="maxima" args="$answer">
is ( trigsimp(trigreduce(RESPONSE[1] - LONCAPALIST[1])) < 0.000001

</mathresponse>
</problem>

This accepts 4*ln(1/2), 4*log(1/2), 4*(ln(1) - ln(2)), ln(1/2^4), etc,...

This problem has no randomization, but could be modified. (In this case you
may need to pass any random parameters to Maxima using an argument array.)
What is it that you are asking students to calculate?

Justin

Justin Gray | Senior Lecturer
Department of Mathematics | Simon Fraser University
8888 University Drive, Burnaby | V5A 1S6 | Canada
Tel: +1 778.782.4237

On Wed, Jun 17, 2015 at 11:05 AM, Peter Dencker <dencker at math.uni-luebeck.de
> wrote:

>
>
> Hi David,
>
> define 'ln(x):=log(x)'. (See my example below.)
>
> The maxima function  'radcan' simplifies expressions in maxima, which can
> contain logs, exponentials, and radicals, so it may helpful. (It is not
> needed in your specific example but can help to compare more subtle
> examples.
>
> - Peter
>
> <problem>
>
> <script type="loncapa/perl">
>   our $result = "4*ln(1/2)"; > </script> > > <part id="p0"> > <customresponse id="p0r0"> > <textline /> > <answer type="loncapa/perl"> > my$given      = implicit_multiplication($submission); > my$maxima_in  = "ln(x):=log(x);is(rat(radcan($result-($given)))=0)";
>       my $evaluation = cas( 'maxima',$maxima_in );
>       return 'EXACT_ANS' if $evaluation eq 'true'; > return 'INCORRECT' if$evaluation eq 'false';
> </customresponse>
> </part>
>
> </problem>
>
>
>
>
>
> Am 06/17/2015 um 05:45 PM schrieb Huckleberry, David W:
>
>> 4*(ln(1) - ln(2))
>>
>
>
> --
> Dr. Peter Dencker
>     wissenschaftl. Mitarbeiter
>
> UNIVERSITÄT ZU LÜBECK
>     INSTITUT FÜR MATHEMATIK
>
>     Ratzeburger Allee 160
>     23562 Lübeck
>
>     Tel +49 451 500 4254
>     Fax +49 451 500 3373
>     dencker at math.uni-luebeck.de
>
>     www.math.uni-luebeck.de
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users at mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20150617/c9bda0ba/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SFU_2012_email_sig.jpg
Type: image/jpeg
Size: 8910 bytes
Desc: not available
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20150617/c9bda0ba/attachment-0001.jpg>