File Exchange

## Newton-Raphson Method for 2 variables

version 1.0 (1.91 KB) by

Newton method for non-linear system of 2 variables (also solves linear system)

Updated

This program calculates the roots of a system of non-linear equations in 2 variables. This a script file and you only have to write in the command windows ">>newton2v2", and the program ask for the functions and other elements that are necessary. What I mean "quotes" is single quotes,like this: ' .
I will be grateful for any comment.
I also have this program for 3, 4 ,5 variables and can be extended to any number of variables

Sandeep Soni

### Sandeep Soni (view profile)

When i am running your code for following equations,roots are not correct .Kindly help me.
f1(x,y) = '(((1+2*x^2)/(1-x^2))+(4*(1-2*y^2)*sqrt(1-x^2)*(2+x^2))/((1-x^2)*(1-y^2)^0.5*(2+y^2)))'

f2(x,y) = '(((4*(y*(2+x^2)*(1-x^2)*sqrt(pi^2*(1-y^2)+4*y^2)))/(x*(2+y^2)*(1-y^2)*sqrt(pi^2*(1-x^2)+4*x^2))-1))'

The initial values are xo = 0.10 and yo = 0.10
The maximun number of iteration is k = 100
and the tolerance is: 1.00e-007

The Root are:
x = 5.7355e+054 +5.3264e+053i
y = 5.7207e+054 +5.3127e+053i

Thanks,
Sandeep Soni,
sandytit2004@gmail.com

Saqib

Saqib

### Saqib (view profile)

@Hernandez

can u plz post the m file code for 4 variables?

Vagelis Kounis

### Vagelis Kounis (view profile)

EMRE before running the program try
>> syms x y

EKTOR
diff(f,n) means give me the nth derivative of f, and thats why it needs to be integer..

Ektor

### Ektor (view profile)

The first function? (between quotes) f1(x,y) = x+y
The second function? (between quotes)f2(x,y) = 2*x+y
??? Error using ==> diff
Difference order N must be a positive integer scalar.

Error in ==> newton2v2 at 24

Why is this happening?

Emre

### Emre (view profile)

can you give any input examples?

Emre

### Emre (view profile)

I can not enter my functions, it says
"??? Error using ==> input
Undefined function or variable 'x'.

Error in ==> Untitled at 22
f1name = input('The first function? (between quotes) f1(x,y) = ');"

xingyu

### xingyu (view profile)

Hi where can I get the propram for 4 variables ?

chanchal gupta

### chanchal gupta (view profile)

thanx for this code.....

##### MATLAB Release
MATLAB 6.1 (R12.1)