diff --git a/Reals/Grapher.mch b/Reals/Grapher.mch index e64de0183a61d4add7ee099001a66599b1bf83e7..11e458ef1c7cc69a45694857f0eff98bed8f75c8 100644 --- a/Reals/Grapher.mch +++ b/Reals/Grapher.mch @@ -3,15 +3,23 @@ DEFINITIONS "LibraryReals.def"; "LibraryStrings.def"; - // generate a SVG points attribute string (e.g. for polygons) from a sequence of pairs of integers: - svg_points2str(points) == conc(%i.(i:dom(points)| + // generate a SVG points attribute string (e.g. for polygons) from a sequence of pairs of integers: + svg_points2str(points) == conc(%i.(i:dom(points)| FORMAT_TO_STRING("~w,~w ",[real(i), points(i)]))); - // the function to be plotted: - myfunction(x) == 2.0*RSQRT(x)-0.5*RSIN(2.0*x); + // the function to be plotted: + myfunction(x) == 1.5*RSQRT(x)-0.5*RSIN(2.0*x); + + // proportions of the SVG frame + WIDTH == 500; + HEIGHT == 300; + + mx_x == 10.0; // maximum x value computed - mypoints(scale) == %x.(x:1..500| 300.0-scale*myfunction(RDIV(real(x),scale))); + // compute a sequence of function values: + mypoints(scale) == %x.(x:1..WIDTH| real(HEIGHT) - + scale*myfunction(RDIV(real(x),scale))); - // graph plotted in rectangle (0,0) to (300,300) - visb_graph == svg_points2str(mypoints(30.0)) + // graph plotted in rectangle (0,0) to (500,300) + visb_graph == svg_points2str(mypoints(RDIV(real(WIDTH),mx_x))) END \ No newline at end of file