[LON-CAPA-cvs] cvs: loncom /homework mathresponse.idea

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 14 Jun 2006 18:31:37 -0000


albertel		Wed Jun 14 14:31:37 2006 EDT

  Added files:                 
    /loncom/homework	mathresponse.idea 
  Log:
  - adding some design docs
  
  

Index: loncom/homework/mathresponse.idea
+++ loncom/homework/mathresponse.idea
<problem>

<script type="loncapa/perl">
$a1 = random(-5,5,2);
$a2 = random(-5,5,2);
$n1 = random(1,10,1);
$n2 = random(1,10,1);
$function = "$a1*cos($n1*x)+$a2*sin($n2*x)";
@cas_list = ($function);
</script>

<startouttext />
Give an example of a function which is
(1) orthogonal to <algebra>$function</algebra> with respect to the
scalar product
<m>$$\langle g \mid h \rangle =
\frac{1}{\pi} \int_{-\pi}^{\pi} g(x) \cdot h(x)$$</m>
and
(2) whose norm is 1.
<endouttext />

<mathresponse cas="maxima" args="@cas_list">
   <answer>
     f(x):= LONCAPALIST[1];
     overlap: integrate(f(x)*RESPONSE[1],x,-%pi,%pi)/%pi;
     norm: integrate(RESPONSE[1]*RESPONSE[1],x,-%pi,%pi)/%pi;
     grade: is(overlap=0 and norm=1);
     [grade];
   </answer>

   <textline />

   <hintgroup showoncorrect="no">
     <mathhint cas="maxima" args="@cas_list" name="ortho">
       <answer>
         f(x):= LONCAPALIST[1];
         overlap: integrate(f(x)*RESPONSE[1],x,-%pi,%pi)/%pi;
	 [is(overlap != 0)];
       </answer>
     </mathhint>
     <mathhint cas="maxima" args="@cas_list" name="norm">
       <answer>
         f(x):= LONCAPALIST[1];
         norm: integrate(RESPONSE[1]*RESPONSE[1],x,-%pi,%pi)/%pi;
         [is(norm != 1)];
       </answer>
     </mathhint>


     <hintpart on="norm">
       <script type="loncapa/perl">
         $response = &EXT('user.resource.resource.0.submissiom');
	 $norm = &cas('maxima',...); # get the norm
	 $norm_display = &cas_tex_display($norm);
       </script>
       <startouttext />
         The function you have provided is not normal to
         <algebra>$function</algebra> its norm is
          <m eval="on">$norm_display</m>
       <endouttext />
     </hintpart>
     <hintpart on="ortho">
       <startouttext />
         The function you have provided is not orthognal.
       <endouttext />
     </hintpart>

   </hintgroup>
</mathresponse>

</problem>