I created a graph of the sigmoid function using the following tikz code:
\documentclass{minimal}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}%
[
grid=major,
xmin=-6,
xmax=6,
axis x line=bottom,
ytick={0,.5,1},
ymax=1,
axis y line=middle,
]
\addplot%
[
blue,%
mark=none,
samples=100,
domain=-6:6,
]
(x,{1/(1+exp(-x))});
\end{axis}
\end{tikzpicture}
\end{document}
Is it possible to add the derivative of the sigmoid function to the graph using a red dotted line, including a legend in the topright corner for both lines without leaving the tikz environment?
Sigmoid function: σ = 1/(1+exp(-x))
Derivative: σ(x)(1−σ(x)
Best Answer
The arguably most convenient way is to declare functions with the
declare function
key, and plot them.