Grafiken erweitert
This commit is contained in:
@@ -1,16 +1,54 @@
|
|||||||
Linear Algebra Refresher
|
# Linear Algebra Refresher
|
||||||
|
|
||||||
Addition von Vektoren
|
## Grundgerüst
|
||||||
|
|
||||||
|
```python
|
||||||
|
# -*- coding: iso-8859-15 -*
|
||||||
|
from math import sqrt
|
||||||
|
|
||||||
|
class Vector(object):
|
||||||
|
def __init__(self, coordinates):
|
||||||
|
try:
|
||||||
|
if not coordinates:
|
||||||
|
raise ValueError
|
||||||
|
self.coordinates = tuple(coordinates)
|
||||||
|
self.dimension = len(coordinates)
|
||||||
|
|
||||||
|
except ValueError:
|
||||||
|
raise ValueError('Die Koordinaten dürfen nicht leer sein')
|
||||||
|
|
||||||
|
except TypeError:
|
||||||
|
raise TypeError('Die Koordinaten müssen iterierbar sein')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return 'Vector: {}'.format(self.coordinates)
|
||||||
|
|
||||||
|
def __eq__(self, v):
|
||||||
|
return self.coordinates == v.coordinates
|
||||||
|
```
|
||||||
|
|
||||||
|
## Addition von Vektoren
|
||||||
|
|
||||||
$\left[ {\begin{array}{*{20}{c}}
|
$\left[ {\begin{array}{*{20}{c}}
|
||||||
1\\
|
5\\
|
||||||
2
|
0
|
||||||
\end{array}} \right] + \left[ {\begin{array}{*{20}{c}}
|
\end{array}} \right] + \left[ {\begin{array}{*{20}{c}}
|
||||||
3\\
|
2\\
|
||||||
1
|
2
|
||||||
\end{array}} \right] = \left[ {\begin{array}{*{20}{c}}
|
\end{array}} \right] = \left[ {\begin{array}{*{20}{c}}
|
||||||
4\\
|
7\\
|
||||||
3
|
2
|
||||||
\end{array}} \right]$
|
\end{array}} \right]$
|
||||||
|
|
||||||
<img src="vektor_add.png" style="zoom:50%;" />
|
```python
|
||||||
|
veka1 = Vector([0,5])
|
||||||
|
veka2 = Vector([2,2])
|
||||||
|
|
||||||
|
print (veka1.plus(veka2))
|
||||||
|
```
|
||||||
|
|
||||||
|
<img src="vektor_add.png" style="zoom:40%;" />
|
||||||
|
|
||||||
|
```python
|
||||||
|
veka1 = Vector([0,5])
|
||||||
|
```
|
||||||
BIN
Vek_Subt_1.pdf
Normal file
BIN
Vek_Subt_1.pdf
Normal file
Binary file not shown.
43
Vek_Subt_1.tex
Normal file
43
Vek_Subt_1.tex
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
\documentclass[10pt]{article}
|
||||||
|
\usepackage{pgf,tikz,pgfplots}
|
||||||
|
\pgfplotsset{compat=1.16}
|
||||||
|
\usepackage{mathrsfs}
|
||||||
|
\usetikzlibrary{arrows}
|
||||||
|
\pagestyle{empty}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
|
||||||
|
|
||||||
|
\begin{tikzpicture}[x=1cm,y=1cm]
|
||||||
|
|
||||||
|
\begin{axis}[
|
||||||
|
x=1cm,y=1cm,
|
||||||
|
axis lines=middle,
|
||||||
|
ymajorgrids=true,
|
||||||
|
xmajorgrids=true,
|
||||||
|
xmin=-1.4889190764182563,
|
||||||
|
xmax=9.29392311219538,
|
||||||
|
ymin=-2.7120035219099305,
|
||||||
|
ymax=6.461032721583817,
|
||||||
|
xtick={-1,-0.5,...,9},
|
||||||
|
ytick={-2.5,-2,...,6},]
|
||||||
|
|
||||||
|
\clip(-1.4889190764182563,-2.7120035219099305) rectangle (9.29392311219538,6.461032721583817);
|
||||||
|
|
||||||
|
\draw [-latex,line width=2pt] (0,0) -- (4,1);
|
||||||
|
\draw [-latex,line width=2pt,color=red] (0,0) -- (2,3);
|
||||||
|
\draw [-latex,line width=1.2pt,dash pattern=on 1pt off 1pt,color=orange] (4,1) -- (6,4);
|
||||||
|
\draw [-latex,line width=1.2pt,dash pattern=on 1pt off 1pt,color=orange] (2,3) -- (6,4);
|
||||||
|
\draw [color=blue,-latex,line width=2pt] (0,0) -- (6,4);
|
||||||
|
\begin{scriptsize}
|
||||||
|
|
||||||
|
\draw[color=orange] (0.07325947387559195,0.1885048229954136) node {$A$};
|
||||||
|
\draw[color=black] (2.949954121367923,2.350788548097263) node {$u$};
|
||||||
|
\draw[color=black] (2.273645114838269,0.845762871594654) node {$v$};
|
||||||
|
\draw[color=red] (0.8067213541964842,1.7697343312196734) node {$w$};
|
||||||
|
\draw[color=orange] (5.350374820599933,2.5603490853318034) node {$a$};
|
||||||
|
\draw[color=orange] (4.073960639262277,3.8558142245998717) node {$b$};
|
||||||
|
\end{scriptsize}
|
||||||
|
\end{axis}
|
||||||
|
\end{tikzpicture}
|
||||||
|
\end{document}
|
||||||
BIN
Vek_Subt_2.pdf
Normal file
BIN
Vek_Subt_2.pdf
Normal file
Binary file not shown.
49
Vek_Subt_2.tex
Normal file
49
Vek_Subt_2.tex
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
\documentclass[10pt]{article}
|
||||||
|
\usepackage{pgf,tikz,pgfplots}
|
||||||
|
\pgfplotsset{compat=1.16}
|
||||||
|
\usepackage{mathrsfs}
|
||||||
|
\usetikzlibrary{arrows}
|
||||||
|
\pagestyle{empty}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\begin{tikzpicture}[x=1cm,y=1cm]
|
||||||
|
|
||||||
|
\begin{axis}[
|
||||||
|
x=1cm,y=1cm,
|
||||||
|
axis lines=middle,
|
||||||
|
ymajorgrids=true,
|
||||||
|
xmajorgrids=true,
|
||||||
|
xmin=-0.5,
|
||||||
|
xmax=6.5,
|
||||||
|
ymin=-1.5,
|
||||||
|
ymax=3.5,
|
||||||
|
xtick={-2,-1,...,7},
|
||||||
|
ytick={-3,-2,...,7},]
|
||||||
|
|
||||||
|
\clip(-2.362405497527683,-3.0044357261417667) rectangle (9.498720909947316,7.085904141701357);
|
||||||
|
|
||||||
|
\draw [-latex,line width=2pt,color=red] (0,0) -- (6,2);
|
||||||
|
\draw [-latex,line width=2pt, color=orange] (0,0) -- (1.5,3);
|
||||||
|
\draw [-latex,line width=2pt,color=blue] (0,0) -- (4.5,-1);
|
||||||
|
\draw [-latex,line width=1.2pt,dash pattern=on 1pt off 1pt,color=blue] (1.5,3) -- (6,2);
|
||||||
|
\draw [-latex,line width=1.2pt,dash pattern=on 1pt off 1pt,color=orange] (4.5,-1) -- (6,2);
|
||||||
|
\begin{scriptsize}
|
||||||
|
|
||||||
|
|
||||||
|
\draw[color=black] (2.9604321482296485,1.3910965423527197) node {$u$};
|
||||||
|
|
||||||
|
|
||||||
|
\draw[color=orange] (0.5,1.852129724268709) node {$\vec{x}$};
|
||||||
|
\draw[color=orange] (2.090755918706305,-0.18060748690633394) node {$w$};
|
||||||
|
\draw[color=orange] (4.175883264189984,2.5751135777278735) node {$a$};
|
||||||
|
\draw[color=orange] (5.1,0.8776732261280955) node {$\vec{x}'$};
|
||||||
|
|
||||||
|
\end{scriptsize}
|
||||||
|
\end{axis}
|
||||||
|
|
||||||
|
\end{tikzpicture}
|
||||||
|
|
||||||
|
\end{document}
|
||||||
44
Vektor_Laenge.tex
Normal file
44
Vektor_Laenge.tex
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
\documentclass[10pt]{article}
|
||||||
|
\usepackage{pgf,tikz,pgfplots}
|
||||||
|
\pgfplotsset{compat=1.15}
|
||||||
|
\usepackage{mathrsfs}
|
||||||
|
\usetikzlibrary{arrows}
|
||||||
|
\pagestyle{empty}
|
||||||
|
\newcommand{\degre}{\ensuremath{^\circ}}
|
||||||
|
\begin{document}
|
||||||
|
\definecolor{qqwuqq}{rgb}{0,0.39215686274509803,0}
|
||||||
|
\definecolor{ududff}{rgb}{0.30196078431372547,0.30196078431372547,1}
|
||||||
|
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1}
|
||||||
|
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
|
||||||
|
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
|
||||||
|
\begin{axis}[
|
||||||
|
x=1cm,y=1cm,
|
||||||
|
axis lines=middle,
|
||||||
|
ymajorgrids=true,
|
||||||
|
xmajorgrids=true,
|
||||||
|
xmin=-1.3544263878097484,
|
||||||
|
xmax=9.691411951745668,
|
||||||
|
ymin=-3.214189806288097,
|
||||||
|
ymax=6.1825790285103785,
|
||||||
|
xtick={-1,-0.5,...,9.5},
|
||||||
|
ytick={-3,-2.5,...,6},]
|
||||||
|
\clip(-1.3544263878097484,-3.214189806288097) rectangle (9.691411951745668,6.1825790285103785);
|
||||||
|
\draw[line width=2pt,color=qqwuqq,fill=qqwuqq,fill opacity=0.10000000149011612] (8,0.20699436025945198) -- (7.793005639740548,0.206994360259452) -- (7.793005639740548,0) -- (8,0) -- cycle;
|
||||||
|
\draw [line width=2pt] (0,0)-- (8,0);
|
||||||
|
\draw [line width=2pt] (8,0)-- (8,4);
|
||||||
|
\draw [->,line width=2pt] (0,0) -- (8,4);
|
||||||
|
\begin{scriptsize}
|
||||||
|
\draw [fill=uuuuuu] (0,0) circle (2pt);
|
||||||
|
\draw[color=uuuuuu] (0.07997134709718273,0.18640618429058298) node {$A$};
|
||||||
|
\draw [fill=xdxdff] (8,0) circle (2.5pt);
|
||||||
|
\draw[color=xdxdff] (8.081373677870541,0.2059217997314936) node {$B$};
|
||||||
|
\draw[color=black] (4.031883473881585,-0.03802339327988945) node {$f$};
|
||||||
|
\draw [fill=ududff] (8,4) circle (2.5pt);
|
||||||
|
\draw[color=ududff] (8.081373677870541,4.206622965118176) node {$C$};
|
||||||
|
\draw[color=black] (8.188709562795548,2.1184521129407368) node {$g$};
|
||||||
|
\draw[color=qqwuqq] (8.315561063161468,0.18640618429058298) node {$\alpha = 90\textrm{\degre}$};
|
||||||
|
\draw[color=black] (4.012367858440674,2.157483343822558) node {$u$};
|
||||||
|
\end{scriptsize}
|
||||||
|
\end{axis}
|
||||||
|
\end{tikzpicture}
|
||||||
|
\end{document}
|
||||||
50
Vektor_add_1.tex
Normal file
50
Vektor_add_1.tex
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
\documentclass[10pt]{article}
|
||||||
|
\usepackage{pgf,tikz,pgfplots}
|
||||||
|
\pgfplotsset{compat=1.15}
|
||||||
|
\usepackage{mathrsfs}
|
||||||
|
\usetikzlibrary{arrows}
|
||||||
|
\pagestyle{empty}
|
||||||
|
\begin{document}
|
||||||
|
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1}
|
||||||
|
\definecolor{ududff}{rgb}{0.30196078431372547,0.30196078431372547,1}
|
||||||
|
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
|
||||||
|
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
|
||||||
|
\begin{axis}[
|
||||||
|
x=1cm,y=1cm,
|
||||||
|
axis lines=middle,
|
||||||
|
ymajorgrids=true,
|
||||||
|
xmajorgrids=true,
|
||||||
|
xmin=-4.66270591911281,
|
||||||
|
xmax=11.894647164540304,
|
||||||
|
ymin=-2.4761462907710943,
|
||||||
|
ymax=7.830725732214009,
|
||||||
|
xtick={-4,-3,...,11},
|
||||||
|
ytick={-2,-1,...,7},]
|
||||||
|
\clip(-4.66270591911281,-2.4761462907710943) rectangle (11.894647164540304,7.830725732214009);
|
||||||
|
\draw [->,line width=2pt] (0,0) -- (5,2);
|
||||||
|
\draw [->,line width=2pt] (0,0) -- (1,4);
|
||||||
|
\draw [->,line width=2pt] (0,0) -- (5,2);
|
||||||
|
\draw [->,line width=2pt] (0,0) -- (6,6);
|
||||||
|
\draw [->,line width=2pt] (1,4) -- (6,6);
|
||||||
|
\draw [->,line width=2pt] (5,2) -- (6,6);
|
||||||
|
\begin{scriptsize}
|
||||||
|
\draw [fill=uuuuuu] (0,0) circle (2pt);
|
||||||
|
\draw[color=uuuuuu] (0.08937214755944764,0.20492478062845743) node {$A$};
|
||||||
|
\draw [fill=ududff] (5,2) circle (2.5pt);
|
||||||
|
\draw[color=ududff] (5.08761642038815,2.22776882252273) node {$B$};
|
||||||
|
\draw[color=black] (2.5189255735382816,1.1681838481971587) node {$u$};
|
||||||
|
\draw [fill=ududff] (1,4) circle (2.5pt);
|
||||||
|
\draw[color=ududff] (1.0847398507137718,4.22920710735992) node {$C$};
|
||||||
|
\draw[color=black] (0.49608153164401014,2.142145794294401) node {$v$};
|
||||||
|
\draw [fill=ududff] (5,2) circle (2.5pt);
|
||||||
|
\draw[color=ududff] (5.119725055973774,2.2598774581083534) node {$B_1$};
|
||||||
|
\draw[color=black] (2.551034209123905,1.2002924837827822) node {$u_1$};
|
||||||
|
\draw[color=black] (3.000555107322632,3.158919254505808) node {$w$};
|
||||||
|
\draw [fill=xdxdff] (6,6) circle (2.5pt);
|
||||||
|
\draw[color=xdxdff] (6.082984123542475,6.23064539219711) node {$D$};
|
||||||
|
\draw[color=black] (3.524996155221147,5.171060417871539) node {$a$};
|
||||||
|
\draw[color=black] (5.494325804472712,4.143584079131591) node {$b$};
|
||||||
|
\end{scriptsize}
|
||||||
|
\end{axis}
|
||||||
|
\end{tikzpicture}
|
||||||
|
\end{document}
|
||||||
38
Vektor_add_2.tex
Normal file
38
Vektor_add_2.tex
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
\documentclass[10pt]{article}
|
||||||
|
\usepackage{pgf,tikz,pgfplots}
|
||||||
|
\pgfplotsset{compat=1.15}
|
||||||
|
\usepackage{mathrsfs}
|
||||||
|
\usetikzlibrary{arrows}
|
||||||
|
\pagestyle{empty}
|
||||||
|
\begin{document}
|
||||||
|
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
|
||||||
|
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
|
||||||
|
\begin{axis}[
|
||||||
|
x=1cm,y=1cm,
|
||||||
|
axis lines=middle,
|
||||||
|
ymajorgrids=true,
|
||||||
|
xmajorgrids=true,
|
||||||
|
xmin=-3.5301370701590713,
|
||||||
|
xmax=7.701311755516924,
|
||||||
|
ymin=-3.410207869386736,
|
||||||
|
ymax=6.144461052102637,
|
||||||
|
xtick={-3.5,-3,...,7.5},
|
||||||
|
ytick={-3,-2.5,...,6},]
|
||||||
|
\clip(-3.5301370701590713,-3.410207869386736) rectangle (7.701311755516924,6.144461052102637);
|
||||||
|
\draw [->,line width=2pt] (0,0) -- (7,2);
|
||||||
|
\draw [->,line width=2pt] (0,0) -- (-3,2);
|
||||||
|
\draw [->,line width=2pt] (0,0) -- (4,4);
|
||||||
|
\draw [->,line width=2pt] (-3,2) -- (4,4);
|
||||||
|
\draw [->,line width=2pt] (7,2) -- (4,4);
|
||||||
|
\begin{scriptsize}
|
||||||
|
\draw [fill=uuuuuu] (0,0) circle (2pt);
|
||||||
|
\draw[color=uuuuuu] (0.08138887731978244,0.19635719080161987) node {$A$};
|
||||||
|
\draw[color=black] (3.5242446569218764,1.1587693251572473) node {$u$};
|
||||||
|
\draw[color=black] (-1.4862515064759836,1.0793951285093604) node {$v$};
|
||||||
|
\draw[color=black] (2.0062131460310395,2.150946783255832) node {$w$};
|
||||||
|
\draw[color=black] (0.5278687334641462,3.162967790516389) node {$a$};
|
||||||
|
\draw[color=black] (5.5085995731190485,3.083593593868502) node {$b$};
|
||||||
|
\end{scriptsize}
|
||||||
|
\end{axis}
|
||||||
|
\end{tikzpicture}
|
||||||
|
\end{document}
|
||||||
33
vector.py
33
vector.py
@@ -24,15 +24,15 @@ class Vector(object):
|
|||||||
def __eq__(self, v):
|
def __eq__(self, v):
|
||||||
return self.coordinates == v.coordinates
|
return self.coordinates == v.coordinates
|
||||||
|
|
||||||
#def plus(self,v):
|
|
||||||
# new_coordinates = [x+y for x,y in zip(self.coordinates, v.coordinates)]
|
|
||||||
# return Vector(new_coordinates)
|
|
||||||
|
|
||||||
def plus(self,v):
|
def plus(self,v):
|
||||||
new_coordinates =[]
|
new_coordinates = [x+y for x,y in zip(self.coordinates, v.coordinates)]
|
||||||
n = len(self.coordinates)
|
return Vector(new_coordinates)
|
||||||
for i in range(n):
|
|
||||||
new_coordinates.append(self.coordinates[i] + v.coordinates[i])
|
#def plus(self,v):
|
||||||
|
# new_coordinates =[]
|
||||||
|
# n = len(self.coordinates)
|
||||||
|
# for i in range(n):
|
||||||
|
# new_coordinates.append(self.coordinates[i] + v.coordinates[i])
|
||||||
|
|
||||||
def minus(self,v):
|
def minus(self,v):
|
||||||
new_coordinates = [x-y for x,y in zip(self.coordinates, v.coordinates)]
|
new_coordinates = [x-y for x,y in zip(self.coordinates, v.coordinates)]
|
||||||
@@ -57,22 +57,11 @@ class Vector(object):
|
|||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
vektor_1 = Vector([1,2,3])
|
|
||||||
print (vektor_1)
|
|
||||||
|
|
||||||
vektor_2 = Vector([1,2,3])
|
veka1 = Vector([0,5])
|
||||||
vektor_3 = Vector([-1,2,3])
|
veka2 = Vector([2,2])
|
||||||
|
|
||||||
print (vektor_1 == vektor_2)
|
print (veka1.plus(veka2))
|
||||||
print (vektor_2 == vektor_3)
|
|
||||||
|
|
||||||
print (vektor_1.plus(vektor_2))
|
|
||||||
|
|
||||||
print (vektor_2.minus(vektor_3))
|
|
||||||
|
|
||||||
print (vektor_3.times_scalar(3))
|
|
||||||
|
|
||||||
print ("Magnitude -- L<>nge ", vektor_3.magnitude())
|
|
||||||
|
|
||||||
print ("Normalisieren ", vektor_2.normalized())
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user