Drawing Functions and Curves
What is New?
This continues my sequence of articles on new features of the upcoming Version 4 of C.a.R. This issue is about plotting of functions and parametric curves, and new numerical expressions implemented in Version 3.95.
You can now draw functions and curves as single points (with various point styles). The distribution of these points depends on your step size, of course. Since the step size can now be an expression, you can evenly distribute points in the interval your functions is defined on.
If a functions is reduced to a point sequence and filled, it will display as a Riemann step function. You get a lower step functions for monotonically increasing functions. If you want an upper step function, you can revert the bounds of the interval simply.
For functions, you can now compute the integral using the trapezoidal rule with your chosen step size, using integrate(f) simply. This is indeed the area of the function as painted, if the function is filled. For functions reduced to points, it will be the Riemann sum.
For parametric curves, integrate(f) will compute the area inside the curve, or more precisely, the are that the ray passes that fills the curve. If you fill the curve, you will see that area. If the curve is not closed (an arc), you can define a center, where the ray starts. In any case, the area is the area you see, if you draw the filled curve.
Have a look at the following applet.
You can take the slider and fill the circle with any number of corners you like. In the upper right, you see the area of the circle and the approximation for this area. How this done?
The slider is the slider from the default macros. Starting value is 3 and end value is 100. However, I opened the expression, named it "n" and put a floor(...) around the expression. This will give integer values for n only.
The n-sided polygon is the parametric curve (cos t, sin t) from 0 to 360 with a stepsize of 360/n, filled. The expression that computes its area is integrate(f) simply.
Here is another example.
Again, you can use the slider to set the number of steps. I already explained the slider. The function is simply f(x)=x^2 from 0 to 1. The step function is f(x), but with a step size of 1/n, filled and with the option "points only". The expression is intergrate(f) simply.
You can get the same effect in older version, using a sequence of 100 points with distance 1/n, and a macro defining the steps of the step function. You could make all points beyond 1 invalid or invisible. However, this is tedious and so I decided to add the new features.
Stay tuned for more!