# The most optimal way to solve this set of non-linear equations in high dimensions

So I have a series of non-linear equations which I wish to solve as fast as possible, to illustrate for the case of $n = 4$, I have the following equations:

\begin{gather*} c_0\exp(\lambda_0-1)+f\exp(\lambda_0 + \lambda_1 + \lambda_2 + \lambda_3 + \lambda_4 - 1) = 1 \\ c_1\exp(\lambda_0+\lambda_1-1)+f\exp(\lambda_0 + \lambda_1 + \lambda_2 + \lambda_3 + \lambda_4 - 1) = P_1 \\ c_2\exp(\lambda_0+\lambda_2-1)+f\exp(\lambda_0 + \lambda_1 + \lambda_2 + \lambda_3 + \lambda_4 - 1) = P_2 \\ c_3\exp(\lambda_0+\lambda_3-1)+f\exp(\lambda_0 + \lambda_1 + \lambda_2 + \lambda_3 + \lambda_4 - 1) = P_3 \\ c_4\exp(\lambda_0+\lambda_4-1)+f\exp(\lambda_0 + \lambda_1 + \lambda_2 + \lambda_3 + \lambda_4 - 1) = P_4 \end{gather*} where \begin{gather*} f = \int_{d_4}^{\infty} \int_{d_3}^{\infty} \int_{d_2}^{\infty} \int_{d_1}^{\infty} q(x_1, x_2, x_3, x_4) dx_1 dx_2 dx_3 dx_4 \\ c_0 = \int_{-\infty}^{d_4} \int_{-\infty}^{d_3}\int_{-\infty}^{d_2} \int_{-\infty}^{d_1} q(x_1, x_2, x_3, x_4) dx_1 dx_2 dx_3 dx_4 \\ c_1 = \int_{-\infty}^{d_4} \int_{-\infty}^{d_3}\int_{-\infty}^{d_2} \int_{d_1}^{\infty} q(x_1, x_2, x_3, x_4) dx_1 dx_2 dx_3 dx_4 \\ c_2 = \int_{-\infty}^{d_4} \int_{-\infty}^{d_3}\int_{d_2}^{\infty} \int_{-\infty}^{d_1} q(x_1, x_2, x_3, x_4) dx_1 dx_2 dx_3 dx_4 \\ c_3 = \int_{-\infty}^{d_4} \int_{d_3}^{\infty}\int_{-\infty}^{d_2} \int_{-\infty}^{d_1} q(x_1, x_2, x_3, x_4) dx_1 dx_2 dx_3 dx_4 \\ c_4 = \int_{d_4}^{\infty} \int_{-\infty}^{d_3}\int_{-\infty}^{d_2} \int_{-\infty}^{d_1} q(x_1, x_2, x_3, x_4) dx_1 dx_2 dx_3 dx_4 \\ \end{gather*}

The definitions are as follows:

• $P_1, P_2, P_3, P_4$ are known values.

• $d_1, d_2, d_3, d_4$ are known values.

• $q(x_1, x_2, x_3, x_4)$ is a multivariate normal distribution with mean vector $0$ and a known variance-covariance matrix.

• Thus $f, c_0, c_1, c_2, c_3, c_4$ are all simply real numbers.

For the general case I have:

\begin{gather*} c_0\exp(\lambda_0-1)+f\exp\left(\sum_{i=0}^n \lambda_i - 1\right) = 1 \\ c_1\exp(\lambda_0+\lambda_1-1)+f\exp\left(\sum_{i=0}^n \lambda_i - 1\right) = P_1 \\ c_2\exp(\lambda_0+\lambda_2-1)+f\exp\left(\sum_{i=0}^n \lambda_i - 1\right) = P_2 \\ c_3\exp(\lambda_0+\lambda_3-1)+f\exp\left(\sum_{i=0}^n \lambda_i - 1\right) = P_3 \\ \vdots \\ c_n\exp(\lambda_0+\lambda_n-1)+f\exp\left(\sum_{i=0}^n \lambda_i - 1\right) = P_n \end{gather*} where \begin{gather*} f = \int_{d_n}^{\infty} \cdots \int_{d_3}^{\infty} \int_{d_2}^{\infty} \int_{d_1}^{\infty} q(x_1, x_2, x_3, \cdots, x_n) dx_1 dx_2 dx_3 \cdots dx_n \\ c_0 = \int_{-\infty}^{d_n} \cdots \int_{-\infty}^{d_3}\int_{-\infty}^{d_2} \int_{-\infty}^{d_1} q(x_1, x_2, x_3, \cdots, x_n) dx_1 dx_2 dx_3 \cdots dx_n \\ c_1 = \int_{-\infty}^{d_n} \cdots \int_{-\infty}^{d_3}\int_{-\infty}^{d_2} \int_{d_1}^{\infty} q(x_1, x_2, x_3, \cdots, x_n) dx_1 dx_2 dx_3 \cdots dx_n \\ c_2 = \int_{-\infty}^{d_n} \cdots \int_{-\infty}^{d_3}\int_{d_2}^{\infty} \int_{-\infty}^{d_1} q(x_1, x_2, x_3, \cdots, x_n) dx_1 dx_2 dx_3 \cdots dx_n \\ c_3 = \int_{-\infty}^{d_n} \cdots \int_{d_3}^{\infty}\int_{-\infty}^{d_2} \int_{-\infty}^{d_1} q(x_1, x_2, x_3, \cdots, x_n) dx_1 dx_2 dx_3 \cdots dx_n \\ \vdots \\ c_n = \int_{d_n}^{\infty} \cdots \int_{-\infty}^{d_3}\int_{-\infty}^{d_2} \int_{-\infty}^{d_1} q(x_1, x_2, x_3, \cdots, x_n) dx_1 dx_2 dx_3 \cdots dx_n \\ \end{gather*}

The definitions are as follows:

• $P_1, P_2, P_3, \cdots, P_n$ are known values.

• $d_1, d_2, d_3, \cdots, d_n$ are known values.

• $q(x_1, x_2, x_3, \cdots, x_n)$ is a multivariate normal distribution with mean vector $0$ and a known variance-covariance matrix.

• Thus $f, c_0, c_1, c_2, c_3, \cdots, c_n$ are all simply real numbers.

At most $n$ will be 35, so there will be 36 equations to solve simultaneously. What is the best method to solve this as quickly as possible using whatever programming language possible? Also I will need to change parameter inputs for $P_i$, $d_i$ and the variance covariance matrix and solve for a new set of $\lambda$'s, I will need to do this at least 2000 times, which means effectively I will need to solve a set of 35 equations for 2000 times.

Write

$$x_i = \exp(\lambda_i),\ P_0 = 1,\ b_i = \exp(1) P_i; \ i = 0, 1, 2, \ldots, n.$$

Note that all the $x_i$ are positive (and nonzero). The system of equations is

$$c_0 x_0 + f x_0 x_1 x_2 \cdots x_n = b_0;$$

$$c_i x_i x_0 + f x_0 x_1 x_2 \cdots x_n = b_i, i = 1, 2, \ldots, n.$$

Subtracting the first equation from all the others gives the system

$$c_i x_0 \left(x_i - \frac{c_0}{c_i}\right) = b_i - b_0,\ i = 1, 2, \ldots, n.$$

This has solution

$$x_i = \frac{c_0}{c_i} + \frac{b_i - b_0}{c_i x_0}$$

depending on the (still unknown) $x_0.$ Plug this solution into the first equation and multiply by $x_0^n$:

$$b_0x_0^n = c_0 x_0^{n+1} + fx_0 x_1 \cdots x_n x_0^n = c_0 x_0^{n+1} + f x_0\prod_{i=1}^n \left(\frac{c_0 x_0 + b_i-b_0}{c_i} \right).$$

The solutions are roots of a polynomial of degree $n+1.$ For each positive real root (found using numerical root-finding methods, for instance) there is a set of corresponding values of $x_i$. Provided they are all positive, too, you have found a solution. There may be up to $n+1$ distinct solutions.

• Thanks, but shouldn't the equation after subtraction be $\displaystyle c_ix_0\left(\frac{x_i}{x_0} - \frac{c_0}{c_i}\right)$? Feb 16 '14 at 9:46
• No, that is incorrect--but I see why you might think that: I dropped a factor of $x_0$ when copying the system of equations. I have made an edit to fix it. The left hand side of the difference is $c_i\exp(\lambda_0+\lambda_i)-c_0\exp(\lambda_0)=c_ix_ix_0-c_0x_0.$
– whuber
Feb 16 '14 at 17:21
• If it doesn't work out, please let us know, because there are other possible approaches available (such as rewriting the system to make $(x_0, x_1, \ldots, x_n)$ a fixed point of a multilinear operator).
– whuber
Feb 16 '14 at 18:44
• Thanks, one last thing, should there be a x_0 after the f in your last equation? That is, $fx_0 \prod_{i=1}^n \left(\frac{c_0x_0 + b_i - b_0}{c_i}\right)$, since there are only $n$ $x_0$'s? Feb 16 '14 at 18:49
• Yes, that's correct: I'll make the edit.
– whuber
Feb 16 '14 at 22:10