SlideShare une entreprise Scribd logo
1  sur  18
1
SSoolluuttiioonn ooff nnoonn--lliinneeaarr eeqquuaattiioonnss
By Gilberto E. Urroz, September 2004
In this document I present methods for the solution of single non-linear equations as well
as for systems of such equations.
SSoolluuttiioonn ooff aa ssiinnggllee nnoonn--lliinneeaarr eeqquuaattiioonn
Equations that can be cast in the form of a polynomial are referred to as algebraic
equations. Equations involving more complicated terms, such as trigonometric,
hyperbolic, exponential, or logarithmic functions are referred to as transcendental
equations. The methods presented in this section are numerical methods that can be
applied to the solution of such equations, to which we will refer, in general, as non-linear
equations. In general, we will we searching for one, or more, solutions to the equation,
f(x) = 0.
We will present the Newton-Raphson algorithm, and the secant method. In the secant
method we need to provide two initial values of x to get the algorithm started. In the
Newton-Raphson methods only one initial value is required.
Because the solution is not exact, the algorithms for any of the methods presented herein
will not provide the exact solution to the equation f(x) = 0, instead, we will stop the
algorithm when the equation is satisfied within an allowed tolerance or error, ε. In
mathematical terms this is expressed as
|f(xR)| < ε.
The value of x for which the non-linear equation f(x)=0 is satisfied, i.e., x = xR, will be
the solution, or root, to the equation within an error of ε units.
The Newton-Raphson method
Consider the Taylor-series expansion of the function f(x) about a value x = xo:
f(x)= f(xo)+f'(xo)(x-xo)+(f"(xo)/2!)(x-xo)2+….
Using only the first two terms of the expansion, a first approximation to the root of the
equation
f(x) = 0
can be obtained from
f(x) = 0 ≈ f(xo)+f'(xo)(x1 -xo)
2
Such approximation is given by,
x1 = xo - f(xo)/f'(xo).
The Newton-Raphson method consists in obtaining improved values of the approximate
root through the recurrent application of equation above. For example, the second and
third approximations to that root will be given by
x2 = x1 - f(x1)/f'(x1),
and
x3= x2 - f(x2)/f'(x2),
respectively.
This iterative procedure can be generalized by writing the following equation, where i
represents the iteration number:
xi+1 = xi - f(xi)/f'(xi).
After each iteration the program should check to see if the convergence condition,
namely,
|f(x i+1)|<ε,
is satisfied.
The figure below illustrates the way in which the solution is found by using the Newton-
Raphson method. Notice that the equation f(x) = 0 ≈ f(xo)+f'(xo)(x1 -xo) represents a
straight line tangent to the curve y = f(x) at x = xo. This line intersects the x-axis (i.e., y =
f(x) = 0) at the point x1 as given by x1 = xo - f(xo)/f'(xo). At that point we can construct
another straight line tangent to y = f(x) whose intersection with the x-axis is the new
approximation to the root of f(x) = 0, namely, x = x2. Proceeding with the iteration we
can see that the intersection of consecutive tangent lines with the x-axis approaches the
actual root relatively fast.
3
The Newton-Raphson method converges relatively fast for most functions regardless of
the initial value chosen. The main disadvantage is that you need to know not only the
function f(x), but also its derivative, f'(x), in order to achieve a solution. The secant
method, discussed in the following section, utilizes an approximation to the derivative,
thus obviating such requirement.
The programming algorithm of any of these methods must include the option of stopping
the program if the number of iterations grows too large. How large is large? That will
depend of the particular problem solved. However, any Newton-Raphson, or secant
method solution that takes more than 1000 iterations to converge is either ill-posed or
contains a logical error. Debugging of the program will be called for at this point by
changing the initial values provided to the program, or by checking the program's logic.
AA MMAATTLLAABB ffuunnccttiioonn ffoorr tthhee NNeewwttoonn--RRaapphhssoonn mmeetthhoodd
The function newton, listed below, implements the Newton-Raphson algorithm. It uses
as arguments an initial value and expressions for f(x) and f'(x).
function [x,iter]=newton(x0,f,fp)
% newton-raphson algorithm
N = 100; eps = 1.e-5; % define max. no. iterations and error
maxval = 10000.0; % define value for divergence
xx = x0;
while (N>0)
xn = xx-f(xx)/fp(xx);
if abs(f(xn))<eps
x=xn;iter=100-N;
return;
end;
if abs(f(xx))>maxval
disp(['iterations = ',num2str(iter)]);
error('Solution diverges');
break;
end;
N = N - 1;
xx = xn;
end;
error('No convergence');
break;
% end function
We will use the Newton-Raphson method to solve for the equation, f(x) = x3
-2x2
+1 = 0.
The following MATLAB commands define the function f001(x) and its derivative,
f01p(x):
»f001 = inline('x.^3-2*x.^2+1','x')
f001 =
Inline function:
f001(x) = x.^3-2*x.^2+1
4
» f01p = inline('3*x.^2-2','x')
f01p =
Inline function:
f01p(x) = 3*x.^2-2
To have an idea of the location of the roots of this polynomial we'll plot the function
using the following MATLAB commands:
» x = [-0.8:0.01:2.0]';y=f001(x);
» plot(x,y);xlabel('x');ylabel('f001(x)');
» grid on
-1 -0.5 0 0.5 1 1.5 2
-1
-0.5
0
0.5
1
x
f001(x)
We see that the function graph crosses the x-axis somewhere between –1.0 and –0.5,
close to 1.0, and between 1.5 and 2.0. To activate the function we could use, for
example, an initial value x0 = 2:
» [x,iterations] = newton(2,f001,f01p)
x = 1.6180
iterations = 39
The following command are aimed at obtaining vectors of the solutions provided by
function newton.m for f001(x)=0 for initial values in the vector x0 such that –20 < x0 <
20. The solutions found are stored in variable xs while the required number of iterations
is stored in variable is.
» x0 = [-20:0.5:20]; xs = []; is = [];
EDU» for i = 1:length(x0)
[xx,ii] = newton(x0(i),f001,f01p);
xs = [xs,xx]; is = [is,ii];
end
Plot of xs vs. x0, and of is vs. x0 are shown next:
5
» figure(1);plot(x0,xs,'o');hold;plot(x0,xs,'-');hold;
» title('Newton-Raphson solution');
» xlabel('initial guess, x0');ylabel('solution, xs');
-20 -15 -10 -5 0 5 10 15 20
1
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
Newton-Raphson solution
initial guess, x0
solution,xs
This figure shows that for initial guesses in the range –20 < xo<20, function newton.m
converges mainly to the solution x = 1.6180, with few instances converting to the
solutions x = -1 and x = 1.
» figure(2);plot(x0,is,'+'); hold;plot(x0,is,'-');hold;
» title('Newton-Raphson solution');
» xlabel('initial guess, x0');ylabel('iterations, is');
-20 -15 -10 -5 0 5 10 15 20
0
10
20
30
40
50
60
70
Newton-Raphson solution
initial guess, x0
iterations,is
This figure shows that the number of iterations required to achieve a solution ranges from
0 to about 65. Most of the time, about 50 iterations are required. The following example
shows a case in which the solution actually diverges:
6
» [x,iter] = newton(-20.75,f001,f01p)
iterations = 6
??? Error using ==> newton
Solution diverges
NOTE: If the function of interest is defined by an m-file, the reference to the function
name in the call to newton.m should be placed between quotes.
The Secant Method
In the secant method, we replace the derivative f'(xi) in the Newton-Raphson method with
f'(xi) ≈ (f(xi) - f(xi-1))/(xi - xi-1).
With this replacement, the Newton-Raphson algorithm becomes
To get the method started we need two values of x, say xo and x1, to get the first
approximation to the solution, namely,
As with the Newton-Raphson method, the iteration is stopped when
|f(x i+1)|<ε.
Figure 4, below, illustrates the way that the secant method approximates the solution of
the equation f(x) = 0.
).(
)()(
)(
1
1
1 −
−
+ −⋅
−
−= ii
ii
i
ii xx
xfxf
xf
xx
).(
)()(
)(
01
1
1
12 xx
xfxf
xf
xx
o
−⋅
−
−=
7
AA MMAATTLLAABB ffuunnccttiioonn ffoorr tthhee sseeccaanntt mmeetthhoodd
The function secant, listed below, uses the secant method to solve for non-linear
equations. It requires two initial values and an expression for the function, f(x).
function [x,iter]=secant(x0,x00,f)
% newton-raphson algorithm
N = 100; eps = 1.e-5; % define max. no. iterations and error
maxval = 10000.0; % define value for divergence
xx1 = x0; xx2 = x00;
while N>0
gp = (f(xx2)-f(xx1))/(xx2-xx1);
xn = xx1-f(xx1)/gp;
if abs(f(xn))<eps
x=xn;
iter = 100-N;
return;
end;
if abs(f(xn))>maxval
iter=100-N;
disp(['iterations = ',num2str(iter)]);
error('Solution diverges');
abort;
end;
N = N - 1;
xx1 = xx2;
xx2 = xn;
end;
iter=100-N;
disp(['iterations = ',iter]);
error('No convergence');
abort;
% end function
AApppplliiccaattiioonn ooff sseeccaanntt mmeetthhoodd
We use the same function f001(x) = 0 presented earlier. The following commands call
the function secant.txt to obtain a solution to the equation:
» [x,iter] = secant(-10.0,-9.8,f001)
x = -0.6180
iter = 11
The following command are aimed at obtaining vectors of the solutions provided by
function Newton.m for f001(x)=0 for initial values in the vector x0 such that –20 < x0 <
20. The solutions found are stored in variable xs while the required number of iterations
is stored in variable is.
8
» x0 = [-20:0.5:20]; x00 = x0 + 0.5; xs = []; is = [];
» for i = 1:length(x0)
[xx,ii] = secant(x0(i),x00(i),f001);
xs = [xs, xx]; is = [is, ii];
end
Plot of xs vs. x0, and of is vs. x0 are shown next:
» figure(1);plot(x0,xs,'o');hold;plot(x0,xs,'-');hold;
» title('Secant method solution');
» xlabel('first initial guess, x0');ylabel('solution, xs');
-20 -15 -10 -5 0 5 10 15 20
-1
-0.5
0
0.5
1
1.5
2
Secant method solution
first initial guess, x0
solution,xs
This figure shows that for initial guesses in the range –20 < xo<20, function newton.m
converges to the three solutions. Notice that initial guesses in the range –20 < x0 < -1,
converge to x = - 0.6180; those in the range –1< x < 1, converge to x = 1; and, those in
the range 1<x<20, converge to x =1.6180.
» figure(2);plot(x0,is,'o');hold;plot(x0,is,'-');hold;
» xlabel('first initial guess, x0');ylabel('iterations, is');
» title('Secant method solution');
-20 -15 -10 -5 0 5 10 15 20
0
5
10
15
first initial guess, x0
iterations,is
Secant method solution
9
This figure shows that the number of iterations required to achieve a solution ranges
from 0 to about 15. Notice also that, the closer the initial guess is to zero, the less
number of iterations to convergence are required.
NOTE: If the function of interest is defined by an m-file, the reference to the function
name in the call to newton.m should be placed between quotes.
SSoollvviinngg ssyysstteemmss ooff nnoonn--lliinneeaarr eeqquuaattiioonnss
Consider the solution to a system of n non-linear equations in n unknowns given by
f1(x1,x2,…,xn) = 0
f2(x1,x2,…,xn) = 0
.
.
.
fn(x1,x2,…,xn) = 0
The system can be written in a single expression using vectors, i.e.,
f(x) = 0,
where the vector x contains the independent variables, and the vector f contains the
functions fi(x):
.
)(
)(
)(
),...,,(
),...,,(
),...,,(
)(, 2
1
21
212
211
2
1












=












=












=
x
x
x
xfx
nnn
n
n
n f
f
f
xxxf
xxxf
xxxf
x
x
x
MMM
Newton-Raphson method to solve systems of non-linear equations
A Newton-Raphson method for solving the system of linear equations requires the
evaluation of a matrix, known as the Jacobian of the system, which is defined as:
.][
///
///
///
),...,,(
),...,,(
21
22212
12111
21
21
nn
j
i
nnnn
n
n
n
n
x
f
xfxfxf
xfxfxf
xfxfxf
xxx
fff
×
∂
∂
=












∂∂∂∂∂∂
∂∂∂∂∂∂
∂∂∂∂∂∂
=
∂
∂
=
L
MOMM
L
L
J
If x = x0 (a vector) represents the first guess for the solution, successive approximations
to the solution are obtained from
xn+1 = xn - J-1
⋅f(xn) = xn - ∆xn,
with ∆xn = xn+1 - xn.
10
A convergence criterion for the solution of a system of non-linear equation could be, for
example, that the maximum of the absolute values of the functions fi(xn) is smaller than a
certain tolerance ε, i.e.,
.|)(|max ε<ni
i
f x
Another possibility for convergence is that the magnitude of the vector f(xn) be smaller
than the tolerance, i.e.,
|f(xn)| < ε.
We can also use as convergence criteria the difference between consecutive values of the
solution, i.e.,
.,|)()(|max 1 ε<−+ nini
i
xx
or,
|∆xn | = |xn+1 - xn| < ε.
The main complication with using Newton-Raphson to solve a system of non-linear
equations is having to define all the functions ∂fi/∂xj, for i,j = 1,2, …, n, included in the
Jacobian. As the number of equations and unknowns, n, increases, so does the number
of elements in the Jacobian, n2
.
MATLAB function for Newton-Raphson method for a system of non-linear equations
The following MATLAB function, newtonm, calculates the solution to a system of n non-
linear equations, f(x) = 0, given the vector of functions f and the Jacobian J, as well as an
initial guess for the solution x0.
function [x,iter] = newtonm(x0,f,J)
% Newton-Raphson method applied to a
% system of linear equations f(x) = 0,
% given the jacobian function J, with
% J = del(f1,f2,...,fn)/del(x1,x2,...,xn)
% x = [x1;x2;...;xn], f = [f1;f2;...;fn]
% x0 is an initial guess of the solution
N = 100; % define max. number of iterations
epsilon = 1e-10; % define tolerance
maxval = 10000.0; % define value for divergence
xx = x0; % load initial guess
while (N>0)
JJ = feval(J,xx);
if abs(det(JJ))<epsilon
error('newtonm - Jacobian is singular - try new x0');
abort;
end;
xn = xx - inv(JJ)*feval(f,xx);
11
if abs(feval(f,xn))<epsilon
x=xn;
iter = 100-N;
return;
end;
if abs(feval(f,xx))>maxval
iter = 100-N;
disp(['iterations = ',num2str(iter)]);
error('Solution diverges');
abort;
end;
N = N - 1;
xx = xn;
end;
error('No convergence after 100 iterations.');
abort;
% end function
The functions f and the Jacobian J need to be defined as separate functions. To illustrate
the definition of the functions consider the system of non-linear equations:
f1(x1,x2) = x1
2
+ x2
2
- 50 = 0,
f2(x1,x2) = x1 ⋅ x2 - 25 = 0,
whose Jacobian is
.
22
12
21
2
2
1
2
2
1
1
1






=












∂
∂
∂
∂
∂
∂
∂
∂
=
xx
xx
x
f
x
f
x
f
x
f
J
We can define the function f as the following user-defined MATLAB function f2:
function [f] = f2(x)
% f2(x) = 0, with x = [x(1);x(2)]
% represents a system of 2 non-linear equations
f1 = x(1)^2 + x(2)^2 - 50;
f2 = x(1)*x(2) -25;
f = [f1;f2];
% end function
The corresponding Jacobian is calculated using the user-defined MATLAB function
jacob2x2:
function [J] = jacob2x2(x)
% Evaluates the Jacobian of a 2x2
% system of non-linear equations
J(1,1) = 2*x(1); J(1,2) = 2*x(2);
J(2,1) = x(2); J(2,2) = x(1);
% end function
12
Illustrating the Newton-Raphson algorithm for a system of two non-linear equations
Before using function newtonm, we will perform some step-by-step calculations to
illustrate the algorithm. We start by defining an initial guess for the solution as:
» x0 = [2;1]
x0 =
2
1
Let’s calculate the function f(x) at x = x0 to see how far we are from a solution:
» f2(x0)
ans =
-45
-23
Obviously, the function f(x0) is far away from being zero. Thus, we proceed to calculate
a better approximation by calculating the Jacobian J(x0):
» J0 = jacob2x2(x0)
J0 =
4 2
1 2
The new approximation to the solution, x1, is calculated as:
» x1 = x0 - inv(J0)*f2(x0)
x1 =
9.3333
8.8333
Evaluating the functions at x1 produces:
f2(x1)
ans = 115.1389
Still far away from convergence. Let’s calculate a new approximation, x2:
» x2 = x1-inv(jacob2x2(x1))*f2(x1)
x2 =
6.0428
5.7928
13
Evaluating the functions at x2 indicates that the values of the functions are decreasing:
» f2(x2)
ans =
20.0723
10.0049
A new approximation and the corresponding function evaluations are:
» x3 = x2 - inv(jacob2x2(x2))*f2(x2)
x3 =
5.1337
5.0087
E» f2(x3)
ans =
1.4414
0.7129
The functions are getting even smaller suggesting convergence towards a solution.
Solution using function newtonm
Next, we use function newtonm to solve the problem postulated earlier.
A call to the function using the values of x0, f2, and jacob2x2 is:
» [x,iter] = newtonm(x0,'f2','jacob2x2')
x =
5.0000
5.0000
iter =
16
The result shows the number of iterations required for convergence (16) and the solution
found as x1 = 5.0000 and x2 = 5.000. Evaluating the functions for those solutions results
in:
» f2(x)
ans =
1.0e-010 *
0.2910
-0.1455
14
The values of the functions are close enough to zero (error in the order of 10-11
).
“Secant” method to solve systems of non-linear equations
In this section we present a method for solving systems of non-linear equations through
the Newton-Raphson algorithm, namely, xn+1 = xn - J-1
⋅f(xn), but approximating the
Jacobian through finite differences. This approach is a generalization of the secant
method for a single non-linear equation. For that reason, we refer to the method applied
to a system of non-linear equations as a “secant” method, although the geometric origin
of the term not longer applies.
The “secant” method for a system of non-linear equations free us from having to define
the n2
functions necessary to define the Jacobian for a system of n equations. Instead, we
approximate the partial derivatives in the Jacobian with
,
),,,,,(),,,,,( 2121
x
xxxxfxxxxxf
x
f njinji
j
i
∆
−∆+
≈
∂
∂ LLLL
where ∆x is a small increment in the independent variables. Notice that ∂fi/∂xj represents
element Jij in the jacobian J = ∂(f1,f2,…,fn)/∂(x1,x2,…,xn).
To calculate the Jacobian we proceed by columns, i.e., column j of the Jacobian will be
calculated as shown in the function jacobFD (jacobian calculated through Finite
Differences) listed below:
function [J] = jacobFD(f,x,delx)
% Calculates the Jacobian of the
% system of non-linear equations:
% f(x) = 0, through finite differences.
% The Jacobian is built by columns
[m n] = size(x);
for j = 1:m
xx = x;
xx(j) = x(j) + delx;
J(:,j) = (f(xx)-f(x))/delx;
end;
% end function
Notice that for each column (i.e., each value of j) we define a variable xx which is first
made equal to x, and then the j-th element is incremented by delx, before calculating the
j-th column of the Jacobian, namely, J(:,j). This is the MATLAB implementation of the
finite difference approximation for the Jacobian elements Jij = ∂fi/∂xj as defined earlier.
15
Illustrating the “secant” algorithm for a system of two non-linear equations
To illustrate the application of the “secant” algorithm we use again the system of two
non-linear equations defined earlier through the function f2.
We choose an initial guess for the solution as x0 = [2;3], and an increment in the
independent variables of ∆x = 0.1:
x0 = [2;3]
x0 =
2
3
EDU» dx = 0.1
dx = 0.1000
Variable J0 will store the Jacobian corresponding to x0 calculated through finite
differences with the value of ∆x defined above:
» J0 = jacobFD('f2',x0,dx)
J0 =
4.1000 6.1000
3.0000 2.0000
A new estimate for the solution, namely, x1, is calculated using the Newton-Raphson
algorithm:
» x1 = x0 - inv(J0)*f2(x0)
x1 =
6.1485
6.2772
The finite-difference Jacobian corresponding to x1 gets stored in J1:
» J1 = jacobFD('f2',x1,dx)
J1 =
12.3970 12.6545
6.2772 6.1485
And a new approximation for the solution (x2) is calculated as:
» x2 = x1 - inv(J1)*f2(x1)
x2 =
4.6671
5.5784
16
The next two approximations to the solution (x3 and x4) are calculated without first
storing the corresponding finite-difference Jacobians:
» x3 = x2 - inv(jacobFD('f2',x2,dx))*f2(x2)
x3 =
4.7676
5.2365
EDU» x4 = x3 - inv(jacobFD('f2',x3,dx))*f2(x3)
x4 =
4.8826
5.1175
To check the value of the functions at x = x4 we use:
» f2(x4)
ans =
0.0278
-0.0137
The functions are close to zero, but not yet at an acceptable error (i.e., something in the
order of 10-6
). Therefore, we try one more approximation to the solution, i.e., x5:
» x5 = x4 - inv(jacobFD('f2',x4,dx))*f2(x4)
x5 =
4.9413
5.0587
The functions are even closer to zero than before, suggesting a convergence to a solution.
» f2(x5)
ans =
0.0069
-0.0034
MMAATTLLAABB ffuunnccttiioonn ffoorr ““sseeccaanntt”” mmeetthhoodd ttoo ssoollvvee ssyysstteemmss ooff nnoonn--lliinneeaarr eeqquuaattiioonnss
To make the process of achieving a solution automatic, we propose the following
MATLAB user -defined function, secantm:
function [x,iter] = secantm(x0,dx,f)
% Secant-type method applied to a
% system of linear equations f(x) = 0,
17
% given the jacobian function J, with
% The Jacobian built by columns.
% x = [x1;x2;...;xn], f = [f1;f2;...;fn]
% x0 is the initial guess of the solution
% dx is an increment in x1,x2,... variables
N = 100; % define max. number of iterations
epsilon = 1.0e-10; % define tolerance
maxval = 10000.0; % define value for divergence
if abs(dx)<epsilon
error('dx = 0, use different values');
break;
end;
xn = x0; % load initial guess
[n m] = size(x0);
while (N>0)
JJ = [1,2;2,3]; xx = zeros(n,1);
for j = 1:n % Estimating
xx = xn; % Jacobian by
xx(j) = xn(j) + dx; % finite
fxx = feval(f,xx);
fxn = feval(f,xn);
JJ(:,j) = (fxx-fxn)/dx; % differences
end; % by columns
if abs(det(JJ))<epsilon
error('newtonm - Jacobian is singular - try new x0,dx');
break;
end;
xnp1 = xn - inv(JJ)*fxn;
fnp1 = feval(f,xnp1);
if abs(fnp1)<epsilon
x=xnp1;
disp(['iterations: ', num2str(100-N)]);
return;
end;
if abs(fnp1)>maxval
disp(['iterations: ', num2str(100-N)]);
error('Solution diverges');
break;
end;
N = N - 1;
xn = xnp1;
end;
error('No convergence');
break;
% end function
18
SSoolluuttiioonn uussiinngg ffuunnccttiioonn sseeccaannttmm
To solve the system represented by function f2, we now use function secantm. The
following call to function secantm produces a solution after 18 iterations:
» [x,iter] = secantm(x0,dx,'f2')
iterations: 18
x =
5.0000
5.0000
iter =
18
Solving equations with Matlab function fzero
Matlab provides function fzero for the solution of single non-linear equations. Use
» help fzero
to obtain additional information on function fzero. Also, read Chapter 7 (Function
Functions) in the Using Matlab guide.
For the solution of systems of non-linear equations Matlab provides function fsolve as
part of the Optimization package. Since this is an add-on package, function fsolve is not
available in the student version of Matlab. If using the full version of Matlab, check the
help facility for function fsolve by using:
» help fsolve
If function fsolve is not available in the Matlab installation you are using, you can always
use function secantm (or newtonm) to solve systems of non-linear equations.

Contenu connexe

Tendances

Newton raphson method
Newton raphson methodNewton raphson method
Newton raphson methodBijay Mishra
 
Euler and improved euler method
Euler and improved euler methodEuler and improved euler method
Euler and improved euler methodSohaib Butt
 
NUMERICAL METHODS ppt new (1).pptx
NUMERICAL METHODS  ppt new (1).pptxNUMERICAL METHODS  ppt new (1).pptx
NUMERICAL METHODS ppt new (1).pptxbaljitkaur96270
 
Numerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsNumerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsMeenakshisundaram N
 
Lecture 04 newton-raphson, secant method etc
Lecture 04 newton-raphson, secant method etcLecture 04 newton-raphson, secant method etc
Lecture 04 newton-raphson, secant method etcRiyandika Jastin
 
Numerical differentiation integration
Numerical differentiation integrationNumerical differentiation integration
Numerical differentiation integrationTarun Gehlot
 
Linear Systems Gauss Seidel
Linear Systems   Gauss SeidelLinear Systems   Gauss Seidel
Linear Systems Gauss SeidelEric Davishahl
 
Numerical Analysis and Its application to Boundary Value Problems
Numerical Analysis and Its application to Boundary Value ProblemsNumerical Analysis and Its application to Boundary Value Problems
Numerical Analysis and Its application to Boundary Value ProblemsGobinda Debnath
 
Newton's Forward/Backward Difference Interpolation
Newton's Forward/Backward  Difference InterpolationNewton's Forward/Backward  Difference Interpolation
Newton's Forward/Backward Difference InterpolationVARUN KUMAR
 
Presentation on Solution to non linear equations
Presentation on Solution to non linear equationsPresentation on Solution to non linear equations
Presentation on Solution to non linear equationsRifat Rahamatullah
 
Bisection & Regual falsi methods
Bisection & Regual falsi methodsBisection & Regual falsi methods
Bisection & Regual falsi methodsDivya Bhatia
 

Tendances (20)

Euler and runge kutta method
Euler and runge kutta methodEuler and runge kutta method
Euler and runge kutta method
 
Numerical method
Numerical methodNumerical method
Numerical method
 
Newton raphson method
Newton raphson methodNewton raphson method
Newton raphson method
 
Numerical analysis ppt
Numerical analysis pptNumerical analysis ppt
Numerical analysis ppt
 
Runge Kutta Method
Runge Kutta MethodRunge Kutta Method
Runge Kutta Method
 
Euler and improved euler method
Euler and improved euler methodEuler and improved euler method
Euler and improved euler method
 
The newton raphson method
The newton raphson methodThe newton raphson method
The newton raphson method
 
NUMERICAL METHODS ppt new (1).pptx
NUMERICAL METHODS  ppt new (1).pptxNUMERICAL METHODS  ppt new (1).pptx
NUMERICAL METHODS ppt new (1).pptx
 
numerical methods
numerical methodsnumerical methods
numerical methods
 
Secant Method
Secant MethodSecant Method
Secant Method
 
Numerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsNumerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential Equations
 
Lecture 04 newton-raphson, secant method etc
Lecture 04 newton-raphson, secant method etcLecture 04 newton-raphson, secant method etc
Lecture 04 newton-raphson, secant method etc
 
Numerical differentiation integration
Numerical differentiation integrationNumerical differentiation integration
Numerical differentiation integration
 
Linear Systems Gauss Seidel
Linear Systems   Gauss SeidelLinear Systems   Gauss Seidel
Linear Systems Gauss Seidel
 
Numerical Analysis and Its application to Boundary Value Problems
Numerical Analysis and Its application to Boundary Value ProblemsNumerical Analysis and Its application to Boundary Value Problems
Numerical Analysis and Its application to Boundary Value Problems
 
Newton's Forward/Backward Difference Interpolation
Newton's Forward/Backward  Difference InterpolationNewton's Forward/Backward  Difference Interpolation
Newton's Forward/Backward Difference Interpolation
 
Presentation on Solution to non linear equations
Presentation on Solution to non linear equationsPresentation on Solution to non linear equations
Presentation on Solution to non linear equations
 
Interpolation
InterpolationInterpolation
Interpolation
 
Fourier series 1
Fourier series 1Fourier series 1
Fourier series 1
 
Bisection & Regual falsi methods
Bisection & Regual falsi methodsBisection & Regual falsi methods
Bisection & Regual falsi methods
 

En vedette

ROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSfenil patel
 
Numerical Analysis (Solution of Non-Linear Equations)
Numerical Analysis (Solution of Non-Linear Equations)Numerical Analysis (Solution of Non-Linear Equations)
Numerical Analysis (Solution of Non-Linear Equations)Asad Ali
 
Roots of Nonlinear Equations - Open Methods
Roots of Nonlinear Equations - Open MethodsRoots of Nonlinear Equations - Open Methods
Roots of Nonlinear Equations - Open MethodsMohammad Tawfik
 
University of duhok
University of duhokUniversity of duhok
University of duhokRwan Kamal
 
system of non-linear equation (linear algebra & vector calculus)
system of non-linear equation (linear algebra & vector calculus)system of non-linear equation (linear algebra & vector calculus)
system of non-linear equation (linear algebra & vector calculus)Rohan Lakhani
 
Dennis j e, schnabel b numerical methods for unconstrained optimization and n...
Dennis j e, schnabel b numerical methods for unconstrained optimization and n...Dennis j e, schnabel b numerical methods for unconstrained optimization and n...
Dennis j e, schnabel b numerical methods for unconstrained optimization and n...Bruno Rush
 
Roots of equations
Roots of equationsRoots of equations
Roots of equationsRobinson
 
World+water+day PPT
World+water+day PPTWorld+water+day PPT
World+water+day PPTAhmed Ayaz
 

En vedette (20)

ROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONS
 
bisection method
bisection methodbisection method
bisection method
 
Numerical Analysis (Solution of Non-Linear Equations)
Numerical Analysis (Solution of Non-Linear Equations)Numerical Analysis (Solution of Non-Linear Equations)
Numerical Analysis (Solution of Non-Linear Equations)
 
Roots of Nonlinear Equations - Open Methods
Roots of Nonlinear Equations - Open MethodsRoots of Nonlinear Equations - Open Methods
Roots of Nonlinear Equations - Open Methods
 
Systems of equations
Systems of equationsSystems of equations
Systems of equations
 
Linear and non linear equation
Linear and non linear equationLinear and non linear equation
Linear and non linear equation
 
Graph theory
Graph theoryGraph theory
Graph theory
 
University of duhok
University of duhokUniversity of duhok
University of duhok
 
system of non-linear equation (linear algebra & vector calculus)
system of non-linear equation (linear algebra & vector calculus)system of non-linear equation (linear algebra & vector calculus)
system of non-linear equation (linear algebra & vector calculus)
 
Dennis j e, schnabel b numerical methods for unconstrained optimization and n...
Dennis j e, schnabel b numerical methods for unconstrained optimization and n...Dennis j e, schnabel b numerical methods for unconstrained optimization and n...
Dennis j e, schnabel b numerical methods for unconstrained optimization and n...
 
Notes 6-1
Notes 6-1Notes 6-1
Notes 6-1
 
Chapter 3 roots of equations
Chapter 3 roots of equationsChapter 3 roots of equations
Chapter 3 roots of equations
 
metode iterasi Gauss seidel
metode iterasi Gauss seidelmetode iterasi Gauss seidel
metode iterasi Gauss seidel
 
Roots of equations
Roots of equationsRoots of equations
Roots of equations
 
NUMERICAL METHODS
NUMERICAL METHODSNUMERICAL METHODS
NUMERICAL METHODS
 
World+water+day PPT
World+water+day PPTWorld+water+day PPT
World+water+day PPT
 
World water day
World water dayWorld water day
World water day
 
Gauss sediel
Gauss sedielGauss sediel
Gauss sediel
 
BCD ADDER
BCD ADDER BCD ADDER
BCD ADDER
 
System call
System callSystem call
System call
 

Similaire à Solution of non-linear equations

Numarical values
Numarical valuesNumarical values
Numarical valuesAmanSaeed11
 
Numarical values highlighted
Numarical values highlightedNumarical values highlighted
Numarical values highlightedAmanSaeed11
 
Roots of equations
Roots of equationsRoots of equations
Roots of equationsMileacre
 
Equations root
Equations rootEquations root
Equations rootMileacre
 
Mit18 330 s12_chapter4
Mit18 330 s12_chapter4Mit18 330 s12_chapter4
Mit18 330 s12_chapter4CAALAAA
 
Newton raphsonmethod presentation
Newton raphsonmethod presentationNewton raphsonmethod presentation
Newton raphsonmethod presentationAbdullah Moin
 
Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...
Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...
Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...mathsjournal
 
Newton-Raphson Iteration marths 4 ntsm
Newton-Raphson Iteration marths 4 ntsmNewton-Raphson Iteration marths 4 ntsm
Newton-Raphson Iteration marths 4 ntsmNemish Bhojani
 
Numerical differentation with c
Numerical differentation with cNumerical differentation with c
Numerical differentation with cYagya Dev Bhardwaj
 
Newton raphson halley_householder_simpleexplanation
Newton raphson halley_householder_simpleexplanationNewton raphson halley_householder_simpleexplanation
Newton raphson halley_householder_simpleexplanationmuyuubyou
 
B02110105012
B02110105012B02110105012
B02110105012theijes
 
The International Journal of Engineering and Science (The IJES)
 The International Journal of Engineering and Science (The IJES) The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)theijes
 

Similaire à Solution of non-linear equations (20)

Numarical values
Numarical valuesNumarical values
Numarical values
 
Numarical values highlighted
Numarical values highlightedNumarical values highlighted
Numarical values highlighted
 
Roots of equations
Roots of equationsRoots of equations
Roots of equations
 
Equations root
Equations rootEquations root
Equations root
 
Mit18 330 s12_chapter4
Mit18 330 s12_chapter4Mit18 330 s12_chapter4
Mit18 330 s12_chapter4
 
Newton raphsonmethod presentation
Newton raphsonmethod presentationNewton raphsonmethod presentation
Newton raphsonmethod presentation
 
Fourier series
Fourier seriesFourier series
Fourier series
 
S3-3.pdf
S3-3.pdfS3-3.pdf
S3-3.pdf
 
Lecture6
Lecture6Lecture6
Lecture6
 
Newton
NewtonNewton
Newton
 
OPERATIONS RESEARCH
OPERATIONS RESEARCHOPERATIONS RESEARCH
OPERATIONS RESEARCH
 
Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...
Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...
Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...
 
CALCULUS 2.pptx
CALCULUS 2.pptxCALCULUS 2.pptx
CALCULUS 2.pptx
 
Newton-Raphson Iteration marths 4 ntsm
Newton-Raphson Iteration marths 4 ntsmNewton-Raphson Iteration marths 4 ntsm
Newton-Raphson Iteration marths 4 ntsm
 
false-point.pdf
false-point.pdffalse-point.pdf
false-point.pdf
 
Numerical differentation with c
Numerical differentation with cNumerical differentation with c
Numerical differentation with c
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Newton raphson halley_householder_simpleexplanation
Newton raphson halley_householder_simpleexplanationNewton raphson halley_householder_simpleexplanation
Newton raphson halley_householder_simpleexplanation
 
B02110105012
B02110105012B02110105012
B02110105012
 
The International Journal of Engineering and Science (The IJES)
 The International Journal of Engineering and Science (The IJES) The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)
 

Plus de ZunAib Ali

Lcl filter design
Lcl filter designLcl filter design
Lcl filter designZunAib Ali
 
Power converter report
Power converter reportPower converter report
Power converter reportZunAib Ali
 
Performance of Six-Pulse Line-Commutated Converter in DC Motor Drive Application
Performance of Six-Pulse Line-Commutated Converter in DC Motor Drive ApplicationPerformance of Six-Pulse Line-Commutated Converter in DC Motor Drive Application
Performance of Six-Pulse Line-Commutated Converter in DC Motor Drive ApplicationZunAib Ali
 
SVM Simulation for three level inverter
SVM Simulation for three level inverterSVM Simulation for three level inverter
SVM Simulation for three level inverterZunAib Ali
 
Multi phase Star Rectifier
Multi phase Star Rectifier Multi phase Star Rectifier
Multi phase Star Rectifier ZunAib Ali
 
Space vector pwm_inverter
Space vector pwm_inverterSpace vector pwm_inverter
Space vector pwm_inverterZunAib Ali
 
Power transformer
Power transformerPower transformer
Power transformerZunAib Ali
 
Neutral point clamped inverter
Neutral point clamped inverterNeutral point clamped inverter
Neutral point clamped inverterZunAib Ali
 
7 channel Interleaved Boost Converter
7 channel Interleaved Boost Converter7 channel Interleaved Boost Converter
7 channel Interleaved Boost ConverterZunAib Ali
 
Sinusoidal PWM and Space Vector Modulation For Two Level Voltage Source Conve...
Sinusoidal PWM and Space Vector Modulation For Two Level Voltage Source Conve...Sinusoidal PWM and Space Vector Modulation For Two Level Voltage Source Conve...
Sinusoidal PWM and Space Vector Modulation For Two Level Voltage Source Conve...ZunAib Ali
 
Rectifiers Simulation
Rectifiers SimulationRectifiers Simulation
Rectifiers SimulationZunAib Ali
 
Instrumentational Amplifier
Instrumentational Amplifier Instrumentational Amplifier
Instrumentational Amplifier ZunAib Ali
 
Electronic Device pakages
Electronic Device pakagesElectronic Device pakages
Electronic Device pakagesZunAib Ali
 
Concept of energy transmission & distribution
Concept of energy transmission & distribution Concept of energy transmission & distribution
Concept of energy transmission & distribution ZunAib Ali
 
DC Motor Model
DC Motor Model DC Motor Model
DC Motor Model ZunAib Ali
 
High Voltage Dc (HVDC) transmission
High Voltage Dc (HVDC) transmissionHigh Voltage Dc (HVDC) transmission
High Voltage Dc (HVDC) transmissionZunAib Ali
 
Cambridge ielts 9 full
Cambridge ielts 9 fullCambridge ielts 9 full
Cambridge ielts 9 fullZunAib Ali
 
Water level buzzer
Water level buzzerWater level buzzer
Water level buzzerZunAib Ali
 
Fourier Specturm via MATLAB
Fourier Specturm via MATLABFourier Specturm via MATLAB
Fourier Specturm via MATLABZunAib Ali
 

Plus de ZunAib Ali (20)

Lcl filter design
Lcl filter designLcl filter design
Lcl filter design
 
Power converter report
Power converter reportPower converter report
Power converter report
 
Performance of Six-Pulse Line-Commutated Converter in DC Motor Drive Application
Performance of Six-Pulse Line-Commutated Converter in DC Motor Drive ApplicationPerformance of Six-Pulse Line-Commutated Converter in DC Motor Drive Application
Performance of Six-Pulse Line-Commutated Converter in DC Motor Drive Application
 
SVM Simulation for three level inverter
SVM Simulation for three level inverterSVM Simulation for three level inverter
SVM Simulation for three level inverter
 
Multi phase Star Rectifier
Multi phase Star Rectifier Multi phase Star Rectifier
Multi phase Star Rectifier
 
Space vector pwm_inverter
Space vector pwm_inverterSpace vector pwm_inverter
Space vector pwm_inverter
 
Power transformer
Power transformerPower transformer
Power transformer
 
Neutral point clamped inverter
Neutral point clamped inverterNeutral point clamped inverter
Neutral point clamped inverter
 
7 channel Interleaved Boost Converter
7 channel Interleaved Boost Converter7 channel Interleaved Boost Converter
7 channel Interleaved Boost Converter
 
Sinusoidal PWM and Space Vector Modulation For Two Level Voltage Source Conve...
Sinusoidal PWM and Space Vector Modulation For Two Level Voltage Source Conve...Sinusoidal PWM and Space Vector Modulation For Two Level Voltage Source Conve...
Sinusoidal PWM and Space Vector Modulation For Two Level Voltage Source Conve...
 
Rectifiers Simulation
Rectifiers SimulationRectifiers Simulation
Rectifiers Simulation
 
Instrumentational Amplifier
Instrumentational Amplifier Instrumentational Amplifier
Instrumentational Amplifier
 
Electronic Device pakages
Electronic Device pakagesElectronic Device pakages
Electronic Device pakages
 
Inverter
InverterInverter
Inverter
 
Concept of energy transmission & distribution
Concept of energy transmission & distribution Concept of energy transmission & distribution
Concept of energy transmission & distribution
 
DC Motor Model
DC Motor Model DC Motor Model
DC Motor Model
 
High Voltage Dc (HVDC) transmission
High Voltage Dc (HVDC) transmissionHigh Voltage Dc (HVDC) transmission
High Voltage Dc (HVDC) transmission
 
Cambridge ielts 9 full
Cambridge ielts 9 fullCambridge ielts 9 full
Cambridge ielts 9 full
 
Water level buzzer
Water level buzzerWater level buzzer
Water level buzzer
 
Fourier Specturm via MATLAB
Fourier Specturm via MATLABFourier Specturm via MATLAB
Fourier Specturm via MATLAB
 

Dernier

social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Dernier (20)

social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 

Solution of non-linear equations

  • 1. 1 SSoolluuttiioonn ooff nnoonn--lliinneeaarr eeqquuaattiioonnss By Gilberto E. Urroz, September 2004 In this document I present methods for the solution of single non-linear equations as well as for systems of such equations. SSoolluuttiioonn ooff aa ssiinnggllee nnoonn--lliinneeaarr eeqquuaattiioonn Equations that can be cast in the form of a polynomial are referred to as algebraic equations. Equations involving more complicated terms, such as trigonometric, hyperbolic, exponential, or logarithmic functions are referred to as transcendental equations. The methods presented in this section are numerical methods that can be applied to the solution of such equations, to which we will refer, in general, as non-linear equations. In general, we will we searching for one, or more, solutions to the equation, f(x) = 0. We will present the Newton-Raphson algorithm, and the secant method. In the secant method we need to provide two initial values of x to get the algorithm started. In the Newton-Raphson methods only one initial value is required. Because the solution is not exact, the algorithms for any of the methods presented herein will not provide the exact solution to the equation f(x) = 0, instead, we will stop the algorithm when the equation is satisfied within an allowed tolerance or error, ε. In mathematical terms this is expressed as |f(xR)| < ε. The value of x for which the non-linear equation f(x)=0 is satisfied, i.e., x = xR, will be the solution, or root, to the equation within an error of ε units. The Newton-Raphson method Consider the Taylor-series expansion of the function f(x) about a value x = xo: f(x)= f(xo)+f'(xo)(x-xo)+(f"(xo)/2!)(x-xo)2+…. Using only the first two terms of the expansion, a first approximation to the root of the equation f(x) = 0 can be obtained from f(x) = 0 ≈ f(xo)+f'(xo)(x1 -xo)
  • 2. 2 Such approximation is given by, x1 = xo - f(xo)/f'(xo). The Newton-Raphson method consists in obtaining improved values of the approximate root through the recurrent application of equation above. For example, the second and third approximations to that root will be given by x2 = x1 - f(x1)/f'(x1), and x3= x2 - f(x2)/f'(x2), respectively. This iterative procedure can be generalized by writing the following equation, where i represents the iteration number: xi+1 = xi - f(xi)/f'(xi). After each iteration the program should check to see if the convergence condition, namely, |f(x i+1)|<ε, is satisfied. The figure below illustrates the way in which the solution is found by using the Newton- Raphson method. Notice that the equation f(x) = 0 ≈ f(xo)+f'(xo)(x1 -xo) represents a straight line tangent to the curve y = f(x) at x = xo. This line intersects the x-axis (i.e., y = f(x) = 0) at the point x1 as given by x1 = xo - f(xo)/f'(xo). At that point we can construct another straight line tangent to y = f(x) whose intersection with the x-axis is the new approximation to the root of f(x) = 0, namely, x = x2. Proceeding with the iteration we can see that the intersection of consecutive tangent lines with the x-axis approaches the actual root relatively fast.
  • 3. 3 The Newton-Raphson method converges relatively fast for most functions regardless of the initial value chosen. The main disadvantage is that you need to know not only the function f(x), but also its derivative, f'(x), in order to achieve a solution. The secant method, discussed in the following section, utilizes an approximation to the derivative, thus obviating such requirement. The programming algorithm of any of these methods must include the option of stopping the program if the number of iterations grows too large. How large is large? That will depend of the particular problem solved. However, any Newton-Raphson, or secant method solution that takes more than 1000 iterations to converge is either ill-posed or contains a logical error. Debugging of the program will be called for at this point by changing the initial values provided to the program, or by checking the program's logic. AA MMAATTLLAABB ffuunnccttiioonn ffoorr tthhee NNeewwttoonn--RRaapphhssoonn mmeetthhoodd The function newton, listed below, implements the Newton-Raphson algorithm. It uses as arguments an initial value and expressions for f(x) and f'(x). function [x,iter]=newton(x0,f,fp) % newton-raphson algorithm N = 100; eps = 1.e-5; % define max. no. iterations and error maxval = 10000.0; % define value for divergence xx = x0; while (N>0) xn = xx-f(xx)/fp(xx); if abs(f(xn))<eps x=xn;iter=100-N; return; end; if abs(f(xx))>maxval disp(['iterations = ',num2str(iter)]); error('Solution diverges'); break; end; N = N - 1; xx = xn; end; error('No convergence'); break; % end function We will use the Newton-Raphson method to solve for the equation, f(x) = x3 -2x2 +1 = 0. The following MATLAB commands define the function f001(x) and its derivative, f01p(x): »f001 = inline('x.^3-2*x.^2+1','x') f001 = Inline function: f001(x) = x.^3-2*x.^2+1
  • 4. 4 » f01p = inline('3*x.^2-2','x') f01p = Inline function: f01p(x) = 3*x.^2-2 To have an idea of the location of the roots of this polynomial we'll plot the function using the following MATLAB commands: » x = [-0.8:0.01:2.0]';y=f001(x); » plot(x,y);xlabel('x');ylabel('f001(x)'); » grid on -1 -0.5 0 0.5 1 1.5 2 -1 -0.5 0 0.5 1 x f001(x) We see that the function graph crosses the x-axis somewhere between –1.0 and –0.5, close to 1.0, and between 1.5 and 2.0. To activate the function we could use, for example, an initial value x0 = 2: » [x,iterations] = newton(2,f001,f01p) x = 1.6180 iterations = 39 The following command are aimed at obtaining vectors of the solutions provided by function newton.m for f001(x)=0 for initial values in the vector x0 such that –20 < x0 < 20. The solutions found are stored in variable xs while the required number of iterations is stored in variable is. » x0 = [-20:0.5:20]; xs = []; is = []; EDU» for i = 1:length(x0) [xx,ii] = newton(x0(i),f001,f01p); xs = [xs,xx]; is = [is,ii]; end Plot of xs vs. x0, and of is vs. x0 are shown next:
  • 5. 5 » figure(1);plot(x0,xs,'o');hold;plot(x0,xs,'-');hold; » title('Newton-Raphson solution'); » xlabel('initial guess, x0');ylabel('solution, xs'); -20 -15 -10 -5 0 5 10 15 20 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 Newton-Raphson solution initial guess, x0 solution,xs This figure shows that for initial guesses in the range –20 < xo<20, function newton.m converges mainly to the solution x = 1.6180, with few instances converting to the solutions x = -1 and x = 1. » figure(2);plot(x0,is,'+'); hold;plot(x0,is,'-');hold; » title('Newton-Raphson solution'); » xlabel('initial guess, x0');ylabel('iterations, is'); -20 -15 -10 -5 0 5 10 15 20 0 10 20 30 40 50 60 70 Newton-Raphson solution initial guess, x0 iterations,is This figure shows that the number of iterations required to achieve a solution ranges from 0 to about 65. Most of the time, about 50 iterations are required. The following example shows a case in which the solution actually diverges:
  • 6. 6 » [x,iter] = newton(-20.75,f001,f01p) iterations = 6 ??? Error using ==> newton Solution diverges NOTE: If the function of interest is defined by an m-file, the reference to the function name in the call to newton.m should be placed between quotes. The Secant Method In the secant method, we replace the derivative f'(xi) in the Newton-Raphson method with f'(xi) ≈ (f(xi) - f(xi-1))/(xi - xi-1). With this replacement, the Newton-Raphson algorithm becomes To get the method started we need two values of x, say xo and x1, to get the first approximation to the solution, namely, As with the Newton-Raphson method, the iteration is stopped when |f(x i+1)|<ε. Figure 4, below, illustrates the way that the secant method approximates the solution of the equation f(x) = 0. ).( )()( )( 1 1 1 − − + −⋅ − −= ii ii i ii xx xfxf xf xx ).( )()( )( 01 1 1 12 xx xfxf xf xx o −⋅ − −=
  • 7. 7 AA MMAATTLLAABB ffuunnccttiioonn ffoorr tthhee sseeccaanntt mmeetthhoodd The function secant, listed below, uses the secant method to solve for non-linear equations. It requires two initial values and an expression for the function, f(x). function [x,iter]=secant(x0,x00,f) % newton-raphson algorithm N = 100; eps = 1.e-5; % define max. no. iterations and error maxval = 10000.0; % define value for divergence xx1 = x0; xx2 = x00; while N>0 gp = (f(xx2)-f(xx1))/(xx2-xx1); xn = xx1-f(xx1)/gp; if abs(f(xn))<eps x=xn; iter = 100-N; return; end; if abs(f(xn))>maxval iter=100-N; disp(['iterations = ',num2str(iter)]); error('Solution diverges'); abort; end; N = N - 1; xx1 = xx2; xx2 = xn; end; iter=100-N; disp(['iterations = ',iter]); error('No convergence'); abort; % end function AApppplliiccaattiioonn ooff sseeccaanntt mmeetthhoodd We use the same function f001(x) = 0 presented earlier. The following commands call the function secant.txt to obtain a solution to the equation: » [x,iter] = secant(-10.0,-9.8,f001) x = -0.6180 iter = 11 The following command are aimed at obtaining vectors of the solutions provided by function Newton.m for f001(x)=0 for initial values in the vector x0 such that –20 < x0 < 20. The solutions found are stored in variable xs while the required number of iterations is stored in variable is.
  • 8. 8 » x0 = [-20:0.5:20]; x00 = x0 + 0.5; xs = []; is = []; » for i = 1:length(x0) [xx,ii] = secant(x0(i),x00(i),f001); xs = [xs, xx]; is = [is, ii]; end Plot of xs vs. x0, and of is vs. x0 are shown next: » figure(1);plot(x0,xs,'o');hold;plot(x0,xs,'-');hold; » title('Secant method solution'); » xlabel('first initial guess, x0');ylabel('solution, xs'); -20 -15 -10 -5 0 5 10 15 20 -1 -0.5 0 0.5 1 1.5 2 Secant method solution first initial guess, x0 solution,xs This figure shows that for initial guesses in the range –20 < xo<20, function newton.m converges to the three solutions. Notice that initial guesses in the range –20 < x0 < -1, converge to x = - 0.6180; those in the range –1< x < 1, converge to x = 1; and, those in the range 1<x<20, converge to x =1.6180. » figure(2);plot(x0,is,'o');hold;plot(x0,is,'-');hold; » xlabel('first initial guess, x0');ylabel('iterations, is'); » title('Secant method solution'); -20 -15 -10 -5 0 5 10 15 20 0 5 10 15 first initial guess, x0 iterations,is Secant method solution
  • 9. 9 This figure shows that the number of iterations required to achieve a solution ranges from 0 to about 15. Notice also that, the closer the initial guess is to zero, the less number of iterations to convergence are required. NOTE: If the function of interest is defined by an m-file, the reference to the function name in the call to newton.m should be placed between quotes. SSoollvviinngg ssyysstteemmss ooff nnoonn--lliinneeaarr eeqquuaattiioonnss Consider the solution to a system of n non-linear equations in n unknowns given by f1(x1,x2,…,xn) = 0 f2(x1,x2,…,xn) = 0 . . . fn(x1,x2,…,xn) = 0 The system can be written in a single expression using vectors, i.e., f(x) = 0, where the vector x contains the independent variables, and the vector f contains the functions fi(x): . )( )( )( ),...,,( ),...,,( ),...,,( )(, 2 1 21 212 211 2 1             =             =             = x x x xfx nnn n n n f f f xxxf xxxf xxxf x x x MMM Newton-Raphson method to solve systems of non-linear equations A Newton-Raphson method for solving the system of linear equations requires the evaluation of a matrix, known as the Jacobian of the system, which is defined as: .][ /// /// /// ),...,,( ),...,,( 21 22212 12111 21 21 nn j i nnnn n n n n x f xfxfxf xfxfxf xfxfxf xxx fff × ∂ ∂ =             ∂∂∂∂∂∂ ∂∂∂∂∂∂ ∂∂∂∂∂∂ = ∂ ∂ = L MOMM L L J If x = x0 (a vector) represents the first guess for the solution, successive approximations to the solution are obtained from xn+1 = xn - J-1 ⋅f(xn) = xn - ∆xn, with ∆xn = xn+1 - xn.
  • 10. 10 A convergence criterion for the solution of a system of non-linear equation could be, for example, that the maximum of the absolute values of the functions fi(xn) is smaller than a certain tolerance ε, i.e., .|)(|max ε<ni i f x Another possibility for convergence is that the magnitude of the vector f(xn) be smaller than the tolerance, i.e., |f(xn)| < ε. We can also use as convergence criteria the difference between consecutive values of the solution, i.e., .,|)()(|max 1 ε<−+ nini i xx or, |∆xn | = |xn+1 - xn| < ε. The main complication with using Newton-Raphson to solve a system of non-linear equations is having to define all the functions ∂fi/∂xj, for i,j = 1,2, …, n, included in the Jacobian. As the number of equations and unknowns, n, increases, so does the number of elements in the Jacobian, n2 . MATLAB function for Newton-Raphson method for a system of non-linear equations The following MATLAB function, newtonm, calculates the solution to a system of n non- linear equations, f(x) = 0, given the vector of functions f and the Jacobian J, as well as an initial guess for the solution x0. function [x,iter] = newtonm(x0,f,J) % Newton-Raphson method applied to a % system of linear equations f(x) = 0, % given the jacobian function J, with % J = del(f1,f2,...,fn)/del(x1,x2,...,xn) % x = [x1;x2;...;xn], f = [f1;f2;...;fn] % x0 is an initial guess of the solution N = 100; % define max. number of iterations epsilon = 1e-10; % define tolerance maxval = 10000.0; % define value for divergence xx = x0; % load initial guess while (N>0) JJ = feval(J,xx); if abs(det(JJ))<epsilon error('newtonm - Jacobian is singular - try new x0'); abort; end; xn = xx - inv(JJ)*feval(f,xx);
  • 11. 11 if abs(feval(f,xn))<epsilon x=xn; iter = 100-N; return; end; if abs(feval(f,xx))>maxval iter = 100-N; disp(['iterations = ',num2str(iter)]); error('Solution diverges'); abort; end; N = N - 1; xx = xn; end; error('No convergence after 100 iterations.'); abort; % end function The functions f and the Jacobian J need to be defined as separate functions. To illustrate the definition of the functions consider the system of non-linear equations: f1(x1,x2) = x1 2 + x2 2 - 50 = 0, f2(x1,x2) = x1 ⋅ x2 - 25 = 0, whose Jacobian is . 22 12 21 2 2 1 2 2 1 1 1       =             ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ = xx xx x f x f x f x f J We can define the function f as the following user-defined MATLAB function f2: function [f] = f2(x) % f2(x) = 0, with x = [x(1);x(2)] % represents a system of 2 non-linear equations f1 = x(1)^2 + x(2)^2 - 50; f2 = x(1)*x(2) -25; f = [f1;f2]; % end function The corresponding Jacobian is calculated using the user-defined MATLAB function jacob2x2: function [J] = jacob2x2(x) % Evaluates the Jacobian of a 2x2 % system of non-linear equations J(1,1) = 2*x(1); J(1,2) = 2*x(2); J(2,1) = x(2); J(2,2) = x(1); % end function
  • 12. 12 Illustrating the Newton-Raphson algorithm for a system of two non-linear equations Before using function newtonm, we will perform some step-by-step calculations to illustrate the algorithm. We start by defining an initial guess for the solution as: » x0 = [2;1] x0 = 2 1 Let’s calculate the function f(x) at x = x0 to see how far we are from a solution: » f2(x0) ans = -45 -23 Obviously, the function f(x0) is far away from being zero. Thus, we proceed to calculate a better approximation by calculating the Jacobian J(x0): » J0 = jacob2x2(x0) J0 = 4 2 1 2 The new approximation to the solution, x1, is calculated as: » x1 = x0 - inv(J0)*f2(x0) x1 = 9.3333 8.8333 Evaluating the functions at x1 produces: f2(x1) ans = 115.1389 Still far away from convergence. Let’s calculate a new approximation, x2: » x2 = x1-inv(jacob2x2(x1))*f2(x1) x2 = 6.0428 5.7928
  • 13. 13 Evaluating the functions at x2 indicates that the values of the functions are decreasing: » f2(x2) ans = 20.0723 10.0049 A new approximation and the corresponding function evaluations are: » x3 = x2 - inv(jacob2x2(x2))*f2(x2) x3 = 5.1337 5.0087 E» f2(x3) ans = 1.4414 0.7129 The functions are getting even smaller suggesting convergence towards a solution. Solution using function newtonm Next, we use function newtonm to solve the problem postulated earlier. A call to the function using the values of x0, f2, and jacob2x2 is: » [x,iter] = newtonm(x0,'f2','jacob2x2') x = 5.0000 5.0000 iter = 16 The result shows the number of iterations required for convergence (16) and the solution found as x1 = 5.0000 and x2 = 5.000. Evaluating the functions for those solutions results in: » f2(x) ans = 1.0e-010 * 0.2910 -0.1455
  • 14. 14 The values of the functions are close enough to zero (error in the order of 10-11 ). “Secant” method to solve systems of non-linear equations In this section we present a method for solving systems of non-linear equations through the Newton-Raphson algorithm, namely, xn+1 = xn - J-1 ⋅f(xn), but approximating the Jacobian through finite differences. This approach is a generalization of the secant method for a single non-linear equation. For that reason, we refer to the method applied to a system of non-linear equations as a “secant” method, although the geometric origin of the term not longer applies. The “secant” method for a system of non-linear equations free us from having to define the n2 functions necessary to define the Jacobian for a system of n equations. Instead, we approximate the partial derivatives in the Jacobian with , ),,,,,(),,,,,( 2121 x xxxxfxxxxxf x f njinji j i ∆ −∆+ ≈ ∂ ∂ LLLL where ∆x is a small increment in the independent variables. Notice that ∂fi/∂xj represents element Jij in the jacobian J = ∂(f1,f2,…,fn)/∂(x1,x2,…,xn). To calculate the Jacobian we proceed by columns, i.e., column j of the Jacobian will be calculated as shown in the function jacobFD (jacobian calculated through Finite Differences) listed below: function [J] = jacobFD(f,x,delx) % Calculates the Jacobian of the % system of non-linear equations: % f(x) = 0, through finite differences. % The Jacobian is built by columns [m n] = size(x); for j = 1:m xx = x; xx(j) = x(j) + delx; J(:,j) = (f(xx)-f(x))/delx; end; % end function Notice that for each column (i.e., each value of j) we define a variable xx which is first made equal to x, and then the j-th element is incremented by delx, before calculating the j-th column of the Jacobian, namely, J(:,j). This is the MATLAB implementation of the finite difference approximation for the Jacobian elements Jij = ∂fi/∂xj as defined earlier.
  • 15. 15 Illustrating the “secant” algorithm for a system of two non-linear equations To illustrate the application of the “secant” algorithm we use again the system of two non-linear equations defined earlier through the function f2. We choose an initial guess for the solution as x0 = [2;3], and an increment in the independent variables of ∆x = 0.1: x0 = [2;3] x0 = 2 3 EDU» dx = 0.1 dx = 0.1000 Variable J0 will store the Jacobian corresponding to x0 calculated through finite differences with the value of ∆x defined above: » J0 = jacobFD('f2',x0,dx) J0 = 4.1000 6.1000 3.0000 2.0000 A new estimate for the solution, namely, x1, is calculated using the Newton-Raphson algorithm: » x1 = x0 - inv(J0)*f2(x0) x1 = 6.1485 6.2772 The finite-difference Jacobian corresponding to x1 gets stored in J1: » J1 = jacobFD('f2',x1,dx) J1 = 12.3970 12.6545 6.2772 6.1485 And a new approximation for the solution (x2) is calculated as: » x2 = x1 - inv(J1)*f2(x1) x2 = 4.6671 5.5784
  • 16. 16 The next two approximations to the solution (x3 and x4) are calculated without first storing the corresponding finite-difference Jacobians: » x3 = x2 - inv(jacobFD('f2',x2,dx))*f2(x2) x3 = 4.7676 5.2365 EDU» x4 = x3 - inv(jacobFD('f2',x3,dx))*f2(x3) x4 = 4.8826 5.1175 To check the value of the functions at x = x4 we use: » f2(x4) ans = 0.0278 -0.0137 The functions are close to zero, but not yet at an acceptable error (i.e., something in the order of 10-6 ). Therefore, we try one more approximation to the solution, i.e., x5: » x5 = x4 - inv(jacobFD('f2',x4,dx))*f2(x4) x5 = 4.9413 5.0587 The functions are even closer to zero than before, suggesting a convergence to a solution. » f2(x5) ans = 0.0069 -0.0034 MMAATTLLAABB ffuunnccttiioonn ffoorr ““sseeccaanntt”” mmeetthhoodd ttoo ssoollvvee ssyysstteemmss ooff nnoonn--lliinneeaarr eeqquuaattiioonnss To make the process of achieving a solution automatic, we propose the following MATLAB user -defined function, secantm: function [x,iter] = secantm(x0,dx,f) % Secant-type method applied to a % system of linear equations f(x) = 0,
  • 17. 17 % given the jacobian function J, with % The Jacobian built by columns. % x = [x1;x2;...;xn], f = [f1;f2;...;fn] % x0 is the initial guess of the solution % dx is an increment in x1,x2,... variables N = 100; % define max. number of iterations epsilon = 1.0e-10; % define tolerance maxval = 10000.0; % define value for divergence if abs(dx)<epsilon error('dx = 0, use different values'); break; end; xn = x0; % load initial guess [n m] = size(x0); while (N>0) JJ = [1,2;2,3]; xx = zeros(n,1); for j = 1:n % Estimating xx = xn; % Jacobian by xx(j) = xn(j) + dx; % finite fxx = feval(f,xx); fxn = feval(f,xn); JJ(:,j) = (fxx-fxn)/dx; % differences end; % by columns if abs(det(JJ))<epsilon error('newtonm - Jacobian is singular - try new x0,dx'); break; end; xnp1 = xn - inv(JJ)*fxn; fnp1 = feval(f,xnp1); if abs(fnp1)<epsilon x=xnp1; disp(['iterations: ', num2str(100-N)]); return; end; if abs(fnp1)>maxval disp(['iterations: ', num2str(100-N)]); error('Solution diverges'); break; end; N = N - 1; xn = xnp1; end; error('No convergence'); break; % end function
  • 18. 18 SSoolluuttiioonn uussiinngg ffuunnccttiioonn sseeccaannttmm To solve the system represented by function f2, we now use function secantm. The following call to function secantm produces a solution after 18 iterations: » [x,iter] = secantm(x0,dx,'f2') iterations: 18 x = 5.0000 5.0000 iter = 18 Solving equations with Matlab function fzero Matlab provides function fzero for the solution of single non-linear equations. Use » help fzero to obtain additional information on function fzero. Also, read Chapter 7 (Function Functions) in the Using Matlab guide. For the solution of systems of non-linear equations Matlab provides function fsolve as part of the Optimization package. Since this is an add-on package, function fsolve is not available in the student version of Matlab. If using the full version of Matlab, check the help facility for function fsolve by using: » help fsolve If function fsolve is not available in the Matlab installation you are using, you can always use function secantm (or newtonm) to solve systems of non-linear equations.