33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
|
import numpy as np
|
||
|
from Schenk_Brandenberger_S9_Aufg2 import *
|
||
|
import matplotlib.pyplot as plt
|
||
|
|
||
|
all_dxmax = np.array([])
|
||
|
all_dxobs = np.array([])
|
||
|
dxmax_dxobs_ratio = np.array([])
|
||
|
index = np.arange(0,1000,1)
|
||
|
|
||
|
for i in range(1000):
|
||
|
A = np.random.rand(100,100)
|
||
|
b = np.random.rand(100,1)
|
||
|
A_approx = A + np.random.rand(100,100)/1e5
|
||
|
b_approx = b + np.random.rand(100,1)/1e5
|
||
|
[x, x_approx, dxmax, dxobs] = Schenk_Brandenberger_S9_Aufg2(A, A_approx, b, b_approx)
|
||
|
all_dxmax = np.append(all_dxmax, [dxmax], axis=0)
|
||
|
all_dxobs = np.append(all_dxobs, [dxobs], axis=0)
|
||
|
dxmax_dxobs_ratio = np.append(dxmax_dxobs_ratio, [dxmax/dxobs], axis=0)
|
||
|
|
||
|
|
||
|
plt.figure(1)
|
||
|
plt.semilogy(all_dxmax)
|
||
|
plt.semilogy(all_dxobs)
|
||
|
plt.semilogy(dxmax_dxobs_ratio)
|
||
|
plt.legend(["dxmax", "dxob", "dxmax/dxobs"])
|
||
|
plt.grid()
|
||
|
plt.xlabel("x")
|
||
|
plt.ylabel("f(x)")
|
||
|
plt.title("Aufgabe 3 Serie 9")
|
||
|
plt.show()
|
||
|
|
||
|
#Die obere Schranke dxmax liegt immer dxobs, deshalb ist sie sicher realistisch und korrekt
|
||
|
#Jedoch liegt die obere Schranke immer etwa den Faktor 1e3 über dxobs
|