package com.imsl.test.example.math; import com.imsl.math.*; /** *
* Solves a system of nonlinear equations.
* * This example solves the following system of nonlinear equations: * $$ * \begin{align} * y_0 &= x_0 + \exp(x_0-1.0) + (x_1+x_2)^2-27.0 \\ * y_1 &= \exp(x_1-2.0)/x_0 + x_2^2 - 10.0 \\ * y_2 &= x_2 + \sin(x_1-2.0) + x_1^2 - 7.0 * \end{align} * $$ * * @see Code * @see Output */ public class ZeroSystemEx1 { public static void main(String args[]) throws com.imsl.IMSLException { ZeroSystem.Function fcn = new ZeroSystem.Function() { @Override public void f(double x[], double f[]) { f[0] = x[0] + Math.exp(x[0] - 1.0) + (x[1] + x[2]) * (x[1] + x[2]) - 27.0; f[1] = Math.exp(x[1] - 2.0) / x[0] + x[2] * x[2] - 10.0; f[2] = x[2] + Math.sin(x[1] - 2.0) + x[1] * x[1] - 7.0; } }; ZeroSystem zf = new ZeroSystem(3); double guess[] = {4, 4, 4}; zf.setGuess(guess); new PrintMatrix("zeros").print(zf.solve(fcn)); } }