Solution of 2-D Nonlinear System

3 downloads 0 Views 377KB Size Report
F(1) = exp(-exp(-(x(1)+x(2)))) - x(2)*(1+x(1)^2);. F(2) = x(1)*cos(x(2)) + x(2)*sin(x(1)) - 0.5;. Save this code as a file named root2d.m on your MATLAB® path.
Solution of 2-D Nonlinear System This example shows how to solve two nonlinear equations in two variables. The equations are

Convert the equations to the form

.

Write a function that computes the left-hand side of these two equations. function F = root2d(x) F(1) = exp(-exp(-(x(1)+x(2)))) - x(2)*(1+x(1)^2); F(2) = x(1)*cos(x(2)) + x(2)*sin(x(1)) - 0.5;

Save this code as a file named root2d.m on your MATLAB® path. Solve the system of equations starting at the point [0,0]. fun = @root2d; x0 = [0,0]; x = fsolve(fun,x0) Equation solved. fsolve completed because the vector of function values is near zero as measured by the default value of the function tolerance, and the problem appears regular as measured by the gradient.

x = 0.3532

0.6061

Suggest Documents