Stand 25.11.
commit
561ecc77e2
|
@ -0,0 +1,35 @@
|
|||
# Python initialisieren:
|
||||
import numpy as np;
|
||||
# Parameter:
|
||||
A=np.array([...,...]); # definieren der Vektoren als Array(2D!)
|
||||
B=np.array([...,...]);
|
||||
C=np.array([...,...]);
|
||||
pr=3;
|
||||
# Funktionen:
|
||||
def Laenge(v): l=np.sqrt(np.dot(v,v)); return l;
|
||||
def Winkel(v,w): phi=np.arccos(np.dot(v,w)/(Laenge(v)*Laenge(w))); return phi;
|
||||
# Seitenvektoren:
|
||||
a=C-B;
|
||||
b=A-C;
|
||||
c=B-A;
|
||||
# Seitenlaengen:
|
||||
l_a=Laenge(a);
|
||||
l_b=Laenge(b);
|
||||
l_c=Laenge(c);
|
||||
# Innenwinkel:
|
||||
w_a=Winkel(-b,c);
|
||||
w_b=Winkel(-c,a);
|
||||
w_c=Winkel(-a,b);
|
||||
# Ausgabe:
|
||||
print('--------------------------------------------------');
|
||||
print(__file__);
|
||||
print('--------------------------------------------------');
|
||||
print('Seiten:');
|
||||
print(f"a = {l_a:#.{pr}g}");
|
||||
print(f"b = {l_b:#.{pr}g}");
|
||||
print(f"c = {l_c:#.{pr}g}");
|
||||
print('Innenwinkel:');
|
||||
print(f"alpha = {w_a/np.pi:#.{pr}g} pi");
|
||||
print(f"beta = {w_b/np.pi:#.{pr}g} pi");
|
||||
print(f"gamma = {w_c/np.pi:#.{pr}g} pi");
|
||||
print('--------------------------------------------------');
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Tue Nov 5 16:58:41 2024
|
||||
|
||||
@author: Carla
|
||||
|
||||
Lineare Algebra
|
||||
|
||||
Übung 03 Gauss
|
||||
"""
|
||||
#Python initialisieren
|
||||
import numpy as np;
|
||||
#Parameter
|
||||
A=np.array([...]);
|
||||
b=np.array([...]);
|
||||
pr_L=...; pr_C=...;
|
||||
#Berechnungen:
|
||||
L=np.linalg.solve(A,b);
|
||||
C=np.linalg.cond(A);
|
||||
#Ausgabe
|
||||
print(f"L= {np.array2string(L,precision=pr_L)}");
|
||||
print(f"C= {C:#.{pr_C}g}");
|
|
@ -0,0 +1,27 @@
|
|||
# Python initialisieren:
|
||||
import numpy as np; # in numpy mit einem array/bei sympy eine Matrix(siehe unten auskommentiert)
|
||||
# Parameter:
|
||||
u=np.array([2,-1]); # Vektor u als array eingeben
|
||||
v=np.array([-3,3]); # (beliebig viele Vektoren können definiert werden)
|
||||
w=np.array([1,1/2]);
|
||||
# Berechnungen:
|
||||
r=u+v; # Termaufstellen
|
||||
# Ausgabe:
|
||||
print(f"r = {r}"); # Ergebnisvektor R im Terminal ausgeben
|
||||
|
||||
|
||||
|
||||
|
||||
#Vektorrechnung mit Sympy
|
||||
'''
|
||||
#Python initialisieren:
|
||||
import IPython.display as dp;
|
||||
import sympy as sp;
|
||||
# Parameter:
|
||||
u=sp.Matrix([[2],[-1]]); # Vektor als Matrix definieren
|
||||
v=sp.Matrix([[-3],[3]]);
|
||||
w=sp.Matrix([[1],[1/2]]);
|
||||
Berechnungen: r=...; # Term zu Berechnung aufstellen
|
||||
# Ausgabe:
|
||||
dp.display(r); # Ergebnisvektor r im Terminal ausgeben
|
||||
'''
|
|
@ -0,0 +1,31 @@
|
|||
# AUEM Kommentare by Carla
|
||||
# 2024-10-10
|
||||
# Begin
|
||||
# --------------------------------------------------------------------------------------
|
||||
# Python initialisieren:
|
||||
import numpy as np;
|
||||
# Python konfigurieren:
|
||||
np.set_printoptions(linewidth=np.nan);
|
||||
# Rahmen
|
||||
print('--------------------------------------------------------------------------------------');
|
||||
print(__file__);
|
||||
print('--------------------------------------------------------------------------------------');
|
||||
# Parameter:
|
||||
n=2; pr=7;
|
||||
# Berechnungen:
|
||||
k_data=np.linspace(1,n,n);
|
||||
[i_data,j_data]=np.meshgrid(k_data,k_data);
|
||||
A=1/(i_data+j_data-1);
|
||||
s=np.sum(A,axis=1)[np.newaxis];
|
||||
b=s.T;
|
||||
G=np.block([A,b]);
|
||||
L=np.linalg.solve(A,b);
|
||||
C=np.linalg.cond(A);
|
||||
# Ausgabe:
|
||||
print(f"G =\n{np.array2string(G,precision=pr)}\n");
|
||||
print(f"L =\n{np.array2string(L.T,precision=pr)}\n");
|
||||
print(f"C = {C:#.2g}");
|
||||
print('--------------------------------------------------------------------------------------');
|
||||
#
|
||||
# --------------------------------------------------------------------------------------
|
||||
# End
|
|
@ -0,0 +1,13 @@
|
|||
# Python initialisieren:
|
||||
import IPython.display as dp;
|
||||
import sympy as sp;
|
||||
# Python konfigurieren:
|
||||
sp.init_printing();
|
||||
m,N,phi,x=sp.symbols('m,N,varphi,x'); # definieren der Maßeinheiten(in dem Fall Meter, Newton)
|
||||
# Parameter:
|
||||
v=sp.Matrix([[3.0*m],[3.2*m],[7.2*m]]); # definieren des Vektors v als Matrix(Masseinheit wird zur Zahl multipliziert)
|
||||
w=sp.Matrix([[3*N],[4*N],[-5*N]]);
|
||||
# Berechnungen:
|
||||
p=sp.simplify(v.dot(w)); # Auersche Magie macht sein Ding (sympy kann das einfach von natur aus)
|
||||
# Ausgabe:
|
||||
dp.display(p); # Ausgabe des Skalarproduktes
|
Loading…
Reference in New Issue