This commit is contained in:
2026-02-09 07:43:40 +01:00
parent df76bf146f
commit d4bba0881b
5 changed files with 5383 additions and 3663 deletions

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"id": "d2493461",
"metadata": {},
"outputs": [
@@ -24,6 +24,80 @@
"print(sympy.Max(h,0))\n",
"print(relu)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "de59fd98",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}x_{1} \\left(11 x_{1} - 12 x_{2}\\right) - 20 x_{1} + x_{2} \\left(- 12 x_{1} + 4 x_{2}\\right) + 40 x_{2} - 60\\end{matrix}\\right]$"
],
"text/plain": [
"Matrix([[x_1*(11*x_1 - 12*x_2) - 20*x_1 + x_2*(-12*x_1 + 4*x_2) + 40*x_2 - 60]])"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}x_{1} \\left(11 x_{1} - 24 x_{2}\\right) - 20 x_{1} + 4 x_{2}^{2} + 40 x_{2} - 60\\end{matrix}\\right]$"
],
"text/plain": [
"Matrix([[x_1*(11*x_1 - 24*x_2) - 20*x_1 + 4*x_2**2 + 40*x_2 - 60]])"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}x_{1} \\left(14.6 x_{1} - 7.2 x_{2}\\right) - 44 x_{1} + x_{2} \\left(- 7.2 x_{1} + 10.4 x_{2}\\right) + 8 x_{2} - 60\\end{matrix}\\right]$"
],
"text/plain": [
"Matrix([[x_1*(14.6*x_1 - 7.2*x_2) - 44*x_1 + x_2*(-7.2*x_1 + 10.4*x_2) + 8*x_2 - 60]])"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import sympy as sp\n",
"import numpy\n",
"\n",
"x_1, x_2 = sp.symbols('x_1, x_2')\n",
"\n",
"A_1 = sp.Matrix([[11,-12],[-12,4]])\n",
"A_2 = sp.Matrix([[11,0],[-24,4]])\n",
"A_3 = sp.Matrix([[73/5,-36/5],[-36/5,52/5]])\n",
"\n",
"b_1 = sp.Matrix([-20,40])\n",
"b_2 = b_1\n",
"b_3 = sp.Matrix([-44,8])\n",
"\n",
"x = sp.Matrix([x_1,x_2])\n",
"\n",
"c = sp.Matrix([-60])\n",
"\n",
"q_1 = x.T * A_1 * x + b_1.T * x + c\n",
"\n",
"q_2 = x.T * A_2 * x + b_2.T * x + c\n",
"\n",
"q_3 = x.T * A_3 * x + b_3.T * x + c\n",
"\n",
"display(q_1)\n",
"\n",
"display(q_2)\n",
"\n",
"display(q_3)\n"
]
}
],
"metadata": {