
# Taylor2.py
# langtangen, B.4, Taylor series, p. 701
# input: 0.2 or 3

import math

h = float(input("h? "))

# successive Taylor series approximations for e^h
ts = []
ts.append(1)
ts.append(ts[-1] + h)
ts.append(ts[-1] + (1/2.0)*h**2)
ts.append(ts[-1] + (1/6.0)*h**3)
ts.append(ts[-1] + (1/24.0)*h**4)

for order in range(len(ts)):
  print(f"order={order}, error={(math.exp(h) - ts[order]):.8f}")
