[LON-CAPA-users] Forcing a sigma solution

Seema Ali sali at vsb.bc.ca
Thu Mar 22 23:35:33 EDT 2012


Hi,

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.

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.

Thanks.



<problem>
<script type="loncapa/perl">$base      = &random(2,6,1);
$exponent  = &random(2,3,1);

$firstterm = &random(-1,1,2)* $base;
$numterms  = &random(5,9,1);
$termstyle = &random(0,1,1); #determine if the term is base^n(-1)^m, or mn(-1)^p

#$termstyle = 0;

$term = $firstterm;
$sumdisplay  = $term;
$total = $firsterm;

#calculate the answer
$answer = &choose($termstyle+1, "sum((-$base)^n,n,1,$numterms)","sum($base*n*(-1)^n,n,1,$numterms)");


if($firstterm>0)
{
  $answer = "-1*".$answer;
}



for($i=1; $i<$numterms-1; $i++)
{
  if($term>0)
  {
    $sumdisplay .= ' - ';
  }
  else
  {
    $sumdisplay .= ' + ';
  }
  
  if($termstyle==0)
  {
    $term*= -1 * $base;         #term = base^n
    
  }
  else
  {
    #$term = (-1)**($i) * $base *($i+1 ); #term = mn(-1)^n
   if($firstterm>0)
   {
      $term =(-1)**($i) * $base *($i+1 ); #term = mn(-1)^n 

   }
   else
   {
      $term =(-1)**($i+1) * $base *($i+1 ); #term = mn(-1)^n
   }


  }
  $total += $term;
  $sumdisplay .= abs($term);
}

  if($term>0)
  {
    $sumdisplay .= ' - ';
  }
  else
  {
    $sumdisplay .= ' + ';
  }

  if($termstyle==0)
  {
    #$term = (-1*$base)**($numterms);  #term = base^n
    $term *= -1*$base;
  }
  else
  {
    $term = (-1)**($numterms) * $base*($numterms);  #term = mn(-1)^n
  }

  $sumdisplay .= abs($term);
  $total += $term;</script><startouttext /><instructions></instructions><endouttext /><startouttext /><m eval='on'>\[ \Large $sumdisplay \]</m>
base=$base <br />
numterm=$numterms <br />
total = $total<br />
style = $termstyle<br />
answer = $answer<br />

<table>
<tr>
<td align='right'><endouttext />
<numericalresponse answer="">


    <textline readonly="no" size="3" />
    
</numericalresponse><startouttext /></td>
<td></td>
</tr>
<tr>
<td>
<m>\[ \Huge\Sigma \]</m>
</td>
<td><endouttext />
<mathresponse cas="maxima">
    <answer>is(RESPONSE[1]=1);</answer>
    <textline readonly="no" />
    
</mathresponse><startouttext /></td>
</tr>
<tr>
<td>
<m>$n=$</m><endouttext />
<numericalresponse answer="">


    <textline readonly="no" size="3" />
    
</numericalresponse><startouttext /></td>
<td></td>
</tr>
</table><endouttext />
</problem>










-----Original Message-----
From: lon-capa-users-bounces at mail.lon-capa.org on behalf of Justin Gray
Sent: Tue 3/20/2012 7:12 PM
To: Discussion list for LON-CAPA users
Subject: Re: [LON-CAPA-users] Forcing a sigma solution
 
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. 

Justin


Justin Gray | Senior Lecturer
Department of Mathematics | Simon Fraser University
8888 University Drive, Burnaby | V5A 1S6 | Canada
Tel: +1 778.782.4237




On Tue, Mar 20, 2012 at 6:55 PM, Seema Ali <sali at vsb.bc.ca> wrote:


		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.
	
	
	Example: ?5+10?15+20?25+30?35+40
	
	Some examples of valid solutions:
	sum(5*n*(-1)^n,n,1,8)
	sum(5*(n-1)*(-1)^(n-1),n,2,9)
	sum(5*(n+1)*(-1)^(n+1),n,0,7)
	5*sum(n*(-1)^n,n,1,8)
	sum(n*(-1)^n,n,1,8)*5
	plus other variations
	
	Some examples of not valid solutions:
	sum(0,n,1,8) + 20
	sum(1,n,1,20)
	20
	plus other variations
	
	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.
	
	Thanks.
	
	
	<problem>
	<script type="loncapa/perl">$base      = &random(2,6,1);
	$exponent  = &random(2,3,1);
	
	$firstterm = &random(-1,1,2)* $base;
	$numterms  = &random(5,9,1);
	$termstyle = &random(0,1,1); #determine if the term is base^n(-1)^m, or mn(-1)^p
	
	#$termstyle = 0;
	
	$term = $firstterm;
	$sumdisplay  = $term;
	$total = $firsterm;
	
	#calculate the answer
	$answer = &choose($termstyle+1, "sum((-$base)^n,n,1,$numterms)","sum($base*n*(-1)^n,n,1,$numterms)");
	
	
	if($firstterm>0)
	{
	  $answer = "-1*".$answer;
	}
	
	
	
	for($i=1; $i<$numterms-1; $i++)
	{
	  if($term>0)
	  {
	    $sumdisplay .= ' - ';
	  }
	  else
	  {
	    $sumdisplay .= ' + ';
	  }
	 
	  if($termstyle==0)
	  {
	    $term*= -1 * $base;         #term = base^n
	   
	  }
	  else
	  {
	    #$term = (-1)**($i) * $base *($i+1 ); #term = mn(-1)^n
	   if($firstterm>0)
	   {
	      $term =(-1)**($i) * $base *($i+1 ); #term = mn(-1)^n
	
	   }
	   else
	   {
	      $term =(-1)**($i+1) * $base *($i+1 ); #term = mn(-1)^n
	   }
	
	
	  }
	  $total += $term;
	  $sumdisplay .= abs($term);
	}
	
	  if($term>0)
	  {
	    $sumdisplay .= ' - ';
	  }
	  else
	  {
	    $sumdisplay .= ' + ';
	  }
	
	  if($termstyle==0)
	  {
	    #$term = (-1*$base)**($numterms);  #term = base^n
	    $term *= -1*$base;
	  }
	  else
	  {
	    $term = (-1)**($numterms) * $base*($numterms);  #term = mn(-1)^n
	  }
	
	  $sumdisplay .= abs($term);
	  $total += $term;</script><startouttext /><instructions></instructions><endouttext /><startouttext /><m eval='on'>\[ \Large $sumdisplay \]</m>
	base=$base <br />
	numterm=$numterms <br />
	total = $total<br />
	style = $termstyle<br />
	answer = $answer<br /><endouttext />
	<mathresponse cas="maxima">
	    <answer></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/20120322/3b599709/attachment-0001.html>


More information about the LON-CAPA-users mailing list