The following nonlinear equations contain terms that are oft

The following nonlinear equations contain terms that are often found in the power flow equations: f_1(x) = 10x_1 sin x_2 + 2 = 0 f_2(x) = 10 (x_1)^2 - 10x_1 cos x_2 + 1 = 0 Solve using the Newton-Raphson method starting with an initial guess of x_1 (0) = 1 and x_2(0) = 0 radians and a stopping criteria of epsilon = 10^-4.

Solution

clc,clear
% Newton Raphson solution of two nonlinear algebraic equations
% set up the iteration
error1 = 1.e-4;
xx(1) = 1; % initial guesses
xx(2) = 0;
iter=0;
maxiter=40
% begin iteration
while error1>1.e-12
iter=iter+1;
x1 = xx(1);
x2= xx(2);
% calculate the functions
f(1) = 10*x1*sin(x2)+2;
f(2) = 10*x1^2-10*x1*cos(x2)+1;
% calculate the Jacobian
J(1,1) = 10*sin(x2);
J(1,2) = 10*x1*cos(x2);
J(2,1) = 20*x1-10*cos(x2);
J(2,2) = 10*x1*sin(x2);
% solve the linear equations
y = -J\\f\';
% move the solution, xx(k+1) - xx(k), to xx(k+1)
xx = xx + y\';
% calculate norms
error1=sqrt(y(1)^2+y(2)^2);
error(iter)=sqrt(f(1)^2+f(2)^2);
ii(iter)=iter;
if (iter > maxiter)
error1 = 0;
s=sprintf(\'****Did not converge within %3.0f iterations.****\',maxiter);
disp(s)
end
% check if error1 < 1.e-12
end
x1 = xx(1);
x2 = xx(2);
f(1) = 10*x1*sin(x2)+2;
f(2) = 10*x1^2-10*x1*cos(x2)+1;
% print results
f
xx
iter
% plot results
semilogy(ii,error)
xlabel(\'iteration number\')
ylabel(\'norm of functions\')
clear ii
clear error

RESULT:

maxiter =

40


xx =

0.8554 -0.2360


iter =

6

 The following nonlinear equations contain terms that are often found in the power flow equations: f_1(x) = 10x_1 sin x_2 + 2 = 0 f_2(x) = 10 (x_1)^2 - 10x_1 co
 The following nonlinear equations contain terms that are often found in the power flow equations: f_1(x) = 10x_1 sin x_2 + 2 = 0 f_2(x) = 10 (x_1)^2 - 10x_1 co

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site