0% found this document useful (0 votes)
50 views7 pages

Root Finding by Newton's Method For A Single Equation

The document discusses using Newton's method to find the roots of single variable and multi-variable equations. For a single variable equation f(x)=0, Newton's method approximates the function as a tangent line at an initial guess x0, finds where the line crosses the x-axis to get an updated guess. For two equations f(x,y)=0 and g(x,y)=0, it extends the method by taking partial derivatives of f and g with respect to x and y, setting the equations equal to 0, and solving the equations to update the guesses for x and y. The process repeats with updated guesses until convergence within a specified tolerance is reached.

Uploaded by

raju kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views7 pages

Root Finding by Newton's Method For A Single Equation

The document discusses using Newton's method to find the roots of single variable and multi-variable equations. For a single variable equation f(x)=0, Newton's method approximates the function as a tangent line at an initial guess x0, finds where the line crosses the x-axis to get an updated guess. For two equations f(x,y)=0 and g(x,y)=0, it extends the method by taking partial derivatives of f and g with respect to x and y, setting the equations equal to 0, and solving the equations to update the guesses for x and y. The process repeats with updated guesses until convergence within a specified tolerance is reached.

Uploaded by

raju kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Root finding by Newton’s method for a single equation

If f(x) = 0 and we would like to find out its roots, then we would have to find out the values
of x where the function identically vanishes. At any point say, x0 the function has a value f0
=f (x0).

Then 𝑑𝑑𝑑𝑑 = 𝑓𝑓`(𝑥𝑥0 )𝑑𝑑𝑑𝑑

or we can write 𝑓𝑓 − 𝑓𝑓0 = 𝑓𝑓`(𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) (1)

Incidentally 𝑓𝑓`(𝑥𝑥0 ) is the slope of the tangent to the curve f at a x = x0 and equation (1) is the
tangent to the curve f at x = x0. This tangent will cut the x axis, when, f= 0, so we get a value
of x by setting f = 0 for the tangent equation and this value of x will act as a new guess value
for the solution of our equation f(x) =0. So, we get a new x from our initial guess of x0.
𝑓𝑓 (𝑥𝑥 ) 𝑓𝑓
𝑥𝑥 = 𝑥𝑥0 − 𝑓𝑓`(𝑥𝑥0 ) = 𝑥𝑥0 − 𝑓𝑓`0
0 0
Solution of simultaneous equations by Newton’s method

If we have to solve simultaneous equations then our program which is developed here is not
going to work since it is only for a single equation. So, we have to find out some other logic
and try to solve through EES. In fact we simply extend the logic that is used for a single
equation to simultaneous equations.

Let’s say we have f(x,y) = 0, g(x,y) = 0 and we are interested in solving the two equations or
finding the roots of the equation. The roots of the equation means, for a certain value of x and
y both the equations will be satisfied. If we give an initial guess of x0 and y0 then we get
𝑓𝑓 (𝑥𝑥0 , 𝑦𝑦0 ) = 𝑓𝑓0 𝑎𝑎𝑎𝑎𝑎𝑎 𝑔𝑔(𝑥𝑥0 , 𝑦𝑦0 ) = 𝑔𝑔0

A change in the functional value of f and g (around x0 and y0) can be written as
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝑑𝑑𝑑𝑑 = 𝜕𝜕𝜕𝜕 ∆𝑥𝑥 + 𝜕𝜕𝜕𝜕 ∆𝑦𝑦 = 𝑓𝑓 − 𝑓𝑓0 (3)

𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝑑𝑑𝑑𝑑 = ∆𝑥𝑥 + ∆𝑦𝑦 = 𝑔𝑔 − 𝑔𝑔0
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
It can be thought that f and g are the new values of the functions f(x,y) and g(x,y). If we set f
and g to be zero (in eqn. (3) and (4)) then we can obtain a new guess value for x0 and y0. So,
by setting f and g to be zero in the above equations and solving for ∆𝑥𝑥 𝑎𝑎𝑎𝑎𝑎𝑎 ∆𝑦𝑦 we get,
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 ∆𝑥𝑥 −𝑓𝑓
�𝜕𝜕𝜕𝜕 �� � = � 0� (5)
𝜕𝜕𝜕𝜕 ∆𝑦𝑦 −𝑔𝑔0
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕

Eqn.(5) is now the basis for updating our initial guess values x0 and y0. The new values of x
and y will be

𝑥𝑥 = 𝑥𝑥0 + ∆𝑥𝑥 𝑎𝑎𝑎𝑎𝑎𝑎 𝑦𝑦 = 𝑦𝑦0 + ∆𝑦𝑦


function f(x1,x2) { Not using the power of EES but writing own logic to
solve the equations through EES}
f=x1*ln(x1)-x2^3 { write the function f (x1,x2)= 0 here}
end
function g(x1,x2)
g= x1*x2^2-1 { write the function g(x1,x2) =0 here}
end
function f`x1(x1,x2)
f`x1=1+ln(x1) { write df/dx1 here}
end
function f`x2(x1,x2)
f`x2=-3*x2^2 { write df/dx2 here}
end
function g`x1(x1,x2)
g`x1=x2^2 { write dg/dx1}
end
function g`x2(x1,x2)
g`x2=2*x1*x2 { write dg/dx2}
end
subprogram incre(x1,x2:dx1,dx2) { this subprogram computes the increment of
dx1 and dx2 for x1 and x2}
f`x1(x1,x2)*dx1+f`x2(x1,x2)*dx2=-f(x1,x2) { we are using EES power to solve
dx1 and dx2 and not writing our own logic}
g`x1(x1,x2)*dx1+g`x2(x1,x2)*dx2=-g(x1,x2)
end

procedure newton(x1,x2:x1f,x2f,i) { x1 and x2 are the initial guess to start the


solution}
i=1; eps=1e-3
repeat
call incre(x1,x2:dx1,dx2)
if (abs(dx1) >eps) or (abs(dx2) > eps) then
x1=x1+dx1; x2=x2+dx2
endif
i=i+1 { i= iteration counter which is shown in the diagram window}
until (abs(dx1) <eps) and (abs(dx2) < eps)
x1f=x1; x2f=x2
end
call newton(x1,x2: x1f,x2f,i) { intial guess of x1 and x2 can be given here, x1f
and x2f are the final solution}
{x1=1; x2=2 } { convergence is ok for initial guess of any +ve numbe

You might also like