1. # Call the taylor series function
2. val = taylor([5, 10, 7],0.2)
3.
4. def taylor(f, h)
5.
6. """
7. f(x) = f(x0) + f'(x0)h + f''(x0)*h^2/2! + ..... + f^(n)(x0) h^n / n!
8. Inputs:
9. f: A list such that f = [f(x0), f'(x0), f''(x0), ...]
10. h: Step size such that h = x - x0
11.
12. Output:
13. """
14. value: scalar value for f(x) following the Taylor series.
15.
16. # Initialize value
17. value = 0
18.
19. # Loop over how many terms we need
20. # Add each term to value using value = value + ...
21. # Will probably need math.factorial().
22. # Import math at the top of the code using import math
23. for i in len(f):
24. value = f[i] * (h**i) / math.factorial[i]
25.
26. # Output final value
27. return value