feat: introduction/serie_1.py advanced. docs: README altered. feat: requirements.txt added
This commit is contained in:
parent
b6de785eb5
commit
88f29d1f52
@ -1,4 +1 @@
|
||||
Repository for CDS-404 Numerische Methoden
|
||||
|
||||
Required libraries:
|
||||
* numpy
|
||||
Repository for CDS-404 Numerische Methoden
|
||||
@ -1,5 +1,8 @@
|
||||
|
||||
#%%
|
||||
# Numpy initialisieren
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
#%%
|
||||
print("Aufgabe 2")
|
||||
print(f"a) {1/3}")
|
||||
@ -25,5 +28,81 @@ print(f"k) {1 / np.arctan(34.1)}")
|
||||
print(f"l) {np.power(np.array([np.e]), -3.34)}")
|
||||
print(f"m) {np.e}")
|
||||
print(f"n) {np.log(13.2)}")
|
||||
print(f"o) ")
|
||||
print(f"p) ")
|
||||
print(f"o) {np.log10(23)}")
|
||||
print(f"p) {np.log2(69.6)}")
|
||||
|
||||
# %%
|
||||
print("Aufgabe 7")
|
||||
# Parameter
|
||||
a = 12.3, b = 8.14, pr = 3, ME = "cm"
|
||||
|
||||
# Berechnungen
|
||||
c = np.sqrt(a**2+b**2)
|
||||
|
||||
# Ausgabe
|
||||
print("----------------------------------------------------------------------")
|
||||
print(__file__)
|
||||
print("----------------------------------------------------------------------")
|
||||
print(f"Seite a = {a:#.{pr}g} {ME}")
|
||||
print(f"Seite b = {b:#.{pr}g} {ME}")
|
||||
print(f"Seite c = {c:#.{pr}g} {ME}")
|
||||
print("----------------------------------------------------------------------")
|
||||
|
||||
# %%
|
||||
print("Aufgabe 7.d)")
|
||||
# Parameter
|
||||
a = 0.85e3; pr_a = 2; sc_a = 1.0e-3; ME_a = "km";\
|
||||
b = 234; pr_b = 3; sc_b = 1.0; ME_b = "m";\
|
||||
pr_c = 2; sc_c = 1.0e-3; ME_c = "km";\
|
||||
|
||||
# Berechnungen
|
||||
c = np.sqrt(a**2+b**2)
|
||||
|
||||
# Ausgabe
|
||||
print("----------------------------------------------------------------------")
|
||||
print(__file__)
|
||||
print("----------------------------------------------------------------------")
|
||||
print(f"Seite a = {a*sc_a:#.{pr_a}g} {ME_a}")
|
||||
print(f"Seite b = {b*sc_b:#.{pr_b}g} {ME_b}")
|
||||
print(f"Seite c = {c*sc_c:#.{pr_c}g} {ME_c}")
|
||||
print("----------------------------------------------------------------------")
|
||||
|
||||
# %%
|
||||
print("Aufgabe 8")
|
||||
# Python konfigurieren
|
||||
plt.close("all")
|
||||
plt.rcParams["figure.figsize"] = (7.03,15)
|
||||
plt.rcParams["font.size"] = 9
|
||||
plt.rcParams["font.family"] = "serif"
|
||||
plt.rcParams["text.usetex"] = False
|
||||
|
||||
# Parameter
|
||||
x_0 = 0
|
||||
x_E = 4
|
||||
N = 201
|
||||
lw = 3
|
||||
fig = 1
|
||||
|
||||
# Funktionen
|
||||
def f(x):
|
||||
y = 3/(1+x)
|
||||
return y
|
||||
|
||||
def g(x):
|
||||
y = x/2
|
||||
return y
|
||||
|
||||
# Daten
|
||||
x_data = np.linspace(x_0, x_E, N)
|
||||
f_data = f(x_data)
|
||||
g_data = g(x_data)
|
||||
|
||||
# pltot
|
||||
fh = plt.figure(fig)
|
||||
plt.plot(x_data, f_data, linewidth = lw, label = r"$f$")
|
||||
plt.plot(x_data, g_data, "--", linewidth = lw, label = r"$g$")
|
||||
plt.xlabel(r"$x$")
|
||||
plt.ylabel(r"$y$")
|
||||
plt.legend()
|
||||
plt.grid(visible=True)
|
||||
plt.axis("image")
|
||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
numpy
|
||||
matplotlib
|
||||
Loading…
x
Reference in New Issue
Block a user