Diff for /doc/help/codingmath.tex between versions 1.1 and 1.2

version 1.1, 2008/09/10 02:12:09 version 1.2, 2008/09/12 02:22:23
Line 21  symbolic math system is implemented. \$l Line 21  symbolic math system is implemented. \$l
   
   
 \subsection{{\tt <mathresponse>}-interface}  \subsection{{\tt <mathresponse>}-interface}
 \input{Math_Response_Problems.tex}  {\tt <mathresponse>} is a way to have a problem graded based on an algorithm that is executed inside of a computer algebra system. 
   The documentation of \LC points out that  use of this response type is
   generally discouraged, since the responses will not be analyzable by the LON-CAPA statistics tools. Yet, it can be useful.
   
   Which computer algebra system is to be used is specified in the cas argument of the mathresponse tag; currently, only Maxima is available.
   LON-CAPA sets up two arrays inside the computer algebra system: RESPONSE and LONCAPALIST. RESPONSE contains the student input by component, for example, if "3,42,17" is entered, RESPONSE[2] would be 42. LONCAPALIST contains the arguments passed in the args of mathresponse.
   
   The answerdisplay is what is displayed when the problem is in "Show Answer" mode.
   
   The following example illustrates this. It is a simplified version of \begin{verbatim} /res/msu/kashy/physicsLib02/02_Math_2_Trig/LinethroughPt2.problem\end{verbatim}.
   
   \begin{verbatim}
   <problem>
   <script type="loncapa/perl">
   $x = &random(-1,1,2) * &random(1,5,1);
   $y = &random(-1,1,2) * &random(1,4,1); 
   if(&abs($x)==&abs($y)){$x=$y+1;} 
   # avoids y=x and y=-x as possible solutions
   @args = ($x, $y); 
   # This is passed to the CAS, where it will be 
   # LONCAPALIST[1], LONCAPALIST[2]
   
   # In the <answer> block below, RESPONSE[1] is the 
   # student's submission (a scalar, e.g., 3x + 2  ).
    
   # The two lines below provide a varying sample function, 
   # y(x)=mx+b, to be displayed when a correct answer is entered.
   
   $m=&random(2,5)*&random(-1,1,2);
   $b = $y-$m*$x;
   if($b > 0){$b = "+ " . $b;} 
   elsif ($b == 0) {$yb = "";}
   elsif ($b < 0) {$yb = "- " . $b;}
   $example = "$m x $b is an example of the many functions that 
     meet the criteria above.";
   </script>
   
   <startouttext />
   State a function y(x) which passes through the point ($x, $y) 
   and which has a constant slope with absolute value > 1.<br />
   <endouttext />
   <mathresponse answerdisplay="$example" cas="maxima" args="@args">
   
   <answer>
   y(x):=RESPONSE[1]; 
   thrupoint:is(abs(y(LONCAPALIST[1]) - LONCAPALIST[2]) <= 0.000000001);
   islinear:is(diff(y(x),x,2) = 0);
   AbsSlopeGT1:is(abs(diff(y(x),x,1)) > 1);
   thrupoint and islinear and AbsSlopeGT1;
   </answer>
   
   <b>y(x)</b> = <textline readonly="no" size="20" />
   
   </mathresponse>
   </problem>
   
   \end{verbatim}
   
 {\bf a simpler example might be more appriopriate here}  
 \section{Interface to maxima}  \section{Interface to maxima}
 \LC servers run several maxima sessions in parallel. There is a queue which distributes CAS calls to these sessions. When processing a new CAS call one has to be sure that maxima is reset to some default state. In particular functions, variables etc.\ defined in previous calls should be removed. LON-CAPA automatically takes care of that by means of the following sequence of commands which is executed every time before a maxima code snippet supplied by an author will be executed:  \LC servers run several maxima sessions in parallel. There is a queue which distributes CAS calls to these sessions. When processing a new CAS call one has to be sure that maxima is reset to some default state. In particular functions, variables etc.\ defined in previous calls should be removed. LON-CAPA automatically takes care of that by means of the following sequence of commands which is executed every time before a maxima code snippet supplied by an author will be executed:
 \begin{quote}  \begin{quote}

Removed from v.1.1  
changed lines
  Added in v.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>