1: <problem>
2:
3: <script type="loncapa/perl">
4: #
5: # This example populates arrays with the x and y coordinates of the plot.
6: # For continuous functions, another approach is to use curve plots.
7: #
8: $amplitude = &random(1,4,0.5);
9: $x_min = -5;
10: $x_max = 5;
11: for ($x=$x_min;$x<=$x_max;$x=$x+0.05) {
12: push(@X,$x);
13: push(@Y,$amplitude*sin($x));
14: # Safeguard:
15: # The following line limits the size of the array to 1000 to avoid infinite loops
16: if (($#X>1000) || ($#Y>1000)) { last; }
17: }
18: </script>
19:
20: <gnuplot width="300" transparent="off" samples="100" grid="on" font="9" bgcolor="xffffff" height="300" align="left" fgcolor="x000000" border="on" plottype="Cartesian" >
21: <axis xmin="$x_min" ymin="-5" xmax="$x_max" ymax="5" color="x000000" />
22: <xlabel>Label X</xlabel>
23: <ylabel>Label Y</ylabel>
24: <curve linestyle="linespoints" name="My Plot" pointtype="0" color="x000000">
25: <data>@X</data>
26: <data>@Y</data>
27: </curve>
28: </gnuplot>
29:
30: <startouttext />What is the amplitude of this function?<endouttext />
31:
32: <numericalresponse answer="$amplitude" format="2s">
33: <responseparam name="tol" type="tolerance" description="Numerical Tolerance" default="5%" />
34:
35: <textline readonly="no" />
36:
37: </numericalresponse>
38: </problem>
39:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>