[LON-CAPA-users] Maxima is being fussy

Seema Ali sali at vsb.bc.ca
Tue Feb 21 18:56:53 EST 2012


Thanks Stefan.

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.

is(trigsimp(trigreduce(trigsimp(trigreduce(RESPONSE[1]))- trigsimp(trigreduce(g(x)))))=0);

It seems to be working, but is this approach full proof?

Thanks.


-----Original Message-----
From: lon-capa-users-bounces at mail.lon-capa.org on behalf of st.bisitz at ostfalia.de
Sent: Tue 2/21/2012 11:22 AM
To: lon-capa-users at mail.lon-capa.org
Subject: Re: [LON-CAPA-users] Maxima is being fussy
 
Hi Seema,

>  <mathresponse cas="maxima" args="@args" id="11">
>     <answer>f(x) := LONCAPALIST[1];
> a:LONCAPALIST[2];
> b:LONCAPALIST[3];
> c:LONCAPALIST[4];
> d:LONCAPALIST[5];
> g(x) := LONCAPALIST[2]*f(LONCAPALIST[3]*(x-LONCAPALIST[4]))+LONCAPALIST[5];
> is(trigsimp(trigreduce(RESPONSE[1]-g(x)))=0);</answer>

Don't forget about the tolerance! Comparing could be tricky.
The basic mathresponse template provides an example:
hitspoint:is(abs(y(LONCAPALIST[1]) - LONCAPALIST[2]) <= 0.000000001);

Stefan Bisitz



On 2012-02-21 19:13:24, Seema Ali wrote:
> Hi,
> 
> 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.
> 
> Example: y = 8 + (x-12)^3
> New graph is vertically compressed by 1/3 and shifted horizontally to the left by 9 units.
> 
> A possible solution:  1/3 * (8 + (x -3)^3)
> This solutions was marked wrong as was:
> (8 + (x -3)^3)/3
> 
> The solution that was marked correctly was:
> 8/3 + ((x-3)^3)/3
> 
> I'm not sure why Maxima did not mark the other 2 correctly.  Below is the code for the problem. 
> 
> 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.  
> 
> Thanks.
> 
> 
> <problem>
> <script type="loncapa/perl">$origA = &random(5,9,1);
> $origB = &random(10,15,1);
> $origC = &random(16,20,1);
> 
> #pick a function
> $index = &random(1,3,1);
> $function = &choose($index, "sqrt($origA-(x-$origB)^2)",  "$origA + (x-$origB)^3", "$origA / (x-$origB) + $origC");
> $functionL= &choose($index, "\\sqrt{$origA-(x-$origB)^2}", "$origA + (x-$origB)^3", "\\Large\\frac{$origA}{x-$origB} \\normalsize + $origC");
> 
> #set the types of translations
> $temp = &random(1,2,1);
> $compression = &choose($temp,"horizontal ", "vertical ");
> 
> $temp = &random(1,2,1);
> $compression = $compression.&choose($temp,"expansion", "compression");
> 
> $compressionAmount = &random(2,9,1);
> 
> 
> $temp = &random(1,2,1);
> $translation = &choose($temp, "horizontal translation", "vertical translation");
> 
> $temp = &random(1,2,1)+ ($temp-1)*2;
> $translationDirection = &choose($temp, "left", "right", "up", "down");
> 
> do
> {
>    $translationAmount = &random(2,9,1);
> }while($compressionAmount==$translationAmount);
> 
> 
> #set the constants for $a and $b
> if($compression eq "horizontal expansion")
> {
>   $a = 1;
>   $b = 1/$compressionAmount;
>   $texcomp = $compressionAmount;
> }
> elsif($compression eq "horizontal compression")
> {
>   $a = 1;
>   $b = $compressionAmount;
>   $texcomp =  "\\frac{1}{$compressionAmount}";
> }
> elsif($compression eq "vertical compression")
> {
>   $a = 1/$compressionAmount;
>   $b = 1;
>   $texcomp = "\\frac{1}{$compressionAmount}";
> }
> else
> {
>   $a = $compressionAmount;
>   $b = 1;
>   $texcomp = $compressionAmount;
> }
> 
> 
> #set values to $c and $d
> if($translation eq "horizontal translation" && $translationDirection eq "left")
> {
>   $c = -1*$translationAmount;
>   $d = 0;
> }
> elsif($translation eq "horizontal translation" && $translationDirection eq "right")
> {
>   $c = $translationAmount;
>   $d = 0;
> }
> elsif($translation eq "vertical translation" && $translationDirection eq "up")
> {
>   $c = 0;
>   $d = $translationAmount;
> }
> elsif($translation eq "vertical translation" && $translationDirection eq "down")
> {
>   $c = 0;
>   $d = -1*$translationAmount;
> }
> 
> 
> 
> 
> 
> 
> @args = ($function, $a, $b, $c, $d);</script><startouttext /><p>
> What is the equation of <m eval="on"> $ y= $functionL$ </m> after a 
> $compression by a factor of <m eval="on">$ $texcomp $</m> and
> $translation $translationAmount units $translationDirection?
> </p>
> Instructions: 
> <ul>
>   <li>Use * for multiplication, / for division, ^ for exponent and brackets</li>
>   <li>For example to represent <m>$y=\Large\frac{(x^3-4)^5}{2}$</m>you would type: ((x^3-4)^5)/2</li>
>   <li>If you enter a formula, double check your formula by clicking on the pencil icon to get a 
>       different representation of your formula </li>
>   <li>Another example to represent <m>$\sqrt{x^2+3} - 5$</m> you would type:  sqrt(x^2 + 3) - 5</li>
> </ul>
> 
> 
> 
> 
> 
> Answer:  <m>$y =$</m><endouttext />
> <mathresponse cas="maxima" args="@args" id="11">
>     <answer>f(x) := LONCAPALIST[1];
> a:LONCAPALIST[2];
> b:LONCAPALIST[3];
> c:LONCAPALIST[4];
> d:LONCAPALIST[5];
> g(x) := LONCAPALIST[2]*f(LONCAPALIST[3]*(x-LONCAPALIST[4]))+LONCAPALIST[5];
> is(trigsimp(trigreduce(RESPONSE[1]-g(x)))=0);</answer>
>     <textline readonly="no" />
>     
> </mathresponse>
> </problem>
> 
> 
> 
> _______________________________________________
> 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/20120221/62180890/attachment.html>


More information about the LON-CAPA-users mailing list