Plotting math functions
Ctioga knows basic math function from which a lot can already be done. Let’s plot an exponential:
ctioga --math 'exp(x)'
Note that the variable in the function is always implicitly “x”
By the way, let’s not forget to add some title via the --title (or -t) command
ctioga --math 'exp(x)' --title 'My exponential'
By default Ctioga assumes that the x-range is -10:10 and stretches the y-axes
so that the function is completely in the plot. A more “usual” way of looking
at exponentials could be
ctioga --math-xrange -5:1 --math 'exp(x)' -t 'My exponential'
Note that you have to use --math-xrange to get this behavior, the --xrange
option will only modify the plotting range but not the computing range, which
could lead to sampling problems. Compare
ctioga --xrange -1:1 --math 'sin(10 * x)' \
-t 'badly sampled sine'
and
ctioga --math-xrange -1:1 --math 'sin(10 * x)' \
-t 'well sampled sine'
From time to time, it can be very useful to define a function piece by piece:
ctioga --xrange -3:3 --math-xrange -2:0 --math 'x+1' \
--math-xrange 0:2 'exp(x)' \
-t 'Strange exponential'
Adding the --yrange option can be used to isolated a piece of graph
ctioga --yrange -2:8 --xrange -3:3 \
--math-xrange -2:0 --math 'x+1' \
--math-xrange 0:2 'exp(x)' \
-t 'Strange exponential'
Ctioga also knows about parametric functions, whenever you use the variable t,
ctioga --math --math-trange -3.1415:3.1415 \
'sin(2*t):cos(3*t)' \
-t 'parametric curve'
Note that you can use --math-trange to specifies the range over which to
compute the curve. As for --math-xrange, default is -10:10.
--include options allows you to define some functions so that ctioga could use
them. Look to file include_1.rb for an example of syntax. In this file is
defined the function pol(x) = (1.0 - x) * (1.0 + x) that we can use:
ctioga --include include_1.rb --math 'pol(x)' -t 'Polynomial function'