[LON-CAPA-users] Maxima is being fussy
Seema Ali
sali at vsb.bc.ca
Wed Feb 22 10:06:36 EST 2012
Thanks guys. I made the changes that Peter suggested, passing the fraction instead of the decimal value to Maxima. I even put brackets around the fraction to make sure the correct order of operations was applied. However, now it is unable to understand the formulas I'm entering (with or without the brackets). I locked the variables to control the test case and I noticed once it accepted my answer and another time it didn't. Below are the values I entered:
The function in the question is: 8+(x?15)^3.
The transformations are: vertical compression by 1/3 and a vertical translation 4 units down
Formulas Maxima did not understand:
1/3(8 + (x-15)^3) – 4
(1/3)*(8 + (x-15)^3) – 4
1/3*(8 + (x-15)^3) – 4
(8 + (x-15)^3)/3 – 4
This formula is understood sometimes:
8/3 + (x-15)^3)/3 – 4
At the moment it is not understanding it.
If it is having so many problems with what I'm entering, then I think the problem should be with my code. But the Maxima part is still the same, with a couple of extra trigsimp(trigreduce()) stuff. It was working earlier for other cases. So I'm not sure what I'm doing wrong.
The code below has the variables locked.
<problem>
<script type="loncapa/perl">$origA = &random(5,9,1);
$origB = &random(10,15,1);
$origC = &random(16,20,1);
$origA = 8;################################
$origB = 15;######################################
#pick a function
$index = &random(1,3,1);
$index=2;###################################
$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);
$compressionAmount = 3;##########################################
$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);
$translation = "vertical translation";#################################
$compression = "vertical compression";#################################
$translationAmount = 4;################################################
$translationDirection = "down";########################################
#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: <br />
<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>
<br />
<br />
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(trigsimp(trigreduce(RESPONSE[1]))- trigsimp(trigreduce(g(x)))))=0);</answer>
<textline readonly="no" />
</mathresponse>
</problem>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20120222/700c1e67/attachment.html>
More information about the LON-CAPA-users
mailing list