File:  [LON-CAPA] / loncom / homework / templates / HintMathResponse.problem
Revision 1.1: download - view: text, annotated - select for diffs
Mon Jan 22 21:48:55 2007 UTC (17 years, 6 months ago) by www
Branches: MAIN
CVS tags: HEAD
* Templates for formula and mathresponse
* Adding documentation to the manual
* stringresponse, etc, are not a subsubsection of "Foils" in author manual

    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>');</script>
    9: <startouttext />
   10: Give an example of a function
   11: <ol>
   12: <li>which is orthogonal to <algebra>$function</algebra> with respect to the
   13: scalar product
   14: <m>\[<g \mid h> =
   15: \frac{1}{\pi} \int_{-\pi}^{\pi}dx g(x) \cdot h(x)\]</m>
   16: </li>
   17: <li>whose norm is 1.</li>
   18: </ol><endouttext />
   19: <mathresponse answerdisplay="$example" cas="maxima" args="$function">
   20: <answer>overlap:integrate((RESPONSE[1])*(LONCAPALIST[1]),x,-%pi,%pi)/%pi;
   21: norm:integrate((RESPONSE[1])*(RESPONSE[1]),x,-%pi,%pi)/%pi;
   22: is(overlap=0 and norm=1);</answer>
   23: <textline readonly="no" size="50" />
   24: <hintgroup showoncorrect="no">
   25: <mathhint name="ortho" args="$function" cas="maxima">
   26: <answer>overlap: integrate((LONCAPALIST[1])*(RESPONSE[1]),x,-%pi,%pi)/%pi;
   27: is(not overlap = 0);</answer>
   28: </mathhint>
   29: <mathhint name="norm" args="$function" cas="maxima">
   30: <answer>norm: integrate((RESPONSE[1])*(RESPONSE[1]),x,-%pi,%pi)/%pi;
   31: is(not norm = 1);</answer>
   32: </mathhint> <hintpart on="norm">
   33: <startouttext />
   34: The function you have provided does not have a norm of one.<endouttext />
   35: </hintpart>
   36: <hintpart on="ortho">
   37: <startouttext />
   38: The function you have provided is not orthogonal.<endouttext />
   39: </hintpart>
   40: </hintgroup>
   41: </mathresponse>
   42: <postanswerdate><startouttext /><p>Note that with respect to the above norm, <m>$\cos(nx)$</m> is perpendicular to <m>$\sin(nx)$</m> and perpendicular to <m>$\cos(mx)$</m> for <m>$n\ne m$</m>.</p><endouttext />
   43: </postanswerdate>
   44: </problem>

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