continued with task 4

This commit is contained in:
leobr 2022-10-20 15:50:45 +02:00
parent d1e1daca18
commit 5912373856
1 changed files with 26 additions and 7 deletions

View File

@ -2,27 +2,46 @@ import numpy as np
import matplotlib.pyplot as plt
import math
def h1(x):
return math.sqrt(100 * math.pow(x,2) - 200 * x + 99)
try:
return math.sqrt(100 * math.pow(x, 2) - 200 * x + 99)
except:
return
def h1_diff(x):
return (100 * x - 100) / math.sqrt(100 * math.pow(x, 2) - 200 * x + 99)
def h2(x):
return math.sqrt((10 * x - 9) * (10 * x - 11))
xStep = math.pow(10,-7)
xStart = 1.1 + xStep
def kondnumb(x):
return (np.abs(h1_diff(x)) * np.abs(x)) / np.abs(h1(x))
xStep = math.pow(10, -7)
xStart = 1.1
xStop = 1.31
x = np.arange(xStart,xStop + xStep,xStep)
x = np.arange(xStart, xStop + xStep, xStep)
y1 = [h1(x_val) for x_val in x]
y2 = [h2(x_val) for x_val in x]
y3 = [kondnumb(x_val) for x_val in x]
plt.yscale('log', base=10)
plt.plot(x, y3, label='Konditionszahl')
plt.title('4.b)')
plt.legend()
plt.figure()
plt.plot(x, y1, label='h1(x)')
plt.plot(x, y2, label='h2(x)')
plt.yscale('log', base=10)
plt.xlim(1.099, 1.101)
plt.legend()
plt.show()