\subsection{substitute}
\label{labsubstitute}
\noindent Name: \textbf{substitute}\\
\phantom{aaa}replace the occurrences of the free variable in an expression.\\[0.2cm]
\noindent Library name:\\
\verb|   sollya_obj_t sollya_lib_substitute(sollya_obj_t, sollya_obj_t)|\\[0.2cm]
\noindent Usage: 
\begin{center}
\textbf{substitute}(\emph{f},\emph{g}) : (\textsf{function}, \textsf{function}) $\rightarrow$ \textsf{function}\\
\textbf{substitute}(\emph{f},\emph{t}) : (\textsf{function}, \textsf{constant}) $\rightarrow$ \textsf{constant}\\
\end{center}
Parameters: 
\begin{itemize}
\item \emph{f} is a function.
\item \emph{g} is a function.
\item \emph{t} is a real number.
\end{itemize}
\noindent Description: \begin{itemize}

\item \textbf{substitute}(\emph{f}, \emph{g}) produces the function $(f \circ g) : x \mapsto f(g(x))$.

\item \textbf{substitute}(\emph{f}, \emph{t}) is the constant $f(t)$. Note that the constant is
   represented by its expression until it has been evaluated (exactly the same
   way as if you type the expression \emph{f} replacing instances of the free variable 
   by \emph{t}).

\item If \emph{f} is stored in a variable \emph{F}, the effect of the commands \textbf{substitute}(\emph{F},\emph{g}) or \textbf{substitute}(\emph{F},\emph{t}) is absolutely equivalent to 
   writing \emph{F(g)} resp. \emph{F(t)}.
\end{itemize}
\noindent Example 1: 
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> f=sin(x);
> g=cos(x);
> substitute(f,g);
sin(cos(x))
> f(g);
sin(cos(x))
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 2: 
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> a=1;
> f=sin(x);
> substitute(f,a);
0.84147098480789650665250232163029899962256306079837
> f(a);
0.84147098480789650665250232163029899962256306079837
\end{Verbatim}
\end{minipage}\end{center}
See also: \textbf{evaluate} (\ref{labevaluate}), \textbf{composepolynomials} (\ref{labcomposepolynomials})
