You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: chapters/functions.tex
+11-6Lines changed: 11 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1483,16 +1483,21 @@ \subsection{Using the Derivative Annotation}\label{using-the-derivative-annotati
1483
1483
1484
1484
\subsection{Partial Derivatives of Functions}\label{partial-derivatives-of-functions}\index{partial derivative}\index{der@\robustinline{der}!partial derivative}
1485
1485
1486
-
A class defined as:
1486
+
A function class defined as follows is a partial derivative of another function:
1487
1487
\begin{lstlisting}[language=grammar]
1488
1488
IDENT "=" der "(" name "," IDENT { "," IDENT } ")" comment
1489
1489
\end{lstlisting}
1490
-
is the partial derivative of a function, and may only be used as declarations of functions.
1491
1490
1492
-
The semantics is that a function (and only a function) can be specified in this form, defining that it is the partial derivative of the function to the right of the equal sign (looked up in the same way as a short class definition, and the looked up name must be a function), and partially differentiated with respect to each {\lstinline!IDENT!} in order (starting from the first one).
1493
-
Each {\lstinline!IDENT!} must be a scalar {\lstinline!Real!} input to the function.
1491
+
In \lstinline!$f$ = der($g$, $u_{1}, \ldots$)!, the function being defined is named $f$, and the function being differentiated is $g$.
1492
+
The name $g$ is looked up in the same way as a in short class definition, and the referenced class must be a function.
1493
+
Each $u_{i}$ must be a scalar {\lstinline!Real!} input to the function, and corresponds mathematically to prepending $\frac{\partial}{\partial u_{i}}$ to the function call.
1494
+
The $u_{i}$ are applied in increasing order of $i$ (although the partial derivatives commute for a broad class of functions).
1494
1495
1495
-
The comment allows a user to comment the function (in the info-layer and as one-line description, and as icon).
1496
+
\begin{nonnormative}
1497
+
In mathematical notation, the order of partial differentiation is reversed compared to the function definition; \lstinline!der($g$, $x$, $y$)! means $\frac{\partial}{\partial y}\frac{\partial}{\partial x}g$.
1498
+
\end{nonnormative}
1499
+
1500
+
The \lstinline[language=grammar]!comment! has the same semantics as in a short class definition, for instance allowing the function to be given a description string, as well as \lstinline!Documentation! and \lstinline!Icon! annotations.
1496
1501
1497
1502
\begin{example}
1498
1503
The specific enthalpy can be computed from a Gibbs-function as follows:
@@ -1511,9 +1516,9 @@ \subsection{Partial Derivatives of Functions}\label{partial-derivatives-of-funct
1511
1516
h := Gibbs(p, T) - T * Gibbs_T(p, T);
1512
1517
end specificEnthalpy;
1513
1518
\end{lstlisting}
1519
+
Thus \lstinline!der(Gibbs, T)! corresponds to $\frac{\partial\text{\lstinline!Gibbs(p, T)!}}{\partial\text{\lstinline!T!}} = \frac{\partial}{\partial\text{\lstinline!T!}}\text{\lstinline!Gibbs!}$.
1514
1520
\end{example}
1515
1521
1516
-
1517
1522
\subsection{Using the Inverse Annotation}\label{using-the-inverse-annotation}
1518
1523
1519
1524
If a function $f_1$ with one output formal parameter $y$ can be restricted to an informally defined domain and codomain, such that the mapping of the input formal parameter $u_{k}$ to $y$ is bijective for any fixed assignment to the other input formal parameters in the domain (see examples below), then it can be given an \fmtannotationindex{inverse} annotation to provide an explicit inverse $f_2$ to this mapping, provided that the function is only applied on this domain:
0 commit comments