I have this homework problem for solving 6 non-linear equations for 6 variables using Newton's Method.
I'm trying to do this example problem in the book to help me get started, but I'm stuck on the easy part because I don't know MATLAB's syntax well enough.
The program and sample problem
Sample problem continued
You don't really have to know Newton's Method to help, just need to know how to use MATLAB a little bit. So I typed the given program in the blue box in an M-file. The part I'm confused about is calling the function
Newton_sys(F, JF, x0, tol, max_it)
I don't know how to define F and JF to be able to call the function. If you look at the two scanned pages, you'll see the system of 3 equations, and those are what I'm supposed to define for F and JF, but I don't know how.
Here's what I have:
In the file func.m:
function F = func(x1, x2, x3)
F = [ (x1^2 + x2^2 + x3^2 -1)
(x1^2 + 0 + x3^2 - .25)
(x1^2 + x2^2 -4*x3 + 0) ];
In the file myfunc.m:
function B = myfunc(x1, x2, x3)
B = [2*x1 2*x2 2*x3
2*x1 0 2*x3
2*x1 2*x2 -4];
I defined guess as [1 1 1]
And in MATLAB"s command window, I tried calling Newton_sys with:
C = Newton_sys('func', 'myfunc', guess, .00001, 200)
And it doesn't work. All I really need (ASAP please!) is how do I get the system of 3 equations and its Jacobian (see scanned pages) into the vectors 'F' and' JF' so it can be used to solve with the function Newton_sys. Thanks.
I'm trying to do this example problem in the book to help me get started, but I'm stuck on the easy part because I don't know MATLAB's syntax well enough.
The program and sample problem
Sample problem continued
You don't really have to know Newton's Method to help, just need to know how to use MATLAB a little bit. So I typed the given program in the blue box in an M-file. The part I'm confused about is calling the function
Newton_sys(F, JF, x0, tol, max_it)
I don't know how to define F and JF to be able to call the function. If you look at the two scanned pages, you'll see the system of 3 equations, and those are what I'm supposed to define for F and JF, but I don't know how.
Here's what I have:
In the file func.m:
function F = func(x1, x2, x3)
F = [ (x1^2 + x2^2 + x3^2 -1)
(x1^2 + 0 + x3^2 - .25)
(x1^2 + x2^2 -4*x3 + 0) ];
In the file myfunc.m:
function B = myfunc(x1, x2, x3)
B = [2*x1 2*x2 2*x3
2*x1 0 2*x3
2*x1 2*x2 -4];
I defined guess as [1 1 1]
And in MATLAB"s command window, I tried calling Newton_sys with:
C = Newton_sys('func', 'myfunc', guess, .00001, 200)
And it doesn't work. All I really need (ASAP please!) is how do I get the system of 3 equations and its Jacobian (see scanned pages) into the vectors 'F' and' JF' so it can be used to solve with the function Newton_sys. Thanks.