Basically, \icmd{\tzaxes}|(<x1,y1>)(<x2,y2>)| draws the $x$ axis from |<x1>| to |<x2>| and the $y$ axis from |<y1>| to |<y2>|.
The coordinate |(<x1,y1>)| represents the origin and |(<x2,y2>)| represents the opposite corner of the rectangle formed by the two coordinates.
|\tzaxes| takes only one coordinate |(<x2,y2>)| as a mandatory argument, in which case the coordinate |(<x1,y1>)| is considered as |(0,0)|.
\paragraph{Shift}
By default, the $x$ and $y$ axes intersect at $(0,0)$.
Specifying the option |<x-shift,y-shift>| shifts the axes to intersect at $(\text{\ttfamily<x-shift,y-shift>})$.
\paragraph{name path}
With the option |"<path name>"|, you can name the path of |\tzaxes| (by default, |axes|).
This makes it easy to find \xem{x-intercepts} and \xem{y-intercepts} of a graph.
The starred version \icmd{\tzaxes*} sets the current state to a \iisw{bounding box} when the macro |\tzaxes| execution is complete. It is recommended for you to use |\tzaxes*| as the first graphics command in |tikzpicture| environment or before any larger graphics.
You can change the text by specifying the curly brace option |{<text>}|, like, for example, |\tzshoworigin{$O$}|.
You can also change the coordinate of origin by the option |(<origin>)|.
Specifying the option |<shift coor>| also moves the origin.
\icmd{\tzshoworigin*} prints a node dot at the origin with no text by default.
Internally the dot is processed by |\tzdot*|. All arguments are optional.
You can add text with the option |{<text>}|.
The default size of the dot is |2.4pt|, and it can be changed with the last option |(<dot size>)|. You can change the dot style using the first optional argument |[<dot opt>]|.
You can also move the dot by specifying the option |<shift coor>|.
\remark
For |\tzshoworigin*|, text for the origin and the dot are placed independently. In other words, the position of node text does not depend on the size of a node dot.
(In fact, the node text for the origin should look good with the `ticks labels', so it was not designed as a |label| for the node dot. This also means that the origin text cannot be positioned by an |<angle>|.)
\icmd{\tzaxesL} is similar to |\tzaxes|, but it draws only the `L' type axes with |(<x1,y1>)| as the origin and |(<x2,y2>)| as the opposite corner of the rectangle.
Those two coordinates are mandatory.
\paragraph{Tick labels}
Internally, |\tzticks| uses \Tikz's |foreach| operation.
So you need to provide comma separated lists to print tick labels.
If only one comma separated list is specified, it is for $x$ tick labels.
\paragraph{Tick marks}
By specifying the options |(<x-from:x-to>)| for $x$ ticks and/or |(<y-from:y-to>)| for $y$ ticks, you can print tick marks. (The default is |(0pt:0pt)| for both options.)
\begin{tzcode}{.3}
% \tzticks: tick marks with (<a pt:b pt>)
\begin{tikzpicture}[scale=.4,font=\scriptsize]
\tzhelplines(10,10)
\tzshoworigin
\tzaxes(-1,-1)(10,10)
\tzticks[draw=red,thick]
(-15pt:10pt){1,...,5,6/$k$,7/$\alpha$,8/$\beta$}
(0pt:3cm) {2,...,6,7/$\gamma$}
\end{tikzpicture}
\end{tzcode}
The position of tick labels does not depend on the length of the tick marks.
You can change the position of tick labels using |[<node opt>]|.
\begin{tzcode}{.3}
% \tzticks: position of tick labels
\begin{tikzpicture}[scale=.4,font=\scriptsize]
\tzhelplines(10,10)
\tzshoworigin
\tzaxes(-1,-1)(10,10)
\tzticks[draw=red,thick]
(-15pt:10pt){1,...,6,7/$t$,8/$\alpha$}[b=5pt]
(0pt:3cm) {2,...,6,7/$\beta$}
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift}
You can move (or shift) the tick marks and labels together by specifying the optional argument |<x-shift,y-shift>|, where |<x-shift>| is for |y-ticks| and |<y-shift>| is for |x-ticks|.
\icmd{\tzproj*} additionally prints a `black node dot' of the size |2.4pt|, by default.
Internally, the node dot is processed by |\tzdot*|.
The first option |[<opt>]| does not control the node dot.
\paragraph{Dot size}
You can only control the size of dots by the last optional argument |(<dot size>)| or by the \threeways\ on page \pageref{ss:threeways}.
If you want to control |fill| or |color| of dots, use |\tzdot*| separately.
\paragraph{Adding text}
You can also add text around the projection point on each axis by the option |{<text>}|.
The position and color of the text is controlled by the option |[<node option>]|.
The default position is (approximately) |[below]| for the x axis and |[left]| for the y axis.
You can only control the size of dots by the last option |(<dot size>)|.
If you want to control |fill| or |color| of dots, use |\tzdot*| separately.
You can also add text around the projection point on each axis by specifying the option |{<x-text>}| or |{<y-text>}| followed by the option |[<node option>]|.
\icmd{\tzprojs} accepts any number of coordinates and draws perpendicular lines onto each axis from the coordinates. The lines are |dotted|, by default.
|\tzprojs| is a semicolon version of |\tzproj|, so a semicolon is needed to indicate when the coordinate iteration ends. Its repeating pattern is |(<coor>){<x-text>}[<node opt>]{<y-text>}[<node opt>]|.
\icmd{\tzprojs*} additionally prints |\tzdots*| of the |2.4pt| (by default) on the coordinates.
The first option |[<opt>]| does not control the node dots.
You can move the projection points and text accordingly, using the option |<x-shift,y-shift>| before the first coordinate. The \xem{empty} shift option |<>| is \xem{not allowed}.
You can also change the dot size with the last option |(<dot size>)| \xem{after} the semicolon, as in |\tzproj(*)|.
%%------------------------------------------------------------
\section{\protect\cmd{\tzprojsx(*)} and \protect\cmd{\tzprojsy(*)}: Semicolon versions}
\label{s:tzprojsx}
\icmd{\tzprojsx} is a semicolon versions of |\tzprojx|. It draws dotted lines, which are perpendicular to the x axis from the specified coordinates, by default.
\icmd{\tzprojsx*} additionally prints |\tzdots*| of the size |2.4pt|, by default.
%%------------------------------------------------------------
\section{\protect\cmd{\tzfn} and \protect\cmd{\tzfn'}: Plot functions and inverse functions}
\label{s:tzfn}
\subsection{\protect\cmd{\tzfn}}
\label{ss:tzfn}
\icmd{\tzfn} plots a function of |\x|.
\begin{tzdef}
% syntax: minimum
\tzfn{<fn of \x>}[<domain>]
% syntax: medium
\tzfn{<fn of \x>}[<domain>]{<text>}[<pos>]
% syntax: full
\tzfn[<opt>]<shift coor>"<path name>"
{<fn of \x>}[<domain>]{<text>}[<node opt>]<code.append>
% [<domain>] should be of the form [<from num:to num>]
% defaults
[samples=201]<>""{<m>}[<m>]{}[]<>
\end{tzdef}
|\tzfn| takes two mandatory arguments: |{<fn of \x>}| and |[<domain>]|.
The domain should be of the form |[<from num:to num>]|, like |[1:5]|.
\begin{tztikz}
\tzfn{.5*(\x)^2-1}[1:5] % works like:
\draw [samples=201,domain=1:5] plot (\x,{.5*(\x)^2-1});
\end{tztikz}
You can name the path of |\tzfn| by specifying the option |"<path name>"| \xem{immediately before} the mandatory argument |{<fn of \x>}|. You can use the path names to find intersection points.
Suppose that the function's expression |<fn of \x>| consists \xem{only of a macro name}, say, |\Fx|. Then
\begin{itemize}\firmlist
\item The macro name |Fx| (\xem{without the backslash}) is
\xem{automatically assigned} to |<path name>|,
unless you give another name.
\item That is, |\tzfn\Fx| is equivalent to |\tzfn"Fx"\Fx|.
(\xem{You don't need to type the same thing twice}.)
\end{itemize}
\begin{tzcode}{.3}
% \tzfn: name path: intersection point
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,8)
\tzaxes(8,8)
\def\Dx{7-\x}
\def\Sx{1+\x}
\tzfn"Dx"\Dx[0:7]{$D$}[ar] % name path = Dx
\tzfn \Sx[0:7]{$S$}[blue,r] % name path = Sx
\tzXpoint*{Dx}{Sx}(E){E} % intersection
\end{tikzpicture}
\end{tzcode}
\subsection{Move graphs: \texttt{shift}}
You can move the graph of |\tzfn| by specifying the option |<shift coor>| \xem{before} the mandatory argument |{<fn of \x>}| or \xem{immediately before} the option |"<path name>"|, if it exists.
The \xem{empty} shift option |<>| is \xem{not allowed}.
\paragraph{\texttt{<code.append>}}
You can extend the path of |\tzfn|, by writing \Tikz\ code in the \xem{last optional argument} |<code.append>|. Internally it adds the \Tikz\ code to the path \xem{after} the options |{<text>}| and |[<node opt>]|.
\paragraph{\texttt{\bs tzfnAtEnd}}
You can also extend the path of |\tzfn| at the end using \icmd{\tzfnAtEnd}.
Internally it adds \Tikz\ code immediately \xem{before} the options |{<text>}| and |[<node opt>]|. But you have to use |\tzfnAtEnd| (immediately) \xem{before each} |\tzfn|.
\paragraph{\texttt{\bs tzfnAtBegin}}
You can use \icmd{\tzfnAtBegin} (immediately) \xem{before each} |\tzfn| to insert \Tikz\ code at the beginning of the path of |\tzfn|.
\remark
\begin{itemize}\firmlist
\item |\tzfn| is based on the |plot| operation of \Tikz.
\item Appending \Tikz\ code at the beginning of |\tzfn| may cause a problem when you use some operations (such as |to| or \verb+-|+ or \verb+|-+) that expect a coordinate to link.
\item In the version 2 of the |tzplot| package, this issue is internally taken care of by using
|(|\ixxw{current subpath start}|)|, which is a special coordinate pre-defined in \Tikz. (See \Tikz\ manual for more details.)
\end{itemize}
\section{\protect\cmd{\tzfnofy} and \protect\cmd{\tzfnofy'}: Functions of variable $y$}
\label{ss:tzfnofy}
\icmd{\tzfnofy} plots a function of |\y|.
Define a function with the (predefined) variable |\y|.
|\tzfnofy| works just like |\tzfn| but as a function of |\y|.
\begin{tzdef}
% syntax: minimum
\tzfnofy{<fn of \y>}[<domain>]
% syntax: medium
\tzfnofy{<fn of \y>}[<domain>]{<text>}[<pos>]
% syntax: full
\tzfnofy[<opt>]<shift coor>"<path name>"
{<fn of \y>}[<domain>]{<text>}[<node opt>]<code.append>
% [<domain>] should be of the form [<from num:to num>]
% defaults
[samples=201]<>""{<m>}[<m>]{}[]<>
\end{tzdef}
\begin{tztikz}
\tzfnofy{2*\y+1}[1:5] % works like:
\draw [samples=201,domain=1:5,variable=\y] plot ({2*\y+1},\y);
\end{tztikz}
The \iisw{swap version} \icmd{\tzfnofy'} plots the \iisw{inverse function} of |\tzfnofy|.
\begin{tztikz}
\tzfnofy'{2*\y+1}[1:5] % works like:
\draw [samples=201,domain=1:5,variable=\y] plot (\y,{2*\y+1});
\end{tztikz}
%%%\section{\protect\cmd{\tzdeffn} and \protect\cmd{\tzdeffnofy}}
%%%\label{ss:tzdeffn}
%%%
%%%\icmd{\tzdeffn} defines a functions of |\x|.
%%%
%%%\icmd{\tzdeffnofy} defines a function of |\y|.
%%%%%
%%%%%These are redundant, since one can use |\def|.
%%%%%
|\tzhfnat| accepts only one mandatory argument |{<y-val>}|.
The domain is optional and should be of the form |[<from num:to num>]|.
The default domain is from left to right of the \ixxw{current bounding box}.
\remark Internally, the default domain of |\tzhfnat| depends on the \ixxw{current bounding box}.
\begin{itemize}
\item Each |\tzhfnat| may draw a line with a (slightly) different length.
\item If an appropriate |current bounding box| is not formed before |\tzhfnat| is executed, you will probably get an unexpected result.
\item In that case, you can fix a |bounding box| in the beginning of the |tikzpicture| environment using macros such as \icmd{\tzbbox}, \icmd{\tzhelplines*}, \icmd{\tzaxes*}, or \Tikz's \icmd{\useasboundingbox}.
\end{itemize}
You can name the path of |\tzhfnat| by the option |"<path name>"|.
You can move the line by the option |<shift coor>|.
You can also extend the path from the end of the line by writing \Tikz\ code in the last optional argument |<code.append>|.
You can also use \icmd{\tzhfnatAtBegin} and \icmd{\tzhfnatAtEnd} to extend the path of |\tzhfnat| at the beginning and at the end. Specifying the option |<code.append>| extends the path after |\tzhfnatAtEnd| if it exists.
(See other examples of using |\tz<..>AtBegin| and |\tz<...>AtEnd|.)
\icmd{\tzhfn} accepts a coordinate as a mandatory argument and draws a horizontal line at the $y$ value of the coordinate.
For example, |\tzhfn(<x>,3)|, ignoring |<x>|, is equivalent to |\tzhfnat{3}|.
\xem{Everything else is the same as in} |\tzhfnat|.
You can also use \icmd{\tzhfnAtBegin} and \icmd{\tzhfnAtEnd} to extend the path of |\tzhfn| at the beginning and at the end. Specifying the option |<code.append>| extends the path after |\tzhfnAtEnd| if it exists.
(See other examples of using |\tz<..>AtBegin| and |\tz<...>AtEnd|.)
|\tzvfnat| accepts only one mandatory argument |{<x-val>}|.
The domain is optional and should be of the form |[<from num:to num>]|.
The default domain is from bottom to top of the \ixxw{current bounding box}.
You can name the path of |\tzvfnat| by the option |"<path name>"|.
You can move the line by the option |<shift coor>|.
You can also extend the path from the end of the line by writing \Tikz\ code in the last optional argument |<code.append>|.
In the previous example, |\tzhelplines*| is used to fix a bounding box. (See Section \ref{s:tzhelplines} on page \pageref{s:tzhelplines}, for more details.)
You can also use \icmd{\tzvfnatAtBegin} and \icmd{\tzvfnatAtEnd} to extend the path of |\tzvfnat| at the beginning and at the end. Specifying the option |<code.append>| extends the path after |\tzvfnatAtEnd| if it exists.
(See other examples of using |\tz<..>AtBegin| and |\tz<...>AtEnd|.)
\icmd{\tzvfn} accepts a coordinate as a mandatory argument and draws a horizontal line at the $x$ value of the coordinate.
For example, |\tzvfn(3,<y>)|, ignoring |<y>|, is equivalent to |\tzvfnat{3}|.
\xem{Everything else is the same as in} |\tzvfnat|.
You can also use \icmd{\tzvfnAtBegin} and \icmd{\tzvfnAtEnd} to extend the path of |\tzvfn| at the beginning and at the end. Specifying the option |<code.append>| extends the path after |\tzvfnAtEnd| if it exists.
(See other examples of using |\tz<..>AtBegin| and |\tz<...>AtEnd|.)
%%==================================
\chapter{Plot Linear Functions}
\label{c:linearfunctions}
%%------------------------------------------------------------
\section{\protect\cmd{\tzLFn}: Plot linear functions}
\label{s:tzLFn}
\subsection{\protect\cmd{\tzLFn} and \protect\cmd{\tzLFn'}}
Knowing two coordinates or one coordinate with a slope, you can draw a linear function with the macro \icmd{\tzLFn}, \xem{without writing the explicit definition of a linear function}.
\begin{itemize}%\firmlist
\item
|\tzLFn(<coor1>)(<coor2>)| is prepared for when you know two coordinates on a line.
\begin{itemize}
\item
If you provide two points $(x_1,y_1)$ and $(x_2,y_2)$, |\tzLFnofy(x1,x2)(y1,y2)| draws the graph of $f(x)=\frac{y_2-y_1}{x_2-x_1}(x-x_1)+y_1$.
\end{itemize}
\item
|\tzLFn(<coor1>){<slope>}| is used when you know one coordinate and the slope of a line.
\item
If you specify all the three arguments |(<coor1>)(<coor2>){<slope>}|, then the slope is ignored.
\end{itemize}
For example, |\tzLFn(1,1)(2,3)[0:4]| draws a line passing through two points: $(1,1)$ and $(2,3)$, over $0\leq x\leq 4$.
|\tzLFn(1,1){.5}[0:4]| draws a line passing through a point $(1,1)$ with a slope |.5|, over $0\leq x\leq 4$.
|\tzLFn| accepts two mandatory arguments: |(<coor1>)| and |[<domain>]|.
\begin{itemize}%\firmlist
\item The \xem{domain} should be of the form |[<from num:to num>]|.
\item If just one coordinate is specified without a slope, the slope is regarded as |1|, by default.
\end{itemize}
\begin{tzdef}
% syntax: minimum
\tzLFn(<coor1>)(<coor2>)[<domain>] % two coordinates
\tzLFn(<coor1>){<slope>)[<domain>] % one coordinate and slope
% syntax: full
\tzLFn[<opt>]<shift coor>"<path name>"
(<coor1>)(<coor2>){<slope>}[<domain>]{<text>}[<node opt>]<code.append>
% defaults
[]<>""(<m>)(){1}[<m>]{}[]<>
\end{tzdef}
You can add text at the end of the line of |\tzLFn| by the options |{<text>}| and |[<node opt>]|. You can also name the path of |\tzLFn| by specifying the option |"<path name>"| \xem{immediately before} the mandatory coordinate.
You can move the line of |\tzLFn| by specifying the option |<shift coor>| immediately before the option |"<path name>"|. (The \xem{empty} shift option |<>| is \xem{not allowed}.)
You can also extend the path of |\tzLFn| by writing \Tikz\ code in the last optional argument |<code.append>|.
\icmd{\tzLFnAtBegin} and \icmd{\tzLFnAtEnd} are available to extend a path of |\tzLFn| at the beginning and and the end, respectively.
Specifying the option |<code.append>| extends the path after |\tzLFnAtEnd|, if it exist.
\subsection{\protect\cmd{\tzLFnofy} and \protect\cmd{\tzLFnofy'}}
\icmd{\tzLFnofy} draws a line as a function of |\y|.
|\tzLFnofy| works just like |\tzLFn| but for the variable $y$.
If you provide two points $(x_1,y_1)$ and $(x_2,y_2)$, |\tzLFnofy(x1,x2)(y1,y2)| draws the graph of $f(y)=\frac{x_2-x_1}{y_2-y_1}(y-y_1)+x_1$.
You can use \icmd{\tzLFnofyAtBegin} and \icmd{\tzLFnofyAtEnd} to extend the path of |\tzLFnofy| at the beginning and at the end. Specifying the optional argument |<code.append>| extends the path after |\tzLFnofyAtEnd| if it exists.
(See other examples of using |\tz<..>AtBegin| and |\tz<...>AtEnd|.)
\icmd{\tzdefLFn} simply defines a linear function $ax+b$ and saves it to a macro.
You can use |\tzdefLFn| together with |\tzfn| to graph a linear function, \xem{without writing an explicit definition} of a linear function.
(Of course, you can directly use |\tzLFn|.)
If |(<coor2>)| is specified, |{<slope>}| is ignored.
If |(<coor2>)| is missing |<slope>| is considered as the slope of the line (by default 1).
For example, |\tzdefLFn{\Gx}(1,1){.5}| defines as |\Gx| a linear function passing through the point $(1,2)$ with a slope |.5|.
That is, it defines a function as $f(x)=.5(x-1)+1$.
Knowing two coordinates, linear function |\Gx| passing through the two points can be defined, for example, by |\tzdefLFn{\Gx}(1,2)(3,1)|.
That is, it defines a function as $g(x)=\frac{1-2}{3-1}(x-1)+2$.
\begin{tztikz}
\tzdefLFn{\Fx}(1,2)(3,1) % works like
\def\Fx{-1/2*(\x-1)+2}
\end{tztikz}
\remark If you inadvertently try an \xem{infinite slope}, you will get an \iisw{error message}.
\remark The swap version |\tzfn'| simply draws the graph of the inverse function of |\tzfn|.
So |\tzfn'(A)(B)| and |\tzfn'(A){.5}| do not guarantee passing through the coordinate |(A)| or |(B)|.
\remark The swap version |\tzfnofy'| simply draws the graph of the inverse function of |\tzfnofy|.
So |\tzfnofy'(A)(B)| and |\tzfnofy'(A){.5}| do not guarantee passing through the coordinate |(A)| or |(B)|.
%%==================================
\chapter{Some More Functions}
\label{c:more-fn}
%%------------------------------------------------------------
\section{\texttt{\bs tzpdfN(*)} and \texttt{\bs tzpdfZ}: Normal distributions}
\label{s:normaldistributions}
|\tzpdfN|, |\tzpdfN*| and |\tzpdfZ| are predefined functions to plot the \iisw{probability density function} (pdf) of a \iisw{normal distribution} $N(\mu,\sigma^2)$.
\paragraph{Normal distributions}
\icmd{\tzpdfN} accepts two mandatory arguments, |{<mean>}| $\mu$ and |{<variance>}| $\sigma^2$, to define the pdf function:
\[
\frac{1}{\sigma\sqrt{2\pi}} e^{-\frac12\big(\frac{x-\mu}{\sigma}\big)^2}
\]
\icmd{\tzpdfN*} uses a standard deviation $\sigma$ instead of a variance.
With these predefined functions together with |\tzfn| you can plot the pdf of normal distributions.
%%------------------------------------------------------------
\section{\protect\cmd{\tzfnarea(*)}: Fill under the graph}
\subsection{\protect\cmd{\tzfnarea(*)}}
\icmd{\tzfnarea} fills the area between the graph of a function and the x axis, with a color or pattern, on the |behind| layer by default.
With \icmd{\settzfnarealayer}, you can change the layer of |\tzfnarea|.
|\tzfnarea| accepts two mandatory arguments: |{<fn of \x>}| and |[<domain>]|, like |\tzfn|.
\begin{tzdef}
% syntax: minimum
\tzfnarea{<fn of \x>}[<domain>]
% syntax: full
\tzfnarea[<opt>]{<fn of \x>}[<domain>]{<fill opacity>}<code.append>
% defaults
[]{<m>}[<m>]{.3}<>
\end{tzdef}
The starred version \icmd{\tzfnarea*} fills the area with |fill=black!50| and |fill opacity=.3|, and |text opacity=1|, by default. The default values can be changed by |\settzfillcolor|, |\settzfillopacity|, and the option |{<fill opacity>}|.
\icmd{\tzfnarealine} draws one or two boundary lines of |\tzfnarea| using |\tzto|, on the |behind| layer by default. The layer can be changed by \icmd{\settzfnarealayer}.
It takes two mandatory arguments: |{<path>}| and |{<x1>}|.
\begin{itemize}\firmlist
\item |\tzfnarealine{<path>}{<x1>}| draws a vertical line to the $x$ axis at |<x1>|.
\item |\tzfnarealine{<path>}{<x1>}{<x2>}| draws two vertical lines at |<x1>| and |<x2>|.
\end{itemize}
The first option |[<opt>]| controls both lines and is overwritten by each of |[<opt1>]| (for the line at |<x1>|) and |[<opt2>]| (for the line at |<x2>|).
The line width is |very thin| by default, which can be changed by \icmd{\settzfnarealinestyle}.
You can also change the length of lines by specifying |(<coor1>)| and |(<coor2>)|.
The \xem{swap version} \icmd{\tzfnarealine'} draws one or two horizontal lines from the point $(x_i,f(x_i))$ to the $y$ axis.
Everything else is the same as in |\tzfnarealine|.
\icmd{\tzfnmax} plots the maximum of a list of functions, that is, an \xem{upper} \iisw{envelope curve}. The first mandatory argument should be a comma separated list of functions.
The second mandatory argument |[<domain>]| should be colon separated.
The default line width of |\tzfnmax| is |thick|.
\begin{tzdef}
% syntax: minimum
\tzfnmax{<fn list>}[<domain>]
% syntax: full
\tzfnmax[<opt>]<shift coor>"<path name>"
{<fn list>}[<domain>]{<text>}[<node opt>]<code.append>
% remark:
- {<fn list>} should be comma separated
- [<domain>] should be of the form [<from num:to num>]
% defaults
[thick,samples=201]<>""{<m>}[<m>]{}[]<>
\end{tzdef}
\remark If you want sharp corners at kinked points, you may need to select an appropriate number of sample points, which is |samples=201|, by default. You can try an odd number.
\remarkafterskip
If you want, you can shift and extend path using the option |<shift coor>| and |<code.append>|, respectively.
You can also use \icmd{\tzfnmaxAtBegin} and \icmd{\tzfnmaxAtEnd} to extend the path of |\tzfnmax| at the beginning and at the end, respectively.
\icmd{\tzfnmin} plots the minimum of a list of functions.
|\tzfnmin| works just like |\tzfnmax|, but it draws a \xem{lower} \iisw{envelope curve}.
\begin{tzdef}
% syntax: minimum
\tzfnmin{<fn list>}[<domain>]
% syntax: full
\tzfnmin[<opt>]<shift coor>"<path name>"
{<fn list>}[<domain>]{<text>}[<node opt>]<code.append>
% remark:
- {<fn list>} should be comma separated
- [<domain>] should be of the form [<from num:to num>]
% defaults
[thick,samples=201]<>""{<m>}[<m>]{}[]<>
\end{tzdef}
For example, |\tzXpoint{path1}{path2}(A)| determines an intersection of the two paths and names the point |(A)| or |(A-1)|. (By default, the name is |(intersection)| as in \Tikz.)
If there are two or more intersection points, they are named as follows: |(A)=(A-1)|, |(A-2)|, |(A-3)|, etc.
You can determine which intersection point is named directly by specifying the option |[<nth>]|. If you select the second intersection point to be named |(A)| out of multiple intersections, they are named as follows: |(A-1)|, |(A)=(A-2)|, |(A-3)|, |(A-4)|, etc.
You can label intersection points by specifying the option |{<label>}| and |[<angle>]|.
\warning When using |\tzXpoint|, the intersection of two paths must actually exist.Otherwise, an error will occur when using coordinates.
\paragraph{\icmd{\tzXpoint*}} The starred version |\tzXpoint*| simply adds a node dot to |\tzXpoint|.
The default dot size is |2.4pt| and it can be changed by the last option |(<dot size>)| or the \threeways\ (on page \pageref{ss:threeways}).
\icmd{\tzvXpointat} determines \iisw{vertical intersection} points of a path at a specified value of $x$.
So it takes |{<path>}| and |{<x-val>}| as mandatory arguments.
\remark
Internally, |\tzvXpointat| depends on the |current bounding box|, which generally does not cause a problem because it is used after paths to be intersected are formed.
In case of any problem of no intersection point, you may want to fix a bounding box using |\tzbbox| or |\tzaxes*| or \Tikz's |\useasboundingbox|.
\icmd{\tzvXpoint} accepts |{<path>}| and |(<coor>)| as mandatory arguments to find \iisw{vertical intersection} points of a path at the $x$ value of the coordinate, ignoring the $y$ value.
For example, |\tzvXpoint{mypath}(3,<y>)|, ignoring |<y>|, is equivalent to |\tzvXpointat{mypath}{3}|.
\xem{Everything else is the same as in} |\tzvXpointat|.
\icmd{\tzhXpointat} determines \iisw{horizontal intersection} points of a path at a specified value of $y$.
So it takes |{<path>}| and |{<y-val>}| as mandatory arguments.
\icmd{\tzhXpoint} accepts |{<path>}| and |(<coor>)| as mandatory arguments to find \iisw{horizontal intersection} points of a path at the $y$ value of the coordinate, ignoring the $x$ value.
For example, |\tzhXpoint{mypath}(<x>,3)|, ignoring |<x>|, is equivalent to |\tzhXpointat{mypath}{3}|.
\xem{Everything else is the same as in} |\tzhXpointat|.
%%------------------------------------------------------------
\section{\protect\cmd{\tzLFnXpoint(*)}: Intersection point of linear functions}
\label{s:tzLFnXpoint}
Sometimes you may want to \xem{quickly} find intersection point of two linear functions \xem{without specifying path names}.
\icmd{\tzLFnXpoint} finds the solution of two linear functions without printing anything by default.
You can name it and use it.
\icmd{\tzsecantat} draws a line segment or a \iisw{secant} line of a curve, on the |behind| layer by default.
|\tzsecantat| accepts three mandatory arguments.
Three mandatory arguments are a path name and two values of $x$: |{<path>}|, |{<from-x>}|, and |{<to-x>}|.
With \icmd{\settzsecantlayer}, you can change the layer, like |\settzsecantlayer{main}|.
\paragraph{Domain}
The domain of the form |[<from num:to num>]| is optional.
Without specifying the optional domain, |\tzsecantat| draws a line segment connecting two points on the (curved) path.
\icmd{\tzsecant} uses two \xem{coordinates instead of two values of $x$} to draw a line segment or a \iisw{secant} line of a curve, on the |behind| layer by default.
You need to specify a path name and two coordinates, then |\tzsecant| uses the $x$ values of the two coordinates.
\xem{Everything else is the same as in} |\tzsecantat|.
You can change the layer with \icmd{\settzsecantlayer}.
The domain should be of the form |[<from num:to num>]|.
Without specifying the optional domain, |\tzsecant| draws a line segment connecting two points on the (curved) path.
\icmd{\tztangentat} draws a \iisw{tangent} line to a curve at a specified value of $x$. Three mandatory arguments are a curve name, a value of $x$, and a domain: |{<path>}|, |{<x-val>}|, and |[domain]|.
By default, the tangent line is drawn on the |behind| layer, which can be changed by \icmd{\settztangentlayer}, like |\settztangentlayer{main}|.
\remark
To calculate the slope at $x$, $x$ varies over the interval $(x-\varepsilon_1,x+\varepsilon_2)$ and $\varepsilon_1=\varepsilon_2=0.01$, by default.
So the slope of tangent line is only \xem{approximate}.
\begin{tzdef}
% syntax: minimum
\tztangentat{<path>}{<x-val>}[<domain>]
% syntax: medium
\tztangentat{<path>}{<x-val>}[<domain>]{<text>}[<node opt>]
% syntax: full
\tztangentat[<opt>]<shift coor>"<path name>"
{<path>}{<x-val>}(<epsilon1>,<epsilon2>)[<domain>]
{<text>}[<node opt>]<code.append>
% The domain should be of the form [<from:to>]
% defaults
[]<>""{<m>}{<m>}(.01,.01)[<m>]{}[]<>
\end{tzdef}
\paragraph{Domain}
The mandatory argument |[<domain>]| should be of the form |[<from num:to num>]|.
\paragraph{Variations}
Since the slope of the tangent line is \xem{approximate}, sometimes you may want to change the variation interval to get better results.
You can change $\varepsilon_1$ and $\varepsilon_2$ by specifying the option |(<epsilon1,epsilon2>)| \xem{immediately after} the mandatory argument |{<x-val>}|.
Or you can change the variations by the macro \icmd{\settztangentepsilon},
like |\settztangentepsilon{|$\varepsilon_1$|}{|$\varepsilon_2$|}|. The effect remains until the end of |tikzpicture| environment unless changed again.
\icmd{\tztangent} uses a \xem{coordinate instead of a value} of $x$ to draw a \iisw{tangent} line to a curve.
|\tztangent| accepts three mandatory arguments: |{<path>}|, |(<coor>)|, and |[<domain>]|.
The value of $y$ in |(<coor>)| is ignored.
For example, |\tztangent{curve}(4,|$y$|)| is equivalent to |\tztangentat{curve}{4}| for any $y$.
\xem{Everything else is the same as in} |\tztangentat|.
\begin{tzdef}
% syntax: minimum
\tztangent{<path>}(<coor>)[<domain>]
% syntax: medium
\tztangent{<path>}(<coor>)[<domain>]{<text>}[<node opt>]
% syntax: full
\tztangent[<opt>]<shift coor>"<path name>"
{<path>}(<coor>)(<epsilon1>,<epsilon2>)[<domain>]
{<text>}[<node opt>]<code.append>
% The domain should be of the form [<from:to>]
% defaults
[]<>""{<m>}(<m>)(.01,.01)[<m>]{}[]<>
\end{tzdef}
\icmd{\tzslopeat} draws a slope line to a path with a specified length.
The mandatory arguments are |{<path>}|, |{<x>}|, and |{<length>}|.
The tangent point is the middle point of the slope line.
By default, the slope lines are drawn on the |behind| layer.
You can change the layer, like \icmd{\settztslopelayer}|{main}|.
\remark The slope is \xem{approximate} and you can manipulate the slope by changing the variation interval with the option |(<epsilon1,epsilon2>)|. The default is $(\varepsilon_1,\varepsilon_2)=(0.01,0.01)$.
You can also use
\icmd{\settzslopeepsilon}|{<epsilon1>}{<epsilon2>}| \xem{before} the macro |\tzslopeat|, which is valid until the end of the |tikzpicture| environment, unless changed again.
\begin{tzdef}
% syntax: minimum
\tzslopeat{<path>}{<x-val>}{<length>}
% syntax: minimum (for normal line)
\tzslopeat{<path>}{<x-val>}{<length>}[90] % or [-90]
% syntax: full
\tzslopeat[<opt>]{<path>}{<x-val>}(<epsilon1>,<epsilon2>){<length>}[<rotate>]
{<text>}[<node opt>]<code.append>
% defaults
[]{<m>}{<m>}(.01,.01){<m>}[0]{}[]<>
\end{tzdef}
\paragraph{Normal lines}
With the option |[<rotate>]| \xem{immediately after} the last mandatory argument |{<length>}|, you can draw a \iisw{normal line} to a curve by rotating the slope lines |90|\textdegree or |-90|\textdegree.
\begin{tzcode}{.3}
% \tzslopeat: slopes and normals
\begin{tikzpicture}
\tzhelplines*(5,4)
\tzcoors*(0,0)(A)(2,2)(B){B}[b](3.5,1)(C)(5,3)(D);
\tztos[thick]"AA"(A)[out=0,in=180]
(B)[out=0,in=180]
(C)[out=0,in=255]
(D);
\tzslopeat[red]{AA}{1}{3cm}
\tzslopeat[blue]{AA}{2}{2cm}
\tzslopeat{AA}{4}{2cm}{$f'(4)$}[r]
% normal lines: rotate: [90] or [-90]
\tzslopeat[->,blue]{AA}{1}{1cm}[90]
\tzslopeat[->,red]{AA}{2}{2cm}[90]
\tzslopeat[->,red]{AA}{4}{1cm}[-90]{normal}[b]
\end{tikzpicture}
\end{tzcode}
\remark
|\tzslopeat{AA}{2}{2cm}[-180]| is equivalent to |\tzslopeat'{AA}{2}{2cm}|.
\begin{itemize}
\item Without the arrows, |\tzslopeat| and |\tzslopeat'| give the same result except where the labels are placed.
\item
The swap version |\tzslopeat'| does not change its direction with the option |[<rotate>]|.
\end{itemize}
\icmd{\tzslope} is the same as |\tzslopeat|, except for one thing.
|\tzslope| uses a coordinate instead of a value of $x$ to draw slope lines.
So the mandatory arguments of |\tzslope| is |{<path>}|, |(<coor>)|, and |{<length>}|. The $y$ value of |(<x,y>)| is ignored.
\remark
|\tzslope{AA}{2}{2cm}[-180]| is equivalent to |\tzslope'{AA}{2}{2cm}|.
\begin{itemize}
\item Without the arrows, |\tzslope| and |\tzslope'| give the same result except where the labels are placed.
\item
The swap version |\tzslope'| does not change its direction with the option |[<rotate>]|.
\end{itemize}
\icmd{\tznormalat} draws a normal line \xem{from a point} on a graph at $x=\mbox{\texttt{<x-val>}}$.
The mandatory arguments are |{<path>}|, |{<x-val>}|, and |{<length>}|.
By default, the normal lines are drawn on the |behind| layer.
You can change the layer, like \icmd{\settztnormallayer}|{main}|.
\remark The slope of a normal \xem{perpendicular to the slope line} is \xem{approximate} and can be changed by changing the variation interval with the option |(<epsilon1,epsilon2>)|. The default is $(\varepsilon_1,\varepsilon_2)=(0.01,0.01)$.
You can also use
\icmd{\settznormalepsilon}|{<epsilon1>}{<epsilon2>}| \xem{before} the macro |\tznormalat|, which is valid until the end of the |tikzpicture| environment, unless changed again.
\remark
The swap version |\tznormalat'| has a fixed |[<rotate>]| value of |[-90]|.
\begin{itemize}
\item |\tznormalat{AA}{1}{3cm}[-90]| is equivalent to |\tznormalat'{AA}{1}{3cm}|.
\item |\tznomralat'| does not change its direction with the option |[<rotate>]|.
\end{itemize}
The starred version \icmd{\tznormalat*} works like |\tzslopeat|, but rotated |[90]|.
And the swap version \icmd{\tznormalat*'} works like |\tzslopeat|, but rotated |[-90]|.
\remark
The swap version |\tznormalat*'| has a fixed |[<rotate>]| value of |[-90]|.
\begin{itemize}
\item |\tznormalat*{AA}{1}{3cm}[-90]| is equivalent to |\tznormalat*'{AA}{1}{3cm}|.
\item |\tznomralat*'| does not change its direction with the option |[<rotate>]|.
\end{itemize}
\icmd{\tznormal} is the same as |\tznormalat|, except for one thing.
|\tznormal| uses a coordinate instead of a value of $x$ to draw normal lines.
So the mandatory arguments of |\tznormal| is |{<path>}|, |(<coor>)|, and |{<length>}|. The $y$ value of |(<x,y>)| is ignored.
\remark
The swap version |\tznormal'| has a fixed |[<rotate>]| value of |[-90]|.
\begin{itemize}
\item |\tznormal{AA}{1}{3cm}[-90]| is equivalent to |\tznormal'{AA}{1}{3cm}|.
\item |\tznomral'| does not change its direction with the option |[<rotate>]|.
\end{itemize}
The starred version \icmd{\tznormal*} works like |\tzslope|, but rotated |[90]|.
And its swap version \icmd{\tznormal*'} works like |\tzslope|, but rotated |[-90]|.
\remark
The swap version |\tznormal*'| has a fixed |[<rotate>]| value of |[-90]|.
\begin{itemize}
\item |\tznormal*{AA}{1}{3cm}[-90]| is equivalent to |\tznormal*'{AA}{1}{3cm}|.
\item |\tznomral*'| does not change its direction with the option |[<rotate>]|.
\end{itemize}