Skip to content

Commit 071d398

Browse files
committed
enbrown bugfixes - resolved conflicts, double-checked changes
1 parent 29f1b84 commit 071d398

24 files changed

+867
-1146
lines changed

src/stan-users-guide/algebraic-equations.Rmd

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ to solve nonlinear equations.
1717

1818
As an illustrative example, we consider the following nonlinear system of two equations
1919
with two unknowns:
20-
2120
\begin{align*}
22-
z_1 &= y_1 - \theta_1 \\
23-
z_2 &= y_1 y_2 + \theta_2
21+
z_1 &= y_1 - \theta_1 \\
22+
z_2 &= y_1 y_2 + \theta_2
2423
\end{align*}
2524

2625
Our goal is to simultaneously solve all equations for
@@ -60,8 +59,8 @@ The body of the system function here could also be coded using a row
6059
vector constructor and transposition,
6160

6261
```
63-
return [ y[1] - theta[1],
64-
y[1] * y[2] - theta[2] ]';
62+
return [ y[1] - theta[1],
63+
y[1] * y[2] - theta[2] ]';
6564
```
6665

6766
As systems get more complicated, naming the intermediate expressions
@@ -120,9 +119,9 @@ must only involve parameters. Note there are no restrictions on the initial gues
120119
The Jacobian of the solution with respect to the parameters is computed
121120
using the implicit function theorem, which imposes certain restrictions. In particular,
122121
the Jacobian of the algebraic function $f$ with respect to the unknowns $x$ must
123-
be invertible. This requires the Jacobian to be square, meaning \textit{$f(y)$ and
124-
$y$ have the same length} or, in other words \textit{the number of equations in
125-
the system is the same as the number of unknowns.}
122+
be invertible. This requires the Jacobian to be square, meaning $f(y)$ and
123+
$y$ have the same length or, in other words *the number of equations in
124+
the system is the same as the number of unknowns.*
126125

127126
### Pathological Solutions {-}
128127
Certain systems may be degenerate, meaning they have multiple solutions. The
@@ -142,15 +141,15 @@ allows three additional parameters, all of which must be supplied if any of them
142141
supplied.
143142

144143
```
145-
y = algebra_solver(system, y_guess, theta, x_r, x_i,
146-
rel_tol, f_tol, max_steps);
144+
y = algebra_solver(system, y_guess, theta, x_r, x_i,
145+
rel_tol, f_tol, max_steps);
147146
```
148147

149148
The three control arguments are relative tolerance, function tolerance, and maximum
150149
number of steps. Both tolerances need to be satisfied. If one of them is not met, the
151150
metropolis proposal gets rejected with a warning message explaining which criterion
152151
was not satisfied. The default values for the control arguments are respectively
153-
`1e-10` ($10^{-10}$), `1e-6` ($10^{-6}$), and `1e3` ($10^3$).
152+
`rel_tol = 1e-10` ($10^{-10}$), `f_tol = 1e-6` ($10^{-6}$), and `max_steps = 1e3` ($10^3$).
154153

155154
### Tolerance {-}
156155

0 commit comments

Comments
 (0)