I was given the problem Find on the next page an outline for a C program that solves two nonlinear equations
f1(x,y) = 0
f2(x,y) = 0
PROGRAM OUTLINE: Newton-Raphson Method in 2-Dimensions
To solve:
0 = f_1 (x,y) = x*x - 2.0*x - y + 0.5
0 = f_2 (x,y) = x*x + 4.0*y*y - 4.0
I already know how to do 1 dimensional, a psudocode would be preferable, or at least some form of direction.
How do I use Newton Raphson method for solving 2-D equations in C programming?
You're actually trying to solve 3-D equations. You'd graph these functions f1 and f2 as z = f1(x,y) and get a 3-D surface.
The Newton-Raphson method is to use the derivative to find a better estimate for a zero.
For a 2-D function, y = f(x), each iteration takes x_guess and produces x_next_guess like this:
x_next_guess = x_guess - ( f(x_guess) / f'(x_guess) )
where f' is the derivitive, d f(x) / dx.
To expand that to two variables, think about choosing a random (x, y) point instead of an x value as the guess. Then consider that you can get two derivative functions:
g(x,y) = d f / dx, and
h(x,y) = d f / dy
Then you can use those derivatives to find the next point (x_next, y_next) to use as an improved guess.
x_next = x - ( f(x,y) / g(x,y) )
y_next = y - ( f(x,y) / h(x,y) )
queen of the night
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment