Nonlinear equations

We provide a variety of non-linear equations used for testing numerical optimization algorithms.


temfpy.nonlinear_equations.broyden(x, a=(3, 0.5, 2, 1), jac=False)[source]

Broyden tridiagonal function.

\[\begin{split}x &\mapsto \begin{pmatrix} F_1(x) & F_2(x) & \dots & F_p(x) \end{pmatrix}^T \\ F_1(x) &= x_1(a_1 - a_2 x_1) -a_3 x_{2} + a_4 \\ F_i(x) &= x_i(a_1 - a_2 x_i)-x_{i-1} -a_3 x_{i+1} + a_4 \\ & \quad i = 2,3, \dots, p-1 \\ F_p(x) &= x_p(a_1 - a_2 x_p)-x_{p-1} + a_4\end{split}\]
Parameters
  • x (array_like) – Input domain with dimension \(p > 1\).

  • a (array_like, optional) – The default array is (3, 0.5, 2, 1).

  • jac (bool) – If True, an additional array containing the numerically derived Jacobian and the analytically derived Jacobian is returned. The default is False.

Returns

  • array_like – Output domain

  • array_like – Only returned if \(jac = True\). Tuple containing the analytically derived Jacobian and the numerically derived Jacobian.

References

V2009

Varadhan, R., and Gilbert, P. D. (2009). BB: An R package for solving a large system of nonlinear equations and for optimizing a high-dimensional nonlinear objective function. Journal of Statistical Software, 32(1): 1–26.

Examples

>>> import numpy as np
>>> from temfpy.nonlinear_equations import broyden
>>>
>>> np.random.seed(123)
>>> p = np.random.randint(3,20)
>>> x = np.zeros(p)
>>> np.allclose(broyden(x), np.repeat(1,p))
True
temfpy.nonlinear_equations.chandrasekhar(x, y, c, jac=False)[source]

Discretized version of Chandrasekhar’s H-equation.

\[\begin{split}x &\mapsto \begin{pmatrix} F_1(x) & F_2(x) & \dots & F_p(x) \end{pmatrix}^T \\ F_i(x) &= x_i - \left(1 - \frac{c}{2p} \sum^p_{j=1} \frac{y_i x_j}{y_i + y_j} \right)^{-1} \\ & \quad i = 1,2, \dots, p\end{split}\]
Parameters
  • x (array_like) – Input domain with dimension \(p\).

  • y (array_like,) – Array of constants with dimension \(p\).

  • c (float) – Constant parameter.

  • jac (bool) – If True, an additional array containing the numerically derived Jacobian and the analytically derived Jacobian is returned. The default is False.

Returns

  • array_like – Output domain

  • array_like – Only returned if \(jac = True\). Tuple containing the analytically derived Jacobian and the numerically derived Jacobian. Numerically derived Jacobian returned only if dimension \(p > 1\).

References

V2009

Varadhan, R., and Gilbert, P. D. (2009). BB: An R package for solving a large system of nonlinear equations and for optimizing a high-dimensional nonlinear objective function. Journal of Statistical Software, 32(1): 1–26.

Examples

>>> import numpy as np
>>> from temfpy.nonlinear_equations import chandrasekhar
>>>
>>> np.random.seed(123)
>>> p = np.random.randint(1,20)
>>> x = np.repeat(2,p)
>>> y = np.repeat(1,p)
>>> c = 1
>>> np.allclose(chandrasekhar(x,y,c), np.zeros(p))
True
temfpy.nonlinear_equations.exponential(x, a=10, b=1, jac=False)[source]

Exponential function.

\[\begin{split}x &\mapsto \begin{pmatrix} F_1(x) & F_2(x) & \dots & F_p(x) \end{pmatrix}^T \\ F_1(x) &= e^{x_1} - b \\ F_i(x) &= \frac{i}{a} (e^{x_i} +x_{i-1}) - b \\ & \quad i = 2,3, \dots, p\end{split}\]
Parameters
  • x (array_like) – Input domain with dimension \(p\).

  • a (float, optional) – The default value is 10.

  • b (float, optional) – The default value is 1.

  • jac (bool) – If True, an additional array containing the numerically derived Jacobian and the analytically derived Jacobian is returned. The default is False.

Returns

  • array_like – Output domain

  • array_like – Only returned if \(jac = True\). Tuple containing the analytically derived Jacobian and the numerically derived Jacobian.

References

V2009

Varadhan, R., and Gilbert, P. D. (2009). BB: An R package for solving a large system of nonlinear equations and for optimizing a high-dimensional nonlinear objective function. Journal of Statistical Software, 32(1): 1–26.

Examples

>>> import numpy as np
>>> from temfpy.nonlinear_equations import exponential
>>>
>>> np.random.seed(123)
>>> p = np.random.randint(1,20)
>>> x = np.zeros(p)
>>> np.allclose(exponential(x), np.zeros(p))
True
temfpy.nonlinear_equations.rosenbrock_ext(x, a=(10, 1), jac=False)[source]

Extended-Rosenbrock function.

\[\begin{split}x &\mapsto \begin{pmatrix} F_1(x) & F_2(x) & \dots & F_p(x) \end{pmatrix}^T \\ F_{2i-1}(x) &= a_1(x_{2i} - x_{2i-1}^2) \\ F_{2i}(x) &= a_2 - x_{2i-1}, \\ & \quad i = 1,2,3, \dots, \frac{p}{2}\end{split}\]
Parameters
  • x (array_like) – Input domain with even dimension \(p > 1\).

  • a (array_like, optional) – The default array is (10,1).

  • jac (bool) – If True, an additional array containing the numerically derived Jacobian and the analytically derived Jacobian is returned. The default is False.

Returns

  • array_like – Output domain

  • array_like – Only returned if \(jac = True\). Tuple containing the analytically derived Jacobian and the numerically derived Jacobian.

References

V2009

Varadhan, R., and Gilbert, P. D. (2009). BB: An R package for solving a large system of nonlinear equations and for optimizing a high-dimensional nonlinear objective function. Journal of Statistical Software, 32(1): 1–26.

Examples

>>> import numpy as np
>>> from temfpy.nonlinear_equations import rosenbrock_ext
>>>
>>> np.random.seed(123)
>>> p = 2*np.random.randint(1,20)
>>> x = np.zeros(p)
>>> compare = np.resize([0,1], p)
>>> np.allclose(rosenbrock_ext(x), compare)
True
temfpy.nonlinear_equations.trig_exp(x, a=(3, 2, 5, 4, 3, 2, 8, 4, 3), jac=False)[source]

Trigonometrical exponential function.

\[\begin{split}x &\mapsto \begin{pmatrix} F_1(x) & F_2(x) & \dots & F_p(x) \end{pmatrix}^T \\ F_1(x) &= a_1x_1^3 + a_2x_2 - a_3 + \sin(x_1 - x_2)\sin(x_1+x_2) \\ F_i(x) &= - x_{i-1}e^{x_{i-1} - x_i} + x_i(a_4+a_5x_i^2) + a_6x_{i+1} \\ & \quad + \sin(x_i - x_{i+1})\sin(x_i + x_{i+1}) - a_7 \\ & \quad i = 2,3, \dots, p-1 \\ F_p(x) &= -x_{p-1}e^{x_{p-1}-x_p} + a_8x_p - a_9\end{split}\]
Parameters
  • x (array_like) – Input domain with dimension \(p > 1\).

  • a (array_like, optional) – The default array is (3,2,5,4,3,2,8,4,3).

  • jac (bool) – If True, an additional array containing the numerically derived Jacobian and the analytically derived Jacobian is returned. The default is False.

Returns

  • array_like – Output domain

  • array_like – Only returned if \(jac = True\). Tuple containing the analytically derived Jacobian and the numerically derived Jacobian.

References

V2009

Varadhan, R., and Gilbert, P. D. (2009). BB: An R package for solving a large system of nonlinear equations and for optimizing a high-dimensional nonlinear objective function. Journal of Statistical Software, 32(1): 1–26.

Examples

>>> import numpy as np
>>> from temfpy.nonlinear_equations import trig_exp
>>>
>>> np.random.seed(123)
>>> p = np.random.randint(3,20)
>>> x = np.zeros(p)
>>> compare = np.insert(np.array([-5,-3]), 1, np.repeat(-8, p-2))
>>> np.allclose(trig_exp(x), compare)
True
temfpy.nonlinear_equations.troesch(x, rho=10, a=2, jac=False)[source]

Troesch function.

\[\begin{split}x &\mapsto \begin{pmatrix} F_1(x) & F_2(x) & \dots & F_p(x) \end{pmatrix}^T \\ h &= \frac{1}{p+1} \\ F_1(x) &= ax_1 + \rho h^2 \sinh(\rho x_1) - x_{2}, \\ F_i(x) &= ax_i + \rho h^2 \sinh(\rho x_i) - x_{i-1} - x_{i+1} \\ & \quad i = 2,3, \dots, p-1 \\ F_p(x) &= ax_p + \rho h^2 \sinh(\rho x_p) - x_{p-1}\end{split}\]
Parameters
  • x (array_like) – Input domain with dimension \(p > 1\).

  • rho (float, optional) – The default value is 10.

  • a (float, optional) – The default value is 2.

  • jac (bool) – If True, an additional array containing the numerically derived Jacobian and the analytically derived Jacobian is returned. The default is False.

Returns

  • array_like – Output domain

  • array_like – Only returned if \(jac = True\). Tuple containing the analytically derived Jacobian and the numerically derived Jacobian.

References

V2009

Varadhan, R., and Gilbert, P. D. (2009). BB: An R package for solving a large system of nonlinear equations and for optimizing a high-dimensional nonlinear objective function. Journal of Statistical Software, 32(1): 1–26.

Examples

>>> import numpy as np
>>> from temfpy.nonlinear_equations import troesch
>>>
>>> np.random.seed(123)
>>> p = np.random.randint(1,20)
>>> x = np.zeros(p)
>>> np.allclose(troesch(x), np.zeros(p))
True