<!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] Having an equation or a range as a response</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Gerd,<BR>
<BR>
I tested tried it out and it looks good.  Where can I get a list of Maxima questions that Lon Capa uses?  I listed the test cases that I used:<BR>
<BR>
x=0   (for these I forced 0 to be a solution to try it out)<BR>
0=x<BR>
<BR>
2*x = 10<BR>
10 = 2*x<BR>
<BR>
x=5<BR>
5=x<BR>
<BR>
2x+9=19<BR>
19=2x+9<BR>
<BR>
y=4*x<BR>
x = 0.25*y<BR>
4x -y = 0<BR>
<BR>
I probably didn't have to test out the equations that are "mirror" images (along the equal sing) of a successful equation, but I thought I'd do it anyways, since  I am not familiar with trigsimp and trigreduce.<BR>
<BR>
Thanks this is awesome!<BR>
<BR>
-----Original Message-----<BR>
From: lon-capa-users-bounces@mail.lon-capa.org on behalf of Gerd Kortemeyer<BR>
Sent: Sat 1/21/2012 7:52 PM<BR>
To: Discussion list for LON-CAPA users<BR>
Subject: Re: [LON-CAPA-users] Having an equation or a range as a response<BR>
<BR>
Hi,<BR>
<BR>
On Jan 20, 2012, at 1:49 PM, Seema Ali wrote:<BR>
<BR>
> I'm also super new to Maxima, but can it factor out constants from an expression?  Or could you create a fraction between the left and right side, reduce it and then see if it is the simplified version? Of course being carfeul not to divide by zero.<BR>
<BR>
I think I got it, please test. If this is good, I might turn it into a template and/or a new responsetype.<BR>
<BR>
Gotta love MAXIMA :-)<BR>
<BR>
- Gerd.<BR>
<BR>
<problem><BR>
<script type="loncapa/perl"><BR>
$a=&random(3,8,1);<BR>
$b=$a+&random(2,5,1);<BR>
$sample="x=$b or y=$a*x would be correct";<BR>
<BR>
sub compareequations {<BR>
    my ($var,$value,$equation)=@_;<BR>
# var is the variable given<BR>
# value is the expected value of $var, $var=$value<BR>
# equation is the equation to be tested<BR>
    $expressiona='trigsimp(trigreduce(['.$var.'='.$value.']))';<BR>
    $expressionb='trigsimp(trigreduce(solve('.$equation.','.$var.')))';<BR>
    $reply=&cas('maxima','is(equal('.$expressiona.','.$expressionb.'))');<BR>
    if ($reply=~/^Error\:/) { return $reply; }<BR>
    if ($reply=~/true/) { return 'true'; }<BR>
    return 'false';<BR>
}<BR>
</script><BR>
<BR>
<startouttext /><BR>
Given an equation for an asymptote of <m eval="on">\[y=$a\cdot x+\frac{1}{x-$b}\]</m><BR>
<endouttext /><BR>
<BR>
<customresponse answerdisplay="$sample"><BR>
<BR>
<answer type="loncapa/perl"><BR>
$first=&compareequations('y',"$a*x",$submission);<BR>
if ($first=~/^Error/) { return 'BAD_FORMULA'; }<BR>
if ($first=~/true/) { return 'EXACT_ANS'; }<BR>
<BR>
$second=&compareequations('x',$b,$submission);<BR>
if ($second=~/^Error/) { return 'BAD_FORMULA'; }<BR>
if ($second=~/true/) { return 'EXACT_ANS'; }<BR>
<BR>
return 'INCORRECT';</answer><BR>
<BR>
    <textline readonly="no" /><BR>
</customresponse><BR>
<BR>
</problem><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>
<BR>
</FONT>
</P>

</BODY>
</HTML>