File:  [LON-CAPA] / loncom / homework / templates / HintMathResponse.problem
Revision 1.2: download - view: text, annotated - select for diffs
Tue Jan 23 21:16:50 2007 UTC (17 years, 3 months ago) by albertel
Branches: MAIN
CVS tags: version_2_3_99_0, HEAD
- trying to make the problem code prettier
- addin sample points to HintFormula.problem
- remove tolerance specfication from CAS fomularesponse

    1: <problem>
    2:     <script type="loncapa/perl">
    3: $a1 = random(-6,6,4);
    4: $a2 = random(-6,6,4);
    5: $n1 = random(3,11,2);
    6: $n2 = random(2,10,2);
    7: $function = "$a1*cos($n1*x)+$a2*sin($n2*x)";
    8: $example=&xmlparse('An example would be <m eval="on">$(sin($n1\cdot x)+cos($n2\cdot x))/\sqrt{2}$</m>');
    9:     </script>
   10: 
   11:     <startouttext />
   12: Give an example of a function
   13: <ol>
   14:     <li>which is orthogonal to <algebra>$function</algebra> with respect to the
   15:         scalar product
   16:         <m>\[<g \mid h> = \frac{1}{\pi} \int_{-\pi}^{\pi}dx g(x) \cdot h(x)\]</m>
   17:     </li>
   18:     <li>whose norm is 1.</li>
   19: </ol>
   20:     <endouttext />
   21: 
   22:     <mathresponse answerdisplay="$example" cas="maxima" args="$function">
   23: 
   24:         <answer>
   25: overlap:integrate((RESPONSE[1])*(LONCAPALIST[1]),x,-%pi,%pi)/%pi;
   26: norm:integrate((RESPONSE[1])*(RESPONSE[1]),x,-%pi,%pi)/%pi;
   27: is(overlap=0 and norm=1);
   28:         </answer>
   29: 
   30:         <textline readonly="no" size="50" />
   31: 
   32:         <hintgroup showoncorrect="no">
   33: 
   34:             <mathhint name="ortho" args="$function" cas="maxima">
   35: 
   36:                 <answer>
   37: overlap: integrate((LONCAPALIST[1])*(RESPONSE[1]),x,-%pi,%pi)/%pi;
   38: is(not overlap = 0);
   39:                 </answer>
   40:             </mathhint>
   41: 
   42:             <mathhint name="norm" args="$function" cas="maxima">
   43:                 <answer>
   44: norm: integrate((RESPONSE[1])*(RESPONSE[1]),x,-%pi,%pi)/%pi;
   45: is(not norm = 1);
   46:                 </answer>
   47:             </mathhint>
   48:            
   49:             <hintpart on="norm">
   50:                 <startouttext />
   51: The function you have provided does not have a norm of one.
   52:                 <endouttext />
   53:             </hintpart>
   54: 
   55:             <hintpart on="ortho">
   56:                 <startouttext />
   57: The function you have provided is not orthogonal.
   58:                 <endouttext />
   59:             </hintpart>
   60: 
   61:         </hintgroup>
   62:     </mathresponse>
   63: 
   64:     <postanswerdate>
   65: 
   66:         <startouttext />
   67: <p>
   68:     Note that with respect to the above norm, <m>$\cos(nx)$</m> is
   69:     perpendicular to <m>$\sin(nx)$</m> and perpendicular to <m>$\cos(mx)$</m>
   70:     for <m>$n\ne m$</m>.
   71: </p>
   72:         <endouttext />
   73: 
   74:     </postanswerdate>
   75: </problem>

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