Simpson-Regel. Trapez Regel Beschreibung hinzugefügt

This commit is contained in:
Sandro Zimmermann 2026-06-02 21:25:50 +02:00
parent dfc9ba19dc
commit fbd6476bad
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,45 @@
"""
Simpson-Regel
Integration der funktion:
2
I = | (x + sin(x))^(2/3)) dx
0
"""
import numpy as np
import scipy.integrate as ig
# Parameter
x_0 = 0
x_E = 2
n = 10
N = 201
pr = 6
f = lambda x: np.sqrt(x + np.sin(x))
# Berechnung
for k in range(0, n):
x_data = np.linspace(x_0, x_E, N)
y_data = f(x_data)
I = ig.simpson(y=y_data, x=x_data)
print(f"I = {I:#.16g} | N = {N:g}")
N *= 2
print(f"I = {I:#.{pr}g}")
"""
Ausgabe:
I = 2.490070783046884 | N = 201
I = 2.490260152603558 | N = 402
I = 2.490326897146905 | N = 804
I = 2.490350466364332 | N = 1608
I = 2.490358796310514 | N = 3216
I = 2.490361741357393 | N = 6432
I = 2.490362782708113 | N = 12864
I = 2.490363150933651 | N = 25728
I = 2.490363281138151 | N = 51456
I = 2.490363327177379 | N = 102912
I = 2.49036
"""

View File

@ -1,4 +1,6 @@
"""
Trapez-Regel
Integration der funktion:
2
I = | (x + sin(x))^(2/3)) dx