diff options
Diffstat (limited to 'tutorials/module_3/newton-raphson_nonlinear_systemspy')
| -rw-r--r-- | tutorials/module_3/newton-raphson_nonlinear_systemspy | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tutorials/module_3/newton-raphson_nonlinear_systemspy b/tutorials/module_3/newton-raphson_nonlinear_systemspy new file mode 100644 index 0000000..55a6cf1 --- /dev/null +++ b/tutorials/module_3/newton-raphson_nonlinear_systemspy @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Sat Sep 27 15:31:11 2025 + +@author: christian +""" + +u = lambda x, y: x**2 + x*y - 10 +v = lambda x, y: y + 3*x*y**2 - 57 + +# Initial guesses +x_0 = 1.5 +y_0 = 3.5 + +# Evaluate partial derivatives at initial guesses +dudx = 2*x_0+y_0 +dudy = x_0 + +dvdx = 6*x_0*y_0 +dvdy = 1 + 6*x_0*y_0 + +# Find determinant +det = dudx * dvdy - dudy * dvdx + +# Values of functions valuated at initial guess +u_0 = u(x_0,y_0) +v_0 = v(x_0,y_0) + +# Substitute into newton-raphson equation +x_1 = x_0 - (u_0*dvdy-v_0*dudy) / det +y_1 = y_0 - (v_0*dudx-v_0*dvdx) / det + +print(x_1) +print(y_1)
\ No newline at end of file |
