2022-10-20 14:27:15 +02:00
|
|
|
import numpy as np
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import math
|
|
|
|
|
2022-10-20 15:21:02 +02:00
|
|
|
def h1(x):
|
2022-10-20 14:44:10 +02:00
|
|
|
return math.sqrt(100 * math.pow(x,2) - 200 * x + 99)
|
2022-10-20 14:55:43 +02:00
|
|
|
|
2022-10-20 15:30:45 +02:00
|
|
|
def h1_diff(x):
|
|
|
|
return (200 * math.pow(x, 2) - 300 * x + 99)/(math.sqrt(100 * math.pow(x, 2) - 200 * x + 99))
|
|
|
|
|
2022-10-20 15:21:02 +02:00
|
|
|
def h2(x):
|
|
|
|
return math.sqrt((10 * x - 9) * (10 * x - 11))
|
|
|
|
|
2022-10-20 14:44:10 +02:00
|
|
|
xStep = math.pow(10,-7)
|
2022-10-20 14:55:43 +02:00
|
|
|
xStart = 1.1 + xStep
|
|
|
|
xStop = 1.31
|
|
|
|
|
2022-10-20 14:44:10 +02:00
|
|
|
|
|
|
|
x = np.arange(xStart,xStop + xStep,xStep)
|
2022-10-20 15:21:02 +02:00
|
|
|
y1 = [h1(x_val) for x_val in x]
|
|
|
|
y2 = [h2(x_val) for x_val in x]
|
2022-10-20 14:44:10 +02:00
|
|
|
|
2022-10-20 15:21:02 +02:00
|
|
|
plt.plot(x, y1, label='h1(x)')
|
|
|
|
plt.plot(x, y2, label='h2(x)')
|
2022-10-20 15:30:45 +02:00
|
|
|
plt.yscale('log', base=10)
|
2022-10-20 14:55:43 +02:00
|
|
|
plt.legend()
|
2022-10-20 14:44:10 +02:00
|
|
|
plt.show()
|
2022-10-20 15:21:02 +02:00
|
|
|
|
|
|
|
# Aufgabe 4a)
|
|
|
|
# Da die Operation nicht gut konditioniert ist, erhält man für den Ausdruck inder Wurzel
|
2022-10-20 15:30:45 +02:00
|
|
|
# bei x = 1.1, -1.4e-14 => ein kleiner Rundungsfehler
|
2022-10-20 15:21:02 +02:00
|
|
|
# Somit kann die Wurzel für diesen x Werte nicht berechnet werden.
|