<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>RE: [LON-CAPA-users] Maxima is being fussy</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Thanks Stefan.<BR>
<BR>
I don't really understand how the abs()<0.0000001 tolerance works for an algebraic expression.  So I decided to go nuts with the trigsimp() and trigreduce() functions.  I applied it to both functions and then did the subtraction and applied it again.<BR>
<BR>
is(trigsimp(trigreduce(trigsimp(trigreduce(RESPONSE[1]))- trigsimp(trigreduce(g(x)))))=0);<BR>
<BR>
It seems to be working, but is this approach full proof?<BR>
<BR>
Thanks.<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: lon-capa-users-bounces@mail.lon-capa.org on behalf of st.bisitz@ostfalia.de<BR>
Sent: Tue 2/21/2012 11:22 AM<BR>
To: lon-capa-users@mail.lon-capa.org<BR>
Subject: Re: [LON-CAPA-users] Maxima is being fussy<BR>
<BR>
Hi Seema,<BR>
<BR>
>  <mathresponse cas="maxima" args="@args" id="11"><BR>
>     <answer>f(x) := LONCAPALIST[1];<BR>
> a:LONCAPALIST[2];<BR>
> b:LONCAPALIST[3];<BR>
> c:LONCAPALIST[4];<BR>
> d:LONCAPALIST[5];<BR>
> g(x) := LONCAPALIST[2]*f(LONCAPALIST[3]*(x-LONCAPALIST[4]))+LONCAPALIST[5];<BR>
> is(trigsimp(trigreduce(RESPONSE[1]-g(x)))=0);</answer><BR>
<BR>
Don't forget about the tolerance! Comparing could be tricky.<BR>
The basic mathresponse template provides an example:<BR>
hitspoint:is(abs(y(LONCAPALIST[1]) - LONCAPALIST[2]) <= 0.000000001);<BR>
<BR>
Stefan Bisitz<BR>
<BR>
<BR>
<BR>
On 2012-02-21 19:13:24, Seema Ali wrote:<BR>
> Hi,<BR>
><BR>
> I have a graph transformation question, that recognizes correct answers most of the time.  I was wondering if it could recognize it all of the time.<BR>
><BR>
> Example: y = 8 + (x-12)^3<BR>
> New graph is vertically compressed by 1/3 and shifted horizontally to the left by 9 units.<BR>
><BR>
> A possible solution:  1/3 * (8 + (x -3)^3)<BR>
> This solutions was marked wrong as was:<BR>
> (8 + (x -3)^3)/3<BR>
><BR>
> The solution that was marked correctly was:<BR>
> 8/3 + ((x-3)^3)/3<BR>
><BR>
> I'm not sure why Maxima did not mark the other 2 correctly.  Below is the code for the problem.<BR>
><BR>
> Also is there something that I'm missing?  I am worried that for the algebra response questions that I created students may be marked incorrectly when they are right. <BR>
><BR>
> Thanks.<BR>
><BR>
><BR>
> <problem><BR>
> <script type="loncapa/perl">$origA = &random(5,9,1);<BR>
> $origB = &random(10,15,1);<BR>
> $origC = &random(16,20,1);<BR>
><BR>
> #pick a function<BR>
> $index = &random(1,3,1);<BR>
> $function = &choose($index, "sqrt($origA-(x-$origB)^2)",  "$origA + (x-$origB)^3", "$origA / (x-$origB) + $origC");<BR>
> $functionL= &choose($index, "\\sqrt{$origA-(x-$origB)^2}", "$origA + (x-$origB)^3", "\\Large\\frac{$origA}{x-$origB} \\normalsize + $origC");<BR>
><BR>
> #set the types of translations<BR>
> $temp = &random(1,2,1);<BR>
> $compression = &choose($temp,"horizontal ", "vertical ");<BR>
><BR>
> $temp = &random(1,2,1);<BR>
> $compression = $compression.&choose($temp,"expansion", "compression");<BR>
><BR>
> $compressionAmount = &random(2,9,1);<BR>
><BR>
><BR>
> $temp = &random(1,2,1);<BR>
> $translation = &choose($temp, "horizontal translation", "vertical translation");<BR>
><BR>
> $temp = &random(1,2,1)+ ($temp-1)*2;<BR>
> $translationDirection = &choose($temp, "left", "right", "up", "down");<BR>
><BR>
> do<BR>
> {<BR>
>    $translationAmount = &random(2,9,1);<BR>
> }while($compressionAmount==$translationAmount);<BR>
><BR>
><BR>
> #set the constants for $a and $b<BR>
> if($compression eq "horizontal expansion")<BR>
> {<BR>
>   $a = 1;<BR>
>   $b = 1/$compressionAmount;<BR>
>   $texcomp = $compressionAmount;<BR>
> }<BR>
> elsif($compression eq "horizontal compression")<BR>
> {<BR>
>   $a = 1;<BR>
>   $b = $compressionAmount;<BR>
>   $texcomp =  "\\frac{1}{$compressionAmount}";<BR>
> }<BR>
> elsif($compression eq "vertical compression")<BR>
> {<BR>
>   $a = 1/$compressionAmount;<BR>
>   $b = 1;<BR>
>   $texcomp = "\\frac{1}{$compressionAmount}";<BR>
> }<BR>
> else<BR>
> {<BR>
>   $a = $compressionAmount;<BR>
>   $b = 1;<BR>
>   $texcomp = $compressionAmount;<BR>
> }<BR>
><BR>
><BR>
> #set values to $c and $d<BR>
> if($translation eq "horizontal translation" && $translationDirection eq "left")<BR>
> {<BR>
>   $c = -1*$translationAmount;<BR>
>   $d = 0;<BR>
> }<BR>
> elsif($translation eq "horizontal translation" && $translationDirection eq "right")<BR>
> {<BR>
>   $c = $translationAmount;<BR>
>   $d = 0;<BR>
> }<BR>
> elsif($translation eq "vertical translation" && $translationDirection eq "up")<BR>
> {<BR>
>   $c = 0;<BR>
>   $d = $translationAmount;<BR>
> }<BR>
> elsif($translation eq "vertical translation" && $translationDirection eq "down")<BR>
> {<BR>
>   $c = 0;<BR>
>   $d = -1*$translationAmount;<BR>
> }<BR>
><BR>
><BR>
><BR>
><BR>
><BR>
><BR>
> @args = ($function, $a, $b, $c, $d);</script><startouttext /><p><BR>
> What is the equation of <m eval="on"> $ y= $functionL$ </m> after a<BR>
> $compression by a factor of <m eval="on">$ $texcomp $</m> and<BR>
> $translation $translationAmount units $translationDirection?<BR>
> </p><BR>
> Instructions:<BR>
> <ul><BR>
>   <li>Use * for multiplication, / for division, ^ for exponent and brackets</li><BR>
>   <li>For example to represent <m>$y=\Large\frac{(x^3-4)^5}{2}$</m>you would type: ((x^3-4)^5)/2</li><BR>
>   <li>If you enter a formula, double check your formula by clicking on the pencil icon to get a<BR>
>       different representation of your formula </li><BR>
>   <li>Another example to represent <m>$\sqrt{x^2+3} - 5$</m> you would type:  sqrt(x^2 + 3) - 5</li><BR>
> </ul><BR>
><BR>
><BR>
><BR>
><BR>
><BR>
> Answer:  <m>$y =$</m><endouttext /><BR>
> <mathresponse cas="maxima" args="@args" id="11"><BR>
>     <answer>f(x) := LONCAPALIST[1];<BR>
> a:LONCAPALIST[2];<BR>
> b:LONCAPALIST[3];<BR>
> c:LONCAPALIST[4];<BR>
> d:LONCAPALIST[5];<BR>
> g(x) := LONCAPALIST[2]*f(LONCAPALIST[3]*(x-LONCAPALIST[4]))+LONCAPALIST[5];<BR>
> is(trigsimp(trigreduce(RESPONSE[1]-g(x)))=0);</answer><BR>
>     <textline readonly="no" /><BR>
>    <BR>
> </mathresponse><BR>
> </problem><BR>
><BR>
><BR>
><BR>
> _______________________________________________<BR>
> LON-CAPA-users mailing list<BR>
> LON-CAPA-users@mail.lon-capa.org<BR>
> <A HREF="http://mail.lon-capa.org/mailman/listinfo/lon-capa-users">http://mail.lon-capa.org/mailman/listinfo/lon-capa-users</A><BR>
</FONT>
</P>

</BODY>
</HTML>