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

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)