In [1]:
import fit_pendulum_data as p1
import midpoint_vec as p2
import Lagrange_poly1 as p3
import Lagrange_poly2 as p4
import Lagrange_poly2b as p5
import sympy as sp
import numpy as np
import matplotlib.pyplot as plt

Exercise 5.18

Plots L vs T from a source file and fits polynomials of varying degrees to it


In [2]:
p1.part_a()


Out[2]:
([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0],
 [0.6, 0.9, 1.1, 1.3, 1.4, 1.6, 1.7, 1.8, 1.9, 2.0])

Below are the polynomials being fit to the data


In [3]:
p1.part_b()


Exercise 5.22

Computes the midpoint rule in different forms


In [4]:
p2.midpointint(p2.function, 1, 3, 50)[0]


Out[4]:
12.231183999999999

In [5]:
p2.sum_vectorized(p2.function, 1, 3, 50)


Out[5]:
12.231183999999999

In [6]:
p2.sum_numpy(p2.function, 1, 3, 50)


Out[6]:
12.231183999999999

Exercise 5.23, 5.24, 5.25 (3 part)

Lagrange Interpolation


In [7]:
p4.graph(p4.sin, 20, 0, 10, [0,10,-2,2])



In [8]:
p5.problem_5_25()



In [ ]: