def plot(self, res = 1001):
     """
     Plots the linear interpolation of the coordinate 
     lists provided. Resolution is optional and defaults
     to 1001.
     """
     LP.graph(self.xp, self.yp, resolution = res)
 def plot(self, res=1001):
     """
     Plots the linear interpolation of the coordinate 
     lists provided. Resolution is optional and defaults
     to 1001.
     """
     LP.graph(self.xp, self.yp, resolution=res)
Beispiel #3
0
import Lagrange_poly2 as lp
import numpy as np
import matplotlib.pyplot as plt

nlist=(2,4,6,10)
plt.figure()
for n in nlist:
    lp.graph(np.abs, n, -2, 2, resolution=1001)
    plt.legend(["n=%d" %n for n in nlist ])
 #plt.savefig("filename.pdf")  if I wanted to save the figure
 
plt.figure()
nlist=(13,20)
for n in nlist:
    lp.graph(np.abs, n, -2, 2, resolution=1001)
    plt.legend(["n=%d" %n for n in nlist ])
plt.show() 
#!/usr/bin/python
"""
File: Lagrange_poly2b.py

Copyright (c) 2016 Michael Seaman

License: MIT

Implements the past Lagrange poly modules and tests them out with
f(x) = abs(x)
"""

import Lagrange_poly2 as poly2
import math

poly2.graph(math.fabs, 2, -2, 2)
poly2.graph(math.fabs, 4, -2, 2)
poly2.graph(math.fabs, 6, -2, 2)
poly2.graph(math.fabs, 10, -2, 2)

poly2.graph(math.fabs, 13, -2, 2)
poly2.graph(math.fabs, 20, -2, 2)
Beispiel #5
0
def problem_5_25():
    L2.graph(absolute, 2, -2, 2, [-3, 3, 0, 1])
    L2.graph(absolute, 4, -2, 2, [-3, 3, 0, 1])
    L2.graph(absolute, 6, -2, 2, [-3, 3, 0, 1])
    L2.graph(absolute, 10, -2, 2, [-3, 3, 0, 1])
    L2.graph(absolute, 13, -2, 2, [-3, 3, 0, 1])
    L2.graph(absolute, 20, -2, 2, [-3, 3, 0, 1])
 def plot(self):
     LP2.graph(np.sin, 5, 0, np.pi)
Beispiel #7
0
"""
Exercise 5.25: Investigate the behaviour of Langrange's interpolating polynomials
Author: Weiyun Lu
"""

import Lagrange_poly2
from scitools.std import hold, figure

figure()
for n in [2,4,6,10]:
    Lagrange_poly2.graph(abs, n, -2, 2)
    hold('on')   
hold('off')

figure()
for n in [13,20]:
    Lagrange_poly2.graph(abs, n, -2, 2)
    hold('on')
hold('off')
def problem_5_25():
    L2.graph(absolute, 2, -2, 2, [-3,3,0,1])
    L2.graph(absolute, 4, -2, 2, [-3,3,0,1])
    L2.graph(absolute, 6, -2, 2, [-3,3,0,1])
    L2.graph(absolute, 10, -2, 2, [-3,3,0,1])
    L2.graph(absolute, 13, -2, 2, [-3,3,0,1])
    L2.graph(absolute, 20, -2, 2, [-3,3,0,1])