Annotation of loncom/homework/templates/extreme.problem, revision 1.1
1.1 ! www 1: <problem>
! 2: <parameter name="ordered" type="string_yesno" description="Show Parts One-at-a-Time" default="yes" />
! 3:
! 4: <script type="loncapa/perl">
! 5: $location=&random(4,10,1);
! 6: $example="(x-$location)^2";
! 7: if (&random(0,1,1)) {
! 8: $text='minimum';
! 9: $factor=1;
! 10: } else {
! 11: $text='maximum';
! 12: $factor=-1;
! 13: $example='-'.$example;
! 14: }
! 15:
! 16: # Get user input, run through function that adds "*" to 3x, etc
! 17: $userfunction=&implicit_multiplication(&submission(1,11));
! 18: if ($userfunction) {
! 19: # Determine value at extreme point
! 20: $extremevalue=&cas('maxima',"float(at($userfunction,x=$location))");
! 21: if ($extremevalue=~/^(error|incorrect)/i) {
! 22: # cas could not evaluate the function
! 23: $userfunction='0';
! 24: $extremevalue=0;
! 25: $remark='Your function could not be evaluated.';
! 26: } else {
! 27: $remark='Your function is plotted.';
! 28: $example=$userfunction;
! 29: }
! 30: } else {
! 31: $userfunction='0';
! 32: $extremevalue=0;
! 33: $remark='';
! 34: }
! 35: # Plot boundaries
! 36: $minx=$location-5;
! 37: $maxx=$location+5;
! 38: $miny=$extremevalue-5;
! 39: $maxy=$extremevalue+5;
! 40: @args=($location,$factor);
! 41: </script>
! 42:
! 43: <part id="1">
! 44: <gnuplot width="400" solid="0" plotcolor="monochrome" gridlayer="off" bmargin="default" font="9" alttag="Plot" bgcolor="xffffff" texfont="22" transparent="off" plottype="Cartesian" rmargin="default" gridtype="Cartesian" minor_ticscale="0.5" fontface="sans-serif" grid="on" align="middle" texwidth="93" height="300" border="on" samples="100" fgcolor="x000000" major_ticscale="1" tmargin="default" lmargin="default" fillstyle="empty">
! 45: <curve
! 46: linestyle="lines"
! 47: color="x000000"
! 48: pointtype="1"
! 49: linetype="solid"
! 50: linewidth="1"
! 51: name=""
! 52: limit="closed"
! 53: pointsize="1" >
! 54: <function>$userfunction</function>
! 55:
! 56:
! 57: </curve>
! 58: <axis yzero="off" xformat="on" xmin="$minx" yformat="on" color="x000000" xmax="$maxx" xzero="off" ymax="$maxy" ymin="$miny" />
! 59:
! 60: </gnuplot>
! 61:
! 62: <startouttext />
! 63: <p>$remark</p>
! 64: Give a differentiable real function <m>$f(x)$</m> that has a $text at <m eval="on">$x=$location$</m>.<br />
! 65: <m>$f(x)=$</m>
! 66: <endouttext />
! 67:
! 68: <mathresponse answerdisplay="$example" cas="maxima" args="@args" id="11">
! 69: <answer>y(x):=RESPONSE[1];
! 70: hasextreme:is(at(diff(y(x),x,1),x=LONCAPALIST[1])=0);
! 71: isrightkind:false;
! 72: k:0;
! 73: s:0;
! 74: if hasextreme then for i:2 while s=0 do (s:at(diff(y(x),x,i),x=LONCAPALIST[1]),k:i);
! 75: if evenp(k) and is(LONCAPALIST[2]*s>0) then isrightkind:true;
! 76: hasextreme and isrightkind;</answer>
! 77: <textline readonly="no" size="50" />
! 78: </mathresponse>
! 79: </part>
! 80: <part id="2">
! 81: <script type="loncapa/perl">$value=&cas('maxima',"float(at($example,x=$location))");</script>
! 82: <startouttext />
! 83: What is the value of your function at this $text?
! 84: <endouttext />
! 85: <numericalresponse answer="$value">
! 86: <responseparam type="tolerance" default="5%" name="tol" description="Numerical Tolerance" />
! 87:
! 88: <textline readonly="no" />
! 89:
! 90: </numericalresponse>
! 91: </part>
! 92: </problem>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>