In [10]:
%matplotlib inline
from pylab import *
from Interpolation import *
from ExpoSin import *
import math
# Sample ExpoSin
k1 = 0.9
k2 = 0.14
# Plot actual function for dt differential
exps = ExpoSin(1.0, k1, k2, 0.0)
a, b = -math.pi / 2 / k2, math.pi / 2 / k2
ab = linspace(a, b, 1000)
dt = [1/exps.thetadot(abi, 1.0) for abi in ab]
plot(ab, dt, 'k')
# Plot interpolation of the function
nodes = chebyshev_nodes(5, a, b)
fnodes = [1/exps.thetadot(node, 1.0) for node in nodes]
plot(nodes, fnodes, 'ro')
intp = Interpolator(nodes, fnodes)
intp_dt = [intp.getY(abi) for abi in ab]
plot(ab, intp_dt, 'r')
grid(True)
In [11]:
# Plot the error
plot(ab, [intp_dti - dti for intp_dti, dti in zip(intp_dt, dt)], 'g')
grid(True)
In [12]:
print intp.poly.integrate(a, b)
In [ ]: