I would like to know if i really have to calculate the domain of functions like sqrt(x-7)
and log(x-7)/log(2)
and tell to \psplot to work only inside that interval, e.g., for the interval [6,16]
and functions above for example, i'm getting error from ghostscript. But not for the code below.
\documentclass[12pt,pstricks,dvipsnames]{standalone}
\usepackage{pstricks-add}
\begin{document}
\def\azul{\color{Cerulean}}
\def\cinza{\color{gray}}
\psset{xunit=0.25cm,yunit=0.5cm,linecolor=Cerulean}
\begin{pspicture}(-4,-4.3)(20,4.4)
\psaxes[Dx=7,
Dy=3,
labelFontSize=\azul,
tickcolor=Cerulean]{->}(0,0)(-1.5,-3.7)(18.2,3.9)
\psplot[algebraic,
plotpoints=500,
linecolor=blue,
linewidth=1.5pt,
yMinValue=-10,
yMaxValue=10]{7.1}{16}{(log(x-7))/(log(2))}
\psplot[algebraic,
plotpoints=500,
linecolor=green,
linewidth=1.5pt,
yMaxValue=5]{7.1}{16}{sqrt(x-7)}
\end{pspicture}
\end{document}
I ask because we can have a lot of work with complicated functions.
Best Answer
You cannot automatically determine the domain of arbitrary functions you plot. In some cases you can use special functions (in your case
Log
andSqrt
), which check the validity of their operand and return 0 otherwise. So, the plot isn't necessarily correct on all parts of the plot, but at least you don't get a Postscript error and you can check and correct the used domains for the respective functions.With the
algebraic
option you can basically use any Postscript procedure which takes one number as input and evaluates to a number. As example, instead of usingLog(x-7)/log(2)
you can define your own functionFoobar
as follows:As full example:
So it is quite difficult to give a full list of possible functions, especially when taking into account the functions defined by various packages like
pst-func
,pst-math
, etc.