<!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] Forcing a sigma solution</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Hi,<BR>
<BR>
I'm not sure how to extract information from an ordered triple.  I'm also concerned that students might have a hard time entering the 3 pieces of information correctly.  So I tried to implement Justin's idea in a different way by having 3 textboxes, however each text box requires an answer and I would like to use the Math Response to see of a small set of conditions have been satisfied to determine if the response is correct.  I also don't really know how to extract the 3 pieces of information and am hoping that RESPONSE[1], RESPONSE[2] AND RESPONSE[3] can be used for the 3 text boxes.<BR>
<BR>
Below is a copy of the problem with the 3 textboxes.  I'm stuck on the coding part. If anyone has a similar question that uses information from a few different textboxes to see if the answer is correct or another way to implement this type of question and is willing to share, I'd greatly appreciate it.<BR>
<BR>
Thanks.<BR>
<BR>
<BR>
<BR>
<problem><BR>
<script type="loncapa/perl">$base      = &random(2,6,1);<BR>
$exponent  = &random(2,3,1);<BR>
<BR>
$firstterm = &random(-1,1,2)* $base;<BR>
$numterms  = &random(5,9,1);<BR>
$termstyle = &random(0,1,1); #determine if the term is base^n(-1)^m, or mn(-1)^p<BR>
<BR>
#$termstyle = 0;<BR>
<BR>
$term = $firstterm;<BR>
$sumdisplay  = $term;<BR>
$total = $firsterm;<BR>
<BR>
#calculate the answer<BR>
$answer = &choose($termstyle+1, "sum((-$base)^n,n,1,$numterms)","sum($base*n*(-1)^n,n,1,$numterms)");<BR>
<BR>
<BR>
if($firstterm>0)<BR>
{<BR>
  $answer = "-1*".$answer;<BR>
}<BR>
<BR>
<BR>
<BR>
for($i=1; $i<$numterms-1; $i++)<BR>
{<BR>
  if($term>0)<BR>
  {<BR>
    $sumdisplay .= ' - ';<BR>
  }<BR>
  else<BR>
  {<BR>
    $sumdisplay .= ' + ';<BR>
  }<BR>
 <BR>
  if($termstyle==0)<BR>
  {<BR>
    $term*= -1 * $base;         #term = base^n<BR>
   <BR>
  }<BR>
  else<BR>
  {<BR>
    #$term = (-1)**($i) * $base *($i+1 ); #term = mn(-1)^n<BR>
   if($firstterm>0)<BR>
   {<BR>
      $term =(-1)**($i) * $base *($i+1 ); #term = mn(-1)^n<BR>
<BR>
   }<BR>
   else<BR>
   {<BR>
      $term =(-1)**($i+1) * $base *($i+1 ); #term = mn(-1)^n<BR>
   }<BR>
<BR>
<BR>
  }<BR>
  $total += $term;<BR>
  $sumdisplay .= abs($term);<BR>
}<BR>
<BR>
  if($term>0)<BR>
  {<BR>
    $sumdisplay .= ' - ';<BR>
  }<BR>
  else<BR>
  {<BR>
    $sumdisplay .= ' + ';<BR>
  }<BR>
<BR>
  if($termstyle==0)<BR>
  {<BR>
    #$term = (-1*$base)**($numterms);  #term = base^n<BR>
    $term *= -1*$base;<BR>
  }<BR>
  else<BR>
  {<BR>
    $term = (-1)**($numterms) * $base*($numterms);  #term = mn(-1)^n<BR>
  }<BR>
<BR>
  $sumdisplay .= abs($term);<BR>
  $total += $term;</script><startouttext /><instructions></instructions><endouttext /><startouttext /><m eval='on'>\[ \Large $sumdisplay \]</m><BR>
base=$base <br /><BR>
numterm=$numterms <br /><BR>
total = $total<br /><BR>
style = $termstyle<br /><BR>
answer = $answer<br /><BR>
<BR>
<table><BR>
<tr><BR>
<td align='right'><endouttext /><BR>
<numericalresponse answer=""><BR>
<BR>
<BR>
    <textline readonly="no" size="3" /><BR>
   <BR>
</numericalresponse><startouttext /></td><BR>
<td></td><BR>
</tr><BR>
<tr><BR>
<td><BR>
<m>\[ \Huge\Sigma \]</m><BR>
</td><BR>
<td><endouttext /><BR>
<mathresponse cas="maxima"><BR>
    <answer>is(RESPONSE[1]=1);</answer><BR>
    <textline readonly="no" /><BR>
   <BR>
</mathresponse><startouttext /></td><BR>
</tr><BR>
<tr><BR>
<td><BR>
<m>$n=$</m><endouttext /><BR>
<numericalresponse answer=""><BR>
<BR>
<BR>
    <textline readonly="no" size="3" /><BR>
   <BR>
</numericalresponse><startouttext /></td><BR>
<td></td><BR>
</tr><BR>
</table><endouttext /><BR>
</problem><BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: lon-capa-users-bounces@mail.lon-capa.org on behalf of Justin Gray<BR>
Sent: Tue 3/20/2012 7:12 PM<BR>
To: Discussion list for LON-CAPA users<BR>
Subject: Re: [LON-CAPA-users] Forcing a sigma solution<BR>
<BR>
I suggest that you approach coding this problem as follows. Ask the student to input the limits of summation and the function that you are summing over as an ordered triple into a mathresponse problem. That is, tell the student to express the answer in the form  <m>$\sum_{n=a}^{b}f(n)$</m> but just ask them to input the ordered triple a,b,f(n). Then determine if sum(f(n),n,a,b) is equivalent to the desired sum in Maxima.<BR>
<BR>
Justin<BR>
<BR>
<BR>
Justin Gray | Senior Lecturer<BR>
Department of Mathematics | Simon Fraser University<BR>
8888 University Drive, Burnaby | V5A 1S6 | Canada<BR>
Tel: +1 778.782.4237<BR>
<BR>
<BR>
<BR>
<BR>
On Tue, Mar 20, 2012 at 6:55 PM, Seema Ali <sali@vsb.bc.ca> wrote:<BR>
<BR>
<BR>
                I'm working on creating a question that lists the terms of a finite sum and asking the students to enter a solution using sigma notation.  I know you can use the sum() function but I was wondering if it possible to make sure that the students enter a "valid" solution.<BR>
       <BR>
       <BR>
        Example: ?5+10?15+20?25+30?35+40<BR>
       <BR>
        Some examples of valid solutions:<BR>
        sum(5*n*(-1)^n,n,1,8)<BR>
        sum(5*(n-1)*(-1)^(n-1),n,2,9)<BR>
        sum(5*(n+1)*(-1)^(n+1),n,0,7)<BR>
        5*sum(n*(-1)^n,n,1,8)<BR>
        sum(n*(-1)^n,n,1,8)*5<BR>
        plus other variations<BR>
       <BR>
        Some examples of not valid solutions:<BR>
        sum(0,n,1,8) + 20<BR>
        sum(1,n,1,20)<BR>
        20<BR>
        plus other variations<BR>
       <BR>
        Is it possible to have a question like this?  Below is the code that I have so far.  Keep in mind that it is still a work in progress.<BR>
       <BR>
        Thanks.<BR>
       <BR>
       <BR>
        <problem><BR>
        <script type="loncapa/perl">$base      = &random(2,6,1);<BR>
        $exponent  = &random(2,3,1);<BR>
       <BR>
        $firstterm = &random(-1,1,2)* $base;<BR>
        $numterms  = &random(5,9,1);<BR>
        $termstyle = &random(0,1,1); #determine if the term is base^n(-1)^m, or mn(-1)^p<BR>
       <BR>
        #$termstyle = 0;<BR>
       <BR>
        $term = $firstterm;<BR>
        $sumdisplay  = $term;<BR>
        $total = $firsterm;<BR>
       <BR>
        #calculate the answer<BR>
        $answer = &choose($termstyle+1, "sum((-$base)^n,n,1,$numterms)","sum($base*n*(-1)^n,n,1,$numterms)");<BR>
       <BR>
       <BR>
        if($firstterm>0)<BR>
        {<BR>
          $answer = "-1*".$answer;<BR>
        }<BR>
       <BR>
       <BR>
       <BR>
        for($i=1; $i<$numterms-1; $i++)<BR>
        {<BR>
          if($term>0)<BR>
          {<BR>
            $sumdisplay .= ' - ';<BR>
          }<BR>
          else<BR>
          {<BR>
            $sumdisplay .= ' + ';<BR>
          }<BR>
        <BR>
          if($termstyle==0)<BR>
          {<BR>
            $term*= -1 * $base;         #term = base^n<BR>
          <BR>
          }<BR>
          else<BR>
          {<BR>
            #$term = (-1)**($i) * $base *($i+1 ); #term = mn(-1)^n<BR>
           if($firstterm>0)<BR>
           {<BR>
              $term =(-1)**($i) * $base *($i+1 ); #term = mn(-1)^n<BR>
       <BR>
           }<BR>
           else<BR>
           {<BR>
              $term =(-1)**($i+1) * $base *($i+1 ); #term = mn(-1)^n<BR>
           }<BR>
       <BR>
       <BR>
          }<BR>
          $total += $term;<BR>
          $sumdisplay .= abs($term);<BR>
        }<BR>
       <BR>
          if($term>0)<BR>
          {<BR>
            $sumdisplay .= ' - ';<BR>
          }<BR>
          else<BR>
          {<BR>
            $sumdisplay .= ' + ';<BR>
          }<BR>
       <BR>
          if($termstyle==0)<BR>
          {<BR>
            #$term = (-1*$base)**($numterms);  #term = base^n<BR>
            $term *= -1*$base;<BR>
          }<BR>
          else<BR>
          {<BR>
            $term = (-1)**($numterms) * $base*($numterms);  #term = mn(-1)^n<BR>
          }<BR>
       <BR>
          $sumdisplay .= abs($term);<BR>
          $total += $term;</script><startouttext /><instructions></instructions><endouttext /><startouttext /><m eval='on'>\[ \Large $sumdisplay \]</m><BR>
        base=$base <br /><BR>
        numterm=$numterms <br /><BR>
        total = $total<br /><BR>
        style = $termstyle<br /><BR>
        answer = $answer<br /><endouttext /><BR>
        <mathresponse cas="maxima"><BR>
            <answer></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>
       <BR>
       <BR>
<BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>