serie 01 and 02

This commit is contained in:
2026-03-11 12:04:23 +01:00
parent d8e3a1d94b
commit b391a0c8a4
8 changed files with 259 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,36 @@
import sympy as sp
x1, x2, x3 = sp.symbols("x1 x2 x3", real=True)
f_a = sp.Matrix([
5 * x1 * x2,
x1**2 * x2**2 + x1 + 2 * x2
])
D_f_a = f_a.jacobian(sp.Matrix([x1, x2]))
D_f_a_at_point = D_f_a.subs({x1: 1, x2: 2})
print("D_f_a(x) =")
sp.pprint(D_f_a)
print("Aufgabe 2a:")
sp.pprint(D_f_a_at_point)
f_b = sp.Matrix([
sp.log(x1**2 + x2**2) + x3**2,
sp.exp(x2**2 + x3**2) + x1**2,
1 / (x3**2 + x1**2) + x2**2
])
D_f_b = f_b.jacobian(sp.Matrix([x1, x2, x3]))
D_f_b_at_point = D_f_b.subs({x1: 1, x2: 2, x3: 3})
print("\nD_f_b(x) =")
sp.pprint(D_f_b)
print("\nAufgabe 2b:")
sp.pprint(sp.simplify(D_f_b_at_point))

View File

@@ -0,0 +1,43 @@
import sympy as sp
x1, x2, x3 = sp.symbols("x1 x2 x3", real=True)
x = sp.Matrix([x1, x2, x3])
f = sp.Matrix([
x1 + x2**2 - x3**2 - 13,
sp.log(x2 / 4) + sp.exp(sp.Rational(1, 2) * x3 - 1) - 1,
(x2 - 3)**2 - x3**3 + 7
])
x0 = sp.Matrix([
sp.Rational(3, 2),
3,
sp.Rational(5, 2)
])
substitution_dictionary = {
x1: x0[0],
x2: x0[1],
x3: x0[2]
}
function_value_at_x0 = f.subs(substitution_dictionary)
jacobian_matrix = f.jacobian(x)
jacobian_matrix_at_x0 = jacobian_matrix.subs(substitution_dictionary)
linearized_function = sp.simplify(
function_value_at_x0 + jacobian_matrix_at_x0 * (x - x0)
)
print("f(x0) =")
sp.pprint(function_value_at_x0)
print("\nDf(x) =")
sp.pprint(jacobian_matrix)
print("\nDf(x0) =")
sp.pprint(jacobian_matrix_at_x0)
print("\nL(x) =")
sp.pprint(linearized_function)