Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
50 views
ubuntu2004
Kernel: Python 3 (system-wide)

MIT 18.06 Linear Algebra, Spring 2005 Instructor: Gilbert Strang View the complete course: http://ocw.mit.edu/18-06S05 Professor of Matematics MIT
Get the full picture at https://ocw.mit.edu.
https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/
https://www.youtube.com/c/mitocw/about

Gilbert 1 Linjär Algebra

Sträva efter att se vektor-koloner

{y=2x1y=x+5\left\{\begin{matrix} y&=&2x-1\\ y&=&-x+5 \end{matrix}\right.

[y=2x1y=x+5]\begin{bmatrix}y=2x-1 \\y=-x+5 \\\end{bmatrix}

alt text


[1x+1y=52x+1y=1]\begin{bmatrix}1x + 1y=5 \\ -2x+ 1y=-1 \\\end{bmatrix}

[1121][xy]=[51]\left[\begin{matrix}1 &1\\-2&1\end{matrix}\right]\left[\begin{matrix}x\\y\end{matrix}\right]= \left[\begin{matrix}5\\-1\end{matrix}\right]

x[12]+y[11]=[51]x\left[\begin{matrix}1\\-2\end{matrix}\right]+ y\left[\begin{matrix}1\\1\end{matrix}\right]=\left[\begin{matrix}5\\-1\end{matrix}\right]

alt text

import sympy as sp x=sp.Symbol('x') y=sp.Symbol('y') f=sp.Function('f')(x) g=sp.Function('g')(x) f=2*x-1 g=-x+5 sp.plot(f,g) svar=sp.solve(f-g) print('x=',svar[0],'y=',f.subs(x,svar[0]))
Image in a Jupyter notebook
x= 2 y= 3
A=[[1,1],[-2,1]] A=sp.Matrix(A) A

[1121]\displaystyle \left[\begin{matrix}1 & 1\\-2 & 1\end{matrix}\right]

B=[[5],[-1]] B=sp.Matrix(B) B

[51]\displaystyle \left[\begin{matrix}5\\-1\end{matrix}\right]

X=[[x],[y]] X=sp.Matrix(X) X

[xy]\displaystyle \left[\begin{matrix}x\\y\end{matrix}\right]

x[12]+y[11]=[51]x\left[\begin{matrix}1\\-2\end{matrix}\right]+ y\left[\begin{matrix}1\\1\end{matrix}\right]=\left[\begin{matrix}5\\-1\end{matrix}\right]

from sympy import init_printing,latex init_printing(use_latex=True) from sympy import pprint pprint(B) W=A*X pprint(W) #vector solution ekv1=x*sp.Matrix([[1],[-2]])+y*sp.Matrix([[1],[1]])-B sv=sp.solve(ekv1) print(sv) 2*sp.Matrix([[1],[-2]])+3*sp.Matrix([[1],[1]])
⎡5 ⎤ ⎢ ⎥ ⎣-1⎦ ⎡ x + y ⎤ ⎢ ⎥ ⎣-2⋅x + y⎦ {x: 2, y: 3}

[51]\displaystyle \left[\begin{matrix}5\\-1\end{matrix}\right]

AX=BA1AX=A1BIX=A1B\begin{array}{rcl} A*X & = & B \\ {A}^{-1}*A*X & = & {A}^{-1}*B \\ I*X& = & {A}^{-1}*B \end{array}

A.inv()*A*X

[xy]\displaystyle \left[\begin{matrix}x\\y\end{matrix}\right]

W=[[1,1,5],[-2,1,-1]] W=sp.Matrix(W) print(latex(W)) print(latex(A.inv()*B)) W.rref(pivots=False)
\left[\begin{matrix}1 & 1 & 5\\-2 & 1 & -1\end{matrix}\right] \left[\begin{matrix}2\\3\end{matrix}\right]

[102013]\displaystyle \left[\begin{matrix}1 & 0 & 2\\0 & 1 & 3\end{matrix}\right]

[xy]=[23]\left[\begin{matrix}x\\y\end{matrix}\right]= \left[\begin{matrix}2\\3\end{matrix}\right]

#A.inv()*B #print($$\left[\begin{matrix}x\\y\end{matrix}\right]= \left[\begin{matrix}2\\3\end{matrix}\right]$$) from IPython.display import display, Math, Latex #display(Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx')) display(Math(r'\left[\begin{matrix}x\\y\end{matrix}\right]= \left[\begin{matrix}2\\3\end{matrix}\right]'))

[xy]=[23]\displaystyle \left[\begin{matrix}x\\y\end{matrix}\right]= \left[\begin{matrix}2\\3\end{matrix}\right]

[y=2x1y=x+5]\begin{bmatrix}y=2x-1 \\y=-x+5 \\\end{bmatrix}

[2x+1y=11x+1y=5]\begin{bmatrix}-2x+ 1y=-1 \\1x + 1y=5 \\\end{bmatrix}

[2xy=0x+2yz=10x3y+4z=4]\begin{bmatrix}2x-y =0 \\-x+2y-z=-1\\0x-3y+4z=4 \\\end{bmatrix}

[210121034][xyz]\begin{bmatrix}-2&-1& 0 \\-1&2&-1\\0&-3&4 \\\end{bmatrix}\left[\begin{matrix}x\\y\\z\end{matrix}\right]=[014]\left[\begin{matrix}0\\-1\\4\end{matrix}\right]

A3*X3=B3
A3.inv()A3X3=A3.inv()*B3
x3=A3.inv()*B3

A3=[[2,-1,0],[-1,2,-1],[0,-3,4]] A3=sp.Matrix(A3) A3

[210121034]\displaystyle \left[\begin{matrix}2 & -1 & 0\\-1 & 2 & -1\\0 & -3 & 4\end{matrix}\right]

B3=sp.Matrix([[0],[-1],[4]]) B3

[014]\displaystyle \left[\begin{matrix}0\\-1\\4\end{matrix}\right]

x,y,z=sp.symbols("x y z") X3=sp.Matrix([[x],[y],[z]]) X3

[xyz]\displaystyle \left[\begin{matrix}x\\y\\z\end{matrix}\right]

x[210]+y[123]+z[014]=[014]x\left[\begin{matrix}2\\-1\\0\end{matrix}\right]+ y\left[\begin{matrix}-1\\2\\-3\end{matrix}\right]+ z\left[\begin{matrix}0\\-1\\4\end{matrix}\right]=\left[\begin{matrix}0\\-1\\4\end{matrix}\right]

A3.inv()*B3

[001]\displaystyle \left[\begin{matrix}0\\0\\1\end{matrix}\right]

x[210]+y[123]+z[014]=[113]x\left[\begin{matrix}2\\-1\\0\end{matrix}\right]+ y\left[\begin{matrix}-1\\2\\-3\end{matrix}\right]+ z\left[\begin{matrix}0\\-1\\4\end{matrix}\right]=\left[\begin{matrix}1\\1\\-3\end{matrix}\right]

B4=sp.Matrix([[1],[1],[-3]]) B4

[113]\displaystyle \left[\begin{matrix}1\\1\\-3\end{matrix}\right]

A3.inv()*B4

[110]\displaystyle \left[\begin{matrix}1\\1\\0\end{matrix}\right]

#https://carbon.now.sh/ - för att klistra in snygga kod block

M1=A=[[2,5],[1,3]] b=sp.Matrix([12,7]) M1=sp.Matrix(M1) X5=[[1],[2]] X5=sp.Matrix(X5) M1*X5

[127]\displaystyle \left[\begin{matrix}12\\7\end{matrix}\right]

M1.LUsolve(b)

[12]\displaystyle \left[\begin{matrix}1\\2\end{matrix}\right]

Två olika sätt

1[21]+2[53]=[127]1\left[\begin{matrix}2\\1\end{matrix}\right]+ 2\left[\begin{matrix}5\\3\end{matrix}\right]=\left[\begin{matrix}12\\7\end{matrix}\right]

[2513][12]\left[\begin{matrix}2 &5\\1&3\end{matrix}\right]\left[\begin{matrix}1\\2\end{matrix}\right]= [127]\left[\begin{matrix}12\\7\end{matrix}\right]

Sammanfattning