Open Educational Resources

Python Lab Tutorials: Lab 6

Create a procedure whose inputs are the vector of functions f=\{f_1,f_2,\cdots,f_n \}, the vector of the names of the unknowns x=\{x_1,x_2,\cdots,x_n \} and the initial guesses x^{(0)}=\{x_1^{(0)},x_2^{(0)},\cdots,x_n^{(0)} \}. The procedure should do the following:

Find the length of the vectors f or x (These should be equal, a more robust code should stop the computations if they are not but this is not required)
The procedure should then form the matrix

    \[     K_{ij}=\frac{\partial f_i}{\partial x_j}\]

The procedure should then output \Delta x=-K^{-1} f evaluated at the values of the initial guesses.
Use the above procedure along with an appropriate “while” loop to find two different solutions (using two different initial guesses) for the following system of nonlinear equations.
Use ε_s=0.00001. Compare with the Newton Raphson method implemented in Sympy using “nroot”.

    \[     \begin{split}       x_1^2+x_2^2&=100\\      x_1 x_2+x_2 x_3&=-102\\       x_2^2+x_3^2&=117       \end{split}\]

Video Tutorials

Newton Raphson Method for Nonlinear Systems of Equations

Leave a Reply

Your email address will not be published. Required fields are marked *