summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex')
-rw-r--r--Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex199
1 files changed, 28 insertions, 171 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex
index 8a75eaa89ae..b1be68267d7 100644
--- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex
+++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-math-commands.tex
@@ -7,187 +7,47 @@
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.
-\section{Evaluating Mathematical Operations}
+\section{Additional Mathematical Commands}
\label{pgfmath-commands}
Instead of parsing and evaluating complex expressions, you can also
use the mathematical engine to evaluate a single mathematical
-operation. The macros used for these computations are described in the
-following.
+operation. The macros used for many of these computations are listed
+above in Section~\ref{pgfmath-functions}. \pgfname{} also provides
+some additional commands which are shown below:
+\subsection{Basic arithmetic functions}
-\subsection{Basic Operations and Functions}
+\label{pgfmath-commands-basic}
-\label{pgfmath-operations}
-
-\begin{command}{\pgfmathadd\marg{x}\marg{y}}
- Defines |\pgfmathresult| as $\meta{x}+\meta{y}$.
-\end{command}
-
-\begin{command}{\pgfmathsubtract\marg{x}\marg{y}}
- Defines |\pgfmathresult| as $\meta{x}-\meta{y}$.
-\end{command}
-
-\begin{command}{\pgfmathmultiply\marg{x}\marg{y}}
- Defines |\pgfmathresult| as $\meta{x}\times\meta{y}$.
-\end{command}
-
-\begin{command}{\pgfmathdivide\marg{x}\marg{y}}
- Defines |\pgfmathresult| as $\meta{x}\div\meta{y}$. An error will
- result if \meta{y} is |0|, or if the result of the division is
- too big for the mathematical engine.
- Please remember when using this command that accurate (and reasonably
- quick) division of non-integers is particularly tricky in \TeX{}.
- There are three different forms of division used in this command:
- \begin{itemize}
- \item
- If \meta{y} is an integer then the native |\divide| operation of
- \TeX{} is used.
- \item
- If \vrule\meta{y}\vrule$<1$, then |\pgfmathreciprocal| is employed.
- \item
- For all other values of \meta{y} an optimised long division
- algorithm is used. In theory this should be accurate
- to any finite precision, but in practice it is constrained by the
- limits of \TeX{}'s native mathematics.
- \end{itemize}
-
-\end{command}
+In addition to the commands described in
+Section~\ref{pgfmath-functions-basic}, the following command is
+provided:
\begin{command}{\pgfmathreciprocal\marg{x}}
- Defines |\pgfmathresult| as $1\div\meta{x}$.
-\end{command}
-
-\begin{command}{\pgfmathgreaterthan\marg{x}\marg{y}}
- Defines |\pgfmathresult| as 1.0 if \meta{x} $>$ \meta{y}, but 0.0 otherwise.
-\end{command}
-
-\begin{command}{\pgfmathlessthan\marg{x}\marg{y}}
- Defines |\pgfmathresult| as 1.0 if \meta{x} $<$ \meta{y}, but 0.0 otherwise.
-\end{command}
-
-\begin{command}{\pgfmathequalto\marg{x}\marg{y}}
- Defines |\pgfmathresult| 1.0 if \meta{x} $=$ \meta{y}, but 0.0 otherwise.
-\end{command}
-
-\begin{command}{\pgfmathround\marg{x}}
- Defines |\pgfmathresult| as $\left\lfloor\textrm{\meta{x}}\right\rceil$.
- This uses asymmetric half-up rounding.
-\end{command}
-
-\begin{command}{\pgfmathfloor\marg{x}}
- Defines |\pgfmathresult| as $\left\lfloor\textrm{\meta{x}}\right\rfloor$.
-\end{command}
-
-\begin{command}{\pgfmathceil\marg{x}}
- Defines |\pgfmathresult| as $\left\lceil\textrm{\meta{x}}\right\rceil$.
-\end{command}
-
-\begin{command}{\pgfmathpow\marg{x}\marg{y}}
- Defines |\pgfmathresult| as $\meta{x}^{\meta{y}}$. For greatest
- accuracy \mvar{y} should be an integer. If \mvar{y} is not an integer
- the actual calculation will be an approximation of $e^{y\ln(x)}$.
-\end{command}
-
-\begin{command}{\pgfmathmod\marg{x}\marg{y}}
- Defines |\pgfmathresult| as \meta{x} modulo \meta{y}.
-\end{command}
-
-\begin{command}{\pgfmathmax\marg{x}\marg{y}}
- Defines |\pgfmathresult| as the maximum of \meta{x} or \meta{y}.
-\end{command}
-
-\begin{command}{\pgfmathmin\marg{x}\marg{y}}
- Defines |\pgfmathresult| as the minimum \meta{x} or \meta{y}.
-\end{command}
-
-\begin{command}{\pgfmathabs\marg{x}}
- Defines |\pgfmathresult| as absolute value of \meta{x}.
-\end{command}
-
-\begin{command}{\pgfmathexp\marg{x}}
- Defines |\pgfmathresult| as $e^{\meta{x}}$. Here, \meta{x} can be a
- non-integer. The algorithm uses a Maclaurin series.
-\end{command}
-
-\begin{command}{\pgfmathln\marg{x}}
- Defines |\pgfmathresult| as $\ln{\meta{x}}$. This uses an algorithm
- due to Rouben Rostamian, and coefficients suggested by
- Alain Matthes.
-\end{command}
-
-\begin{command}{\pgfmathsqrt\marg{x}}
- Defines |\pgfmathresult| as $\sqrt{\meta{x}}$.
-\end{command}
-
-\begin{command}{\pgfmathveclen\marg{x}\marg{y}}
- Defines |\pgfmathresult| as $\sqrt{\meta{x}^2+\meta{y}^2}$. This uses
- a polynomial approximation, based on ideas due to Rouben Rostamian.
-\end{command}
-
-\subsection{Trignometric Functions}
-
-\label{pgfmath-trigonmetry}
-
-\begin{command}{\pgfmathpi}
- Defines |\pgfmathresult| as $3.14159$.
-\end{command}
-
-\begin{command}{\pgfmathdeg{\marg{x}}}
- Defines |\pgfmathresult| as \meta{x} (given in radians) converted to
- degrees.
-\end{command}
-
-\begin{command}{\pgfmathrad{\marg{x}}}
- Defines |\pgfmathresult| as \meta{x} (given in degrees) converted to
- radians.
-\end{command}
-
-\begin{command}{\pgfmathsin{\marg{x}}}
- Defines |\pgfmathresult| as the sine of \meta{x}.
-\end{command}
-
-\begin{command}{\pgfmathcos{\marg{x}}}
- Defines |\pgfmathresult| as the cosine of \meta{x}.
-\end{command}
-
-\begin{command}{\pgfmathtan{\marg{x}}}
- Defines |\pgfmathresult| as the tangant of \meta{x}.
+ Defines |\pgfmathresult| as $1\div\meta{x}$. This is provides
+ greatest accuracy when \mvar{x} is small.
\end{command}
-\begin{command}{\pgfmathsec{\marg{x}}}
- Defines |\pgfmathresult| as the secant of \meta{x}.
-\end{command}
+\subsection{Comparison and logical functions}
-\begin{command}{\pgfmathcosec{\marg{x}}}
- Defines |\pgfmathresult| as the cosecant of \meta{x}.
-\end{command}
+In addition to the commands described in
+Section~\ref{pgfmath-functions-comparison},
+the following command was provided by Christian Feuers\"anger:
-\begin{command}{\pgfmathcot{\marg{x}}}
- Defines |\pgfmathresult| as the cotangant of \meta{x}.
+\begin{command}{\pgfmathapproxequalto\marg{x}\marg{y}}
+ Defines |\pgfmathresult| 1.0 if $ \rvert \meta{x} - \meta{y} \lvert < 0.0001$, but 0.0 otherwise.
+ As a side-effect, the global boolean |\ifpgfmathcomparison| will be set accordingly.
\end{command}
-\begin{command}{\pgfmathasin{\marg{x}}}
- Defines |\pgfmathresult| as the arcsine of \meta{x}.
- The result will be in the range $\pm90^\circ$.
-\end{command}
-
-\begin{command}{\pgfmathacos{\marg{x}}}
- Defines |\pgfmathresult| as the arccosine of \meta{x}.
- The result will be in the range $\pm90^\circ$.
-\end{command}
-
-\begin{command}{\pgfmathatan{\marg{x}}}
- Defines |\pgfmathresult| as the arctangent of \meta{x}.
-\end{command}
-
-
-
\subsection{Pseudo-Random Numbers}
\label{pgfmath-random}
+In addition to the commands described in
+Section~\ref{pgfmath-functions-random},
+the following commands are provided:
\begin{command}{\pgfmathgeneratepseudorandomnumber}
Defines |\pgfmathresult| as a pseudo-random integer between 1 and
@@ -195,14 +55,6 @@ following.
due to Erich Janka.
\end{command}
-\begin{command}{\pgfmathrnd}
- Defines |\pgfmathresult| as a pseudo-random number between |0| and |1|.
-\end{command}
-
-\begin{command}{\pgfmathrand}
- Defines |\pgfmathresult| as a pseudo-random number between |-1| and |1|.
-\end{command}
-
\begin{command}{\pgfmathrandominteger\marg{macro}\marg{maximum}\marg{minimum}}
This defines \meta{macro} as a pseudo-randomly generated integer from
the range \meta{maximum} to \meta{minimum} (inclusive).
@@ -253,7 +105,7 @@ following.
-\subsection{Conversion Between Bases}
+\subsection{Base Conversion}
\label{pgfmath-bases}
@@ -263,6 +115,10 @@ positive integers in the range $0$ to $2^{31}-1$, and the bases in the
range $2$ to $36$. All digits representing numbers greater than 9 (in
base ten), are alphabetic, but may be upper or lower case.
+In addition to the commands described in
+Section~\ref{pgfmath-functions-base},
+the following commands are provided:
+
\begin{command}{\pgfmathbasetodec\marg{macro}\marg{number}\marg{base}}
Defines \meta{macro} as the result of converting \meta{number} from
base \meta{base} to base 10. Alphabetic digits can be upper or lower
@@ -340,4 +196,5 @@ base ten), are alphabetic, but may be upper or lower case.
\pgfmathdectobase\mynumber{15}{2} \mynumber
\end{codeexample}
-\end{command} \ No newline at end of file
+\end{command}
+