Reader small image

You're reading from  Mastering SciPy

Product typeBook
Published inNov 2015
Reading LevelIntermediate
Publisher
ISBN-139781783984749
Edition1st Edition
Languages
Right arrow
Authors (2):
Francisco Javier Blanco-Silva
Francisco Javier Blanco-Silva
author image
Francisco Javier Blanco-Silva

I will always be indebted to Bradley J. Lucier and Rodrigo Bañuelos, for being a constant inspiration, for their guidance and teachings. Special thanks to my editors, Sriram Neelakantam, Bharat Patil, Nikhil Potdukhe, and Mohammad Rizvi. Many colleagues have contributed with encouragement and fruitful discussions. In particular, I would like to mention Parsa Bakhtary, Aaron Dutle, Edsel Peña, Pablo Sprechmann, Adam Taylor, and Holly Watson. But the most special thanks go without a doubt to my wife and daughter. Grace's love and smiles alone provided all the motivation, enthusiasm and skills to overcome any difficulties encountered during the pursuit of this book, and everything life threw at me ever since she was born.
Read more about Francisco Javier Blanco-Silva

View More author details
Right arrow

Motivation


Let's revisit Runge's example from Chapter 2, Interpolation and Approximation, where we computed a Lagrange interpolation of Runge's function using eleven equally spaced nodes in the interval from -5 to 5:

In [1]: import numpy as np, matplotlib.pyplot as plt; \
   ...: from scipy.interpolate import BarycentricInterpolator
In [2]: def f(t): return 1. / (1. + t**2)
In [3]: nodes = np.linspace(-5, 5, 11); \
   ...: domain = np.linspace(-5, 5, 128); \
   ...: interpolant = BarycentricInterpolator(nodes, f(nodes))
In [4]: plt.figure(); \
   ...: plt.subplot(121); \
   ...: plt.plot(domain, f(domain), 'r-', label='original'); \
   ...: plt.plot(nodes, f(nodes), 'ro', label='nodes'); \
   ...: plt.plot(domain, interpolant1(domain), 'b--',
   ...:          label='interpolant'); \
   ...: plt.legend(loc=9); \
   ...: plt.subplot(122); \
   ...: plt.plot(domain, np.abs(f(domain)-interpolant1(domain))); \
   ...: plt.title('error or interpolation'); \
   ...: plt.show()

One way to measure...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Mastering SciPy
Published in: Nov 2015Publisher: ISBN-13: 9781783984749

Authors (2)

author image
Francisco Javier Blanco-Silva

I will always be indebted to Bradley J. Lucier and Rodrigo Bañuelos, for being a constant inspiration, for their guidance and teachings. Special thanks to my editors, Sriram Neelakantam, Bharat Patil, Nikhil Potdukhe, and Mohammad Rizvi. Many colleagues have contributed with encouragement and fruitful discussions. In particular, I would like to mention Parsa Bakhtary, Aaron Dutle, Edsel Peña, Pablo Sprechmann, Adam Taylor, and Holly Watson. But the most special thanks go without a doubt to my wife and daughter. Grace's love and smiles alone provided all the motivation, enthusiasm and skills to overcome any difficulties encountered during the pursuit of this book, and everything life threw at me ever since she was born.
Read more about Francisco Javier Blanco-Silva