Mat1b
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -298,14 +298,49 @@ Hvilken vektor er længst? Hvilke vektorer er ortogonale på hinanden? Hvilke to
|
||||
]
|
||||
|
||||
#solution[
|
||||
Længder:
|
||||
$
|
||||
norm(arrow(v)_1)=sqrt((-10)^2 + (-10)^2 + (-10)^2) = #calc.norm(-10,-10,-10)\
|
||||
norm(arrow(v)_2)=sqrt((-10)^2 + (-4)^2 + 14^2) = #calc.norm(-10,-4,14)\
|
||||
norm(arrow(v)_3)=sqrt((-10)^2 + (-8)^2 + (-12)^2) = #calc.norm(-10,-8,-12)\
|
||||
$
|
||||
$v_2$ er længst
|
||||
|
||||
Ortogonale ($v_x dot v_y = 0$):
|
||||
$
|
||||
<arrow(v)_1, arrow(v)_2> &= (-10) dot (-10) + (-10) dot (-4) + (-10) dot 14\
|
||||
&= 100 + 40 - 140 = 0\
|
||||
<arrow(v)_1, arrow(v)_3> &= (-10) dot (-10) + (-10) dot (-8) + (-10) dot (-12)\
|
||||
&= 100 + 80 + 120 = 300\
|
||||
<arrow(v)_2, arrow(v)_3> &= (-10) dot (-10) + (-4) dot (-8) + 14 dot (-12)\
|
||||
&= 100 + 32 - 168 = -36
|
||||
$
|
||||
$arrow(v)_1$ og $arrow(v)_2$ er ortogonale.
|
||||
|
||||
$arrow(v)_1)$ og $arrow(v)_3)$ må være tættest på hinanden, da $arrow(v)_2$ har et positivt koordinat, mens de andre kun har negative.
|
||||
]
|
||||
|
||||
=== 2: Partielle afledede af simpel skalar-funktion
|
||||
|
||||
Find de partielle afledte $p d v(f, x_1)$ og $p d v(f, x_2)$ for $f(x_1, x_2) = x_1^3 + 3 x_1 x_2 + x_2^3$. Bestem værdien af de partielle afledte i punktet $(x_1, x_2) = (1, 2)$.
|
||||
Find de partielle afledte $(partial f)/(partial x_1)$ og $(partial f)/(partial x_2)$ for $f(x_1, x_2) = x_1^3 + 3 x_1 x_2 + x_2^3$. Bestem værdien af de partielle afledte i punktet $(x_1, x_2) = (1, 2)$.
|
||||
|
||||
#solution[
|
||||
$(partial f)/(partial x_1)$:
|
||||
$
|
||||
h(x_1)=x_1^3 + 3 x_1 c_1 + c_2, c_1=x_2, c_2 = x_2^3\
|
||||
h'(x)=3x_1^2+3c_1 + 0\
|
||||
(partial f)/(partial x_1) = 3x_1^2 + 3x_2
|
||||
$
|
||||
I punkt $(x_1, x_2) = (1, 2))$: $3 dot 1^2 + 3 dot 2 = 9$
|
||||
|
||||
$(partial f)/(partial x_2)$:
|
||||
$
|
||||
g(x_2)=c_3 + 3 dot c_4 dot x_2 + x_2^3, quad c_3 = x_1^3, c_4 = x_1\
|
||||
g'(x_2) = 0 + 3 dot c_4 + 3x_2^2\
|
||||
(partial f)/(partial x_2) = 3x_1 + 3x_2^2
|
||||
$
|
||||
I punkt $(x_1, x_2) = (1, 2))$: $3 dot 1 + 3 dot 2^2 = 15$
|
||||
|
||||
|
||||
]
|
||||
|
||||
@@ -341,7 +376,14 @@ for $i = 1, 2, 3$. Sådanne funktioner kaldes kvadratiske former.
|
||||
Gang udtrykket for $q_1(x_1, x_2)$ ud. Først i hånden, så ved hjælp af Python. Gang også udtrykkene for $q_2(x_1, x_2)$ og $q_3(x_1, x_2)$ (i hånden eller Python) ud.
|
||||
|
||||
#solution[
|
||||
$
|
||||
q_1(x_1,x_2) &= mat(x_1,x_2) dot mat(11,-12;-12,4) dot vec(x_1,x_2) + mat(-20,40) dot vec(x_1,x_2) -60\
|
||||
&= mat(x_1,x_2) dot vec(11 x_1 -12 x_2,4x_2-12x_1) -20x_1 + 40x_2 - 60\
|
||||
&= 11 x_1^2 - 12x_1 x_2 + 4x_2^2 - 12x_1 x_2 - 20 x_1 + 40x_2 -60\
|
||||
&= 11x_1^2 + 4x_2^2 - 24x_1x_2 - 20x_1 + 40x_2 - 60
|
||||
$
|
||||
|
||||
Se Python fil for de andre q
|
||||
]
|
||||
|
||||
==== Spørgsmål b
|
||||
@@ -349,7 +391,7 @@ Gang udtrykket for $q_1(x_1, x_2)$ ud. Først i hånden, så ved hjælp af Pytho
|
||||
Er den kvadratiske matrix $A$ i en kvadratisk form (som fx $bold(x)^T A bold(x)$) entydig givet?
|
||||
|
||||
#solution[
|
||||
|
||||
Nej da $q_1(arrow(x))$ og $q_2(arrow(x))$ er ens men har forskellige $bold(A)$. Så forskellige $bold(A)$ kan godt give samme $q(arrow(x))$
|
||||
]
|
||||
|
||||
==== Spørgsmål c
|
||||
|
||||
@@ -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": {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -228,6 +228,123 @@ Så funktionen er ikke kontinuert $(x,y)=(0,0)$
|
||||
|
||||
]
|
||||
]
|
||||
== Kontinuitet af vektorfunktioner
|
||||
#definition(title: "3.2.1")[
|
||||
En funktion $f: "dom"(f) arrow RR, quad "dom"(f) in RR$ er kontinuert i $x_0 in A = "dom"(f)$ hvis
|
||||
$
|
||||
||arrow(f)(arrow(x))-arrow(f)(arrow(x)_0)|| arrow 0 "for" ||arrow(x)-arrow(x)_0)|| arrow 0
|
||||
$
|
||||
]
|
||||
|
||||
= Ortogonale vektor
|
||||
#example(title: "2.1.1")[
|
||||
$
|
||||
<arrow(x), arrow(y)> = arrow(x) dot arrow(y) = x_1 y_1 + x_2 y_2\
|
||||
=
|
||||
|
||||
$
|
||||
|
||||
$arrow(x) eq.not arrow(0)$ og $arrow(y) eq.not arrow(0)$ er ortogonale hvis prik-produkt (indre produkt) er nul:
|
||||
$
|
||||
arrow(x) dot arrow(y) = 0
|
||||
$
|
||||
]
|
||||
|
||||
#definition(title: "2.1.2 og eq 2.6")[
|
||||
Lad $FF=RR$ eller $CC$. For $arrow(x), arrow(y) in CC^n$ er det sædvanlige indre produkt givet ved:
|
||||
$
|
||||
<arrow(x), arrow(y) &= x_1 overline(y_1) + x_2 overline(y_2) + dots + x_n overline(y_n)\
|
||||
&= sum^k_(k=1) x_k overline(y_k)
|
||||
$
|
||||
Hvis $FF=RR$:
|
||||
$
|
||||
<arrow(x),arrow(y)>&=sum^k_(k=1) x_k y_k\
|
||||
&=arrow(y)^T arrow(x)\
|
||||
&= [y_1 y_2 dots y_n] dot vec(x_1, x_2, dots.v, x_3)
|
||||
$
|
||||
|
||||
]
|
||||
|
||||
#example()[
|
||||
I $RR^4$. $arrow(x)=vec(0,1,-3,1), arrow(y)=vec(1,1,3,a)$. Hvilken værdi af $a in RR$ er disse ortogonale?
|
||||
|
||||
#solution()[
|
||||
$
|
||||
<arrow(x), arrow(y)> &= 0 dot 1 + 1 dot 1 + (-3) dot 3 + 1 dot a\
|
||||
= -8 + a <=> a = 8
|
||||
$
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
= Norm/længe af vektor
|
||||
$
|
||||
||arrow(x)|| &= sqrt(<arrow(x)\, arrow(y)>)\
|
||||
&= sqrt(sum^n_(k=1) x_k overline(x_k))\
|
||||
&=sqrt(sum^n_(k=1) |x_k|^2)
|
||||
$
|
||||
|
||||
|
||||
Enhedsvektor hvis $||arrow(x)|| = 1$
|
||||
|
||||
= Kvadratiske former
|
||||
#definition(title: "1.2.1")[
|
||||
$
|
||||
q : RR^n arrow RR, q(arrow(x)) = arrow(x)^T bold(A) arrow(x) + arrow(b)^T arrow(x) + c\
|
||||
bold(A) in RR^(n times n), arrow(b) in RR^n, c in RR
|
||||
$
|
||||
]
|
||||
|
||||
#example()[
|
||||
$n=2$.
|
||||
$
|
||||
bold(A)=mat(-1,0;0,-2), arrow(b)=vec(0,0), c=0, arrow(x)=vec(x_1, x_2)
|
||||
$
|
||||
|
||||
$
|
||||
q(arrow(x))&=mat(x_1,x_2) mat(-1,0;0,-2) vec(x_1, x_2) + mat(0,0) vec(x_1, x_2) + 0\
|
||||
&= mat(x_1,x_2) vec(-x_1 + 0, 0-2x_2) = mat(x_1, x_2) vec(-x_1, 2x_2)\
|
||||
&= -x_1^2 - 2x_2^2
|
||||
$
|
||||
]
|
||||
|
||||
= Delvis afledte
|
||||
#example()[
|
||||
$
|
||||
f: RR^2 arrow RR\
|
||||
f(x_1, x_2) = 1 - (x_1^2)/2 - x_1 x_2^2
|
||||
$
|
||||
|
||||
Laver ny funktion med kun én variabel:
|
||||
$
|
||||
h(x_1) = 1 - x_1^2/2 - x_1 dot c_1, c_1 = x_2^2\
|
||||
h'(x_1)=0- 2/2 x_1 - c_1 = -x_1 - x_2^2
|
||||
$
|
||||
|
||||
$
|
||||
(partial f)/(partial x_1) (arrow(x))= -x_1 - x_2^2
|
||||
$
|
||||
|
||||
For $x_2$:
|
||||
$
|
||||
g(x_2)=1-c_2 - c_3 x_2^2\
|
||||
"hvor" c_2 = x_1^2/2, c_3 = x_1\
|
||||
g'(x_2) = 0-0-2 c_3 x_2
|
||||
$
|
||||
Så:
|
||||
$
|
||||
(partial f)/(partial x_2) (arrow(x)) = -2x_1 x_2
|
||||
$
|
||||
]
|
||||
#definition(title: "3.2.2 (gradientvektoren)")[
|
||||
$
|
||||
arrow(nabla) f(arrow(x))= vec((partial f)/(partial x_1) (arrow(x)), (partial f)/(partial x_2) (arrow(x)), dots.v, (partial f)/(partial x_n) (arrow(x)))
|
||||
$
|
||||
Den hører altid til i domænet af f.
|
||||
]
|
||||
|
||||
Gradientvektoren fra før:
|
||||
$
|
||||
arrow(nabla) q (arrow(x)) = vec(-2x_1, -4x_2)
|
||||
$
|
||||
|
||||
|
||||
Reference in New Issue
Block a user