I had to extend the matrix library to add 2norm and transpose functions.
matrix.c matrix.h
The code for the new library is here:06_SystemsNonLinearEq.c 06_SystemsNonLinearEq.h
Finally the example program to define the function is here: 06_SystemsNonLinearEq_HW.c
The system of 3 equations with three unknowns. Followed by 9 derivatives with respect to X1, X2, and X3. |
initial 0 0 00 0.0112181743 0.0100963569 -0.5227407743 1 -0.0392975036 0.0960761555 -0.5230125588
Once you have that initial guess then you can use Newtons method which converges in just a few iterations:
0 0.5002972122 0.0144515939 -0.5210250069 1 0.5000081616 0.0009138476 -0.5235749873 2 0.5000000378 0.0000041458 -0.5235986672 3 0.5000000000 0.0000000001 -0.5235987756 4 0.5000000000 -0.0000000000 -0.5235987756If you aren't close with the initial value on Newton's method it may never converge to a value.
Most of the time in books for class the initial guess is just provided for you, our teacher went that extra 2 days of work to let us figure out the guess ourselves. Because nobody will give you that initial guess in the real world.
What I need to do now is to find the error and only stop once I have met the required accuracy.
--
I fixed a couple of issues with symbols in converting from math to the c programming language. It wasn't clear that the quadratic was always 3 points, I was setting it to OrderSize points instead. Fixed that.
--
Modified the program so you can set how many iterations of steepest descent you want, with none as an option. Ran into a homework problem where steepest descent just ran off into the wild blue yonder.
----
--
Feeding solution back into formulas as an accuracy and final sanity check. :D |
----
This is one of my homework problems that is due on Tuesday. It is a 2nd order non linear system of equations. As you can see in main() the system_new function defines the 2 order and the title. Then the Jacobian functions are defined based on the derivatives of those functions for either x1 or x2. When you are creating a derivative of a function on a variable, every other variable is treated like it was a constant.
No comments:
Post a Comment