<!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>I guess the problem was that I had a fat minus sign in my equation, which Peter noticed:<BR>
<BR>
My hexeditor tells me that you are using &#x96; for a minus, while I am<BR>
using &#x2d;<BR>
<BR>
Retyping the minus sign fixed the problem.<BR>
<BR>
Thanks Peter.<BR>
<BR>
>From Seema.<BR>
<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: lon-capa-users-bounces@mail.lon-capa.org on behalf of Seema Ali<BR>
Sent: Wed 2/22/2012 7:06 AM<BR>
To: Peter Riegler; lon-capa-users@mail.lon-capa.org<BR>
Subject: Re: [LON-CAPA-users] Maxima is being fussy<BR>
<BR>
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:<BR>
<BR>
The function in the question is: 8+(x-15)^3.<BR>
The transformations are: vertical compression by 1/3 and a vertical translation 4 units down<BR>
<BR>
Formulas Maxima did not understand:<BR>
1/3(8 + (x-15)^3) – 4<BR>
(1/3)*(8 + (x-15)^3) – 4<BR>
1/3*(8 + (x-15)^3) – 4<BR>
(8 + (x-15)^3)/3 – 4<BR>
<BR>
This formula is understood sometimes:<BR>
8/3 + (x-15)^3)/3 – 4<BR>
At the moment it is not understanding it.<BR>
<BR>
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.<BR>
<BR>
The code below has the variables locked.<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>
$origA = 8;################################<BR>
$origB = 15;######################################<BR>
<BR>
#pick a function<BR>
$index = &random(1,3,1);<BR>
<BR>
<BR>
$index=2;###################################<BR>
<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>
<BR>
$compressionAmount = 3;##########################################<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>
<BR>
$translation = "vertical translation";#################################<BR>
$compression = "vertical compression";#################################<BR>
$translationAmount = 4;################################################<BR>
$translationDirection = "down";########################################<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>
<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>
@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 /><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>
<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(trigsimp(trigreduce(RESPONSE[1]))- trigsimp(trigreduce(g(x)))))=0);</answer><BR>
    <textline readonly="no" /><BR>
  <BR>
</mathresponse><BR>
</problem><BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>