ZHAWNotes/Notes/Semester 4/HM2 - Höhere Mathematik 2/Week 5/Miguel_S5_Aufg3.py

31 lines
710 B
Python
Raw Normal View History

2023-03-29 05:15:02 +00:00
# %%
from Miguel_S5_Aufg2 import Miguel_S5_Aufg2
from matplotlib import pyplot
from numpy import array, polyfit, polyval
from scipy import interpolate
x = array([1900, 1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 19100, 19110])
y = array([75.995, 91.972, 105.711, 123.203, 131.669, 150.697, 179.323, 203.212, 226.505, 249.633, 281.422, 308.745])
xx = array([17, 25, 41, 56, 72, 98, 100, 108])
# a)
pyplot.figure()
Miguel_S5_Aufg2(x, y, xx)
# b)
pyplot.figure()
pyplot.scatter(xx, interpolate.CubicSpline(x, y)(xx))
# c) 1
pyplot.figure()
pyplot.scatter(xx, polyval(polyfit(x, y, deg = 11), xx))
# c) 2
x[:] -= 1900
pyplot.figure()
pyplot.scatter(xx, polyval(polyfit(x, y, deg = 11), xx))
# %%