Compare commits
No commits in common. "main" and "serie_2" have entirely different histories.
@ -1,4 +1,2 @@
|
|||||||
numpy==2.4.3
|
numpy
|
||||||
matplotlib==3.10.8
|
matplotlib
|
||||||
ipykernel==7.2.0
|
|
||||||
scipy==1.17.1
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
# %%
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
R = 1.0 * np.array(
|
|
||||||
[
|
|
||||||
[2, 3, 1],
|
|
||||||
[1, -2, -1],
|
|
||||||
[4, 1, -3],
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
L = 1.0 * np.array([8, 3, 6])
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
#%%
|
|
||||||
# Python initialisieren
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
# Parameter
|
|
||||||
G=1.*np.array([
|
|
||||||
[2,3,1,8],
|
|
||||||
[1,-2,-1,-3],
|
|
||||||
[4,1,-3,6]])
|
|
||||||
|
|
||||||
# Berechnung
|
|
||||||
m = np.max(G.shape)
|
|
||||||
n = np.linalg.norm(G)
|
|
||||||
e = np.finfo(np.float64).eps
|
|
||||||
tol = m * n * e
|
|
||||||
|
|
||||||
print(m)
|
|
||||||
print(n)
|
|
||||||
print(e)
|
|
||||||
print(tol)
|
|
||||||
# %%
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
# %%
|
|
||||||
# Python initialisieren
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import numpy as np
|
|
||||||
import scipy.integrate as ig
|
|
||||||
|
|
||||||
# Parameter
|
|
||||||
x_0 = 0.0
|
|
||||||
x_E = np.pi
|
|
||||||
N = 11
|
|
||||||
n = 5
|
|
||||||
pr = 6
|
|
||||||
lw = 3
|
|
||||||
fig = 1
|
|
||||||
|
|
||||||
# Funktion
|
|
||||||
f = lambda x: np.sin(x)
|
|
||||||
|
|
||||||
# Berechnungen
|
|
||||||
for k in range(0, n):
|
|
||||||
x_data = np.linspace(x_0, x_E, N)
|
|
||||||
y_data = f(x_data)
|
|
||||||
I = ig.trapezoid(y=y_data, x=x_data)
|
|
||||||
J = ig.simpson(y=y_data, x=x_data)
|
|
||||||
print(f"I = {I:#.16g}")
|
|
||||||
print(f"J = {J:#.16g}")
|
|
||||||
N *= 2
|
|
||||||
|
|
||||||
# Ausgabe
|
|
||||||
print(f"I = {I:#.{pr}g}")
|
|
||||||
print(f"J = {J:#.{pr}g}")
|
|
||||||
|
|
||||||
# Plot
|
|
||||||
fh = plt.figure(fig)
|
|
||||||
plt.plot(x_data, y_data, linewidth=lw)
|
|
||||||
plt.xlabel("x")
|
|
||||||
plt.ylabel("y")
|
|
||||||
plt.grid(visible=True)
|
|
||||||
plt.axis("image")
|
|
||||||
plt.show()
|
|
||||||
# %%
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
# %%
|
|
||||||
import numpy as np
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
|
|
||||||
# %%
|
|
||||||
print(60 * "-")
|
|
||||||
print(__file__)
|
|
||||||
print("Aufgabe 2. Interpolationspolynome gemäss NEWTON-Schema berechnen")
|
|
||||||
# punkte [[x0, x1, x2, xn], [y0, y1, y2, yn]]
|
|
||||||
punkte = [
|
|
||||||
[np.array([4, 8]), np.array([1, -1])],
|
|
||||||
[np.array([-1, 1, 2]), np.array([15, 5, 9])],
|
|
||||||
[np.array([-1, 0, 1, 2]), np.array([-5, -1, -1, 1])],
|
|
||||||
]
|
|
||||||
|
|
||||||
for punkt in punkte:
|
|
||||||
|
|
||||||
# Parameter
|
|
||||||
x_data = punkt[0]
|
|
||||||
y_data = punkt[1]
|
|
||||||
x_0 = x_data[0]
|
|
||||||
x_E = x_data[-1]
|
|
||||||
N = 201
|
|
||||||
lw = 3
|
|
||||||
fig = 1
|
|
||||||
|
|
||||||
# Berechnung
|
|
||||||
n = np.size(y_data)
|
|
||||||
TAB = np.block([[y_data], [np.zeros((n - 1, n))]])
|
|
||||||
c_data = np.zeros(n)
|
|
||||||
c_data[0] = y_data[0]
|
|
||||||
|
|
||||||
for i in range(1, n):
|
|
||||||
for j in range(1, n):
|
|
||||||
TAB[i][j] = (TAB[i - 1][j] - TAB[i - 1][j - 1]) / (
|
|
||||||
x_data[j] - x_data[j - i]
|
|
||||||
)
|
|
||||||
c_data[i] = TAB[i][i]
|
|
||||||
|
|
||||||
# Funktionen:
|
|
||||||
def p(x):
|
|
||||||
d = 1
|
|
||||||
y = c_data[0]
|
|
||||||
for k in range(1, n):
|
|
||||||
d = d * (x - x_data[k - 1])
|
|
||||||
y = y + c_data[k] * d
|
|
||||||
return y
|
|
||||||
|
|
||||||
# Daten
|
|
||||||
u_data = np.linspace(x_0, x_E, N)
|
|
||||||
v_data = p(u_data)
|
|
||||||
|
|
||||||
fh = plt.figure(fig)
|
|
||||||
plt.plot(u_data, v_data, linewidth=lw)
|
|
||||||
plt.plot(x_data, y_data, "o", linewidth=lw)
|
|
||||||
plt.xlabel(r"$x$")
|
|
||||||
plt.ylabel(r"$y$")
|
|
||||||
plt.grid(visible=True)
|
|
||||||
plt.axis("image")
|
|
||||||
|
|
||||||
print(60 * "-")
|
|
||||||
Loading…
x
Reference in New Issue
Block a user