Skip to content

Commit

Permalink
Extend inverses, and slightly clarify. (modelica#2478)
Browse files Browse the repository at this point in the history
* Extend inverses, and slightly clarify.
  • Loading branch information
HansOlsson committed Apr 9, 2020
1 parent 2d78eb1 commit f95030a
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions chapters/functions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1616,12 +1616,13 @@ \section{Declaring Inverses of Functions}\doublelabel{declaring-inverses-of-func
parameters with and without default value. The restriction is that the
\emph{number of unknown variables} (see \autoref{balanced-models}) in the output formal
parameter of both $f_1$ and $f_2$ must be
the same and that $f_2$ must have exactly the same formal
parameters as $f_1$ (with the same defaults, if a formal
parameter $u_m$ has a default), but the order of the formal
the same and that $f_2$ should have a union of output and formal
parameters that is the same or a sub-set of that union for $f_1$, but the order of the formal
parameters may be permuted.


\begin{example}
Same union of variables:
\begin{lstlisting}[language=modelica]
function h_pTX
input Real p "pressure";
Expand All @@ -1644,6 +1645,31 @@ \section{Declaring Inverses of Functions}\doublelabel{declaring-inverses-of-func
\end{lstlisting}
\end{example}

The sub-set case is useful if $f_1$ computes the inverse of $f_2$ within a region, or up to a certain tolerance.
Then, $f_1$ may specify $f_2$ as inverse with fewer arguments, skipping the arguments for tolerance and/or the region.

\begin{example}

\begin{lstlisting}[language=modelica]
function inv_sine
input Real x;
input Real angleOrig;
output Real angle;
// Finds sine(angle)=x with angle closest to angleOrig.
algorithm
...
annotation(inverse(x=sine(angle)));
end inv_sine;

function sine
input Real angle;
output Real x;
algorithm
x:=sin(angle);
// Note: No inverse.
end sine;
\end{lstlisting}
\end{example}
\section{External Function Interface}\doublelabel{external-function-interface}

Here, the word function is used to refer to an arbitrary external
Expand Down

0 comments on commit f95030a

Please sign in to comment.