summaryrefslogtreecommitdiff
path: root/tutorials/module_3/newton-raphson_nonlinear_systemspy
diff options
context:
space:
mode:
authorChristian Kolset <christian.kolset@gmail.com>2025-10-01 14:04:14 -0600
committerChristian Kolset <christian.kolset@gmail.com>2025-10-01 14:04:14 -0600
commitb7652c078a74ec0fd8419c4e0d8f9dc1d7b28020 (patch)
tree436a9952db1fb6f47fb9b6a15e40b9801f925f20 /tutorials/module_3/newton-raphson_nonlinear_systemspy
parent0678159d2801c99437e728823dfccccb9d608174 (diff)
Re-structure of Module 3 to make each file a seperate lecture
Diffstat (limited to 'tutorials/module_3/newton-raphson_nonlinear_systemspy')
-rw-r--r--tutorials/module_3/newton-raphson_nonlinear_systemspy35
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