Introduction To Cubic Spline Interpolation With Examples In Python Thomas I Maindl pdf download
Introduction To Cubic Spline Interpolation With Examples In Python Thomas I Maindl pdf download
https://ebookbell.com/product/introduction-to-cubic-spline-
interpolation-with-examples-in-python-thomas-i-maindl-43838326
https://ebookbell.com/product/conics-and-cubics-a-concrete-
introduction-to-algebraic-curves-2nd-robert-bix-1084014
https://ebookbell.com/product/introduction-to-modern-analysis-2nd-
edition-2nd-kantorovitz-44870612
https://ebookbell.com/product/introduction-to-the-speechmaking-
process-15th-edition-diana-k-leonard-raymond-s-ross-44874488
Introduction To Construction Management 2nd Edition 2nd Fred Sherratt
https://ebookbell.com/product/introduction-to-construction-
management-2nd-edition-2nd-fred-sherratt-44899008
https://ebookbell.com/product/introduction-to-analysis-with-complex-
numbers-irena-swanson-44912170
https://ebookbell.com/product/introduction-to-quantitative-methods-in-
business-with-applications-using-microsoft-office-excel-1st-edition-
bharat-kolluri-44915766
https://ebookbell.com/product/introduction-to-biostatistical-
applications-in-health-research-with-microsoft-office-excel-and-r-2nd-
edition-robert-p-hirsch-44915830
https://ebookbell.com/product/introduction-to-strategies-for-organic-
synthesis-2nd-edition-laurie-s-starkey-44915846
Introduction to
Cubic Spline Interpolation
with Examples in Python
Thomas I. Maindl
Department of Astrophysics, University of Vienna
Copyright c 2018 Thomas I. Maindl
All rights reserved. This book or any portion thereof may not be reproduced or used in
any manner whatsoever without the express written permission of the copyright holder
except for the use of brief quotations in a book review.
Anaconda R is a registered trademark of Anaconda, Inc., Texas, USA. JupyterTM is a
trademark of NumFOCUS, Texas, USA. Python R is a registered trademark of the Python
Software Foundation (PSF), Oregon, USA. SpaceX R and Falcon R are registered trademarks
of Space Exploration Technologies Corp., California, USA.
In case general descriptive names, registered names, trademarks, etc. are used this does
not imply, even in the absence of a specific statement, that such names are exempt from
applicable protective laws and regulations and are therefore free for general use.
Cover picture: Photo by Bill Jelen on Unsplash
CreateSpace Independent Publishing Platform
4900 LaCross Road
North Charleston, SC 29406
USA
April 2018
ISBN-13 978-1987487374
ISBN-10 1987487370
Contents
Preface 5
3 Spline exercises 43
3.1 Spline check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.1.1 Linear spline . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.1.2 Quadratic spline . . . . . . . . . . . . . . . . . . . . . . . 44
3.2 Constructing cubic splines . . . . . . . . . . . . . . . . . . . . . . 45
3.2.1 Non-periodic spline . . . . . . . . . . . . . . . . . . . . . 45
3.2.2 Periodic spline . . . . . . . . . . . . . . . . . . . . . . . . 52
3
4 The rocket launch project 57
4.1 Preparing the Notebook . . . . . . . . . . . . . . . . . . . . . . . 59
4.2 The data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.3 Define functions for later use . . . . . . . . . . . . . . . . . . . . 60
4.4 Calculate the splines . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.4.1 Generalized natural spline . . . . . . . . . . . . . . . . . . 64
4.4.2 Clamped spline . . . . . . . . . . . . . . . . . . . . . . . . 67
4.4.3 Not-a-knot spline . . . . . . . . . . . . . . . . . . . . . . 69
4.4.4 All spline coefficients . . . . . . . . . . . . . . . . . . . . . 72
4.5 Visualize the results . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.6 Answering the questions . . . . . . . . . . . . . . . . . . . . . . . 76
5 Closing remarks 79
Literature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Index 89
4
Preface
After completing the course students are able to implement cubic spline interpolation
in their own projects – either by writing the code by themselves or by using library
functions.
This book covers both parts of the course, the lecture session and the exercises.
The lecture starts with a slide-based presentation covering the ideas of spline inter-
polation and providing insight into the method how to construct an interpolating
cubic spline using linear algebra. Chapter 1 is the picture-book chapter where the
pages show the full-color slides at the top and lecture notes below.
In Chapt. 2 there are lecture notes covering the math in detail by deriving all
necessary equations for constructing cubic interpolating splines. The notes are called
mini-script because in their second half they provide a cookbook-like prescription
that ‘scripts’ how to construct cubic interpolating splines with different boundary
conditions.
The next two chapters elaborate on exercises very similar to those the students
have to do in the lab session. In Chapt. 3, there are ‘pencil and paper’ exercises
which are aggregated into just a few bigger ones in order to save space. The given
solutions are explained in a largely independent way to minimize cross-references
within the exercise chapter. A more extensive project is given in Chapt. 4 – based
on velocity data after a rocket launch (SpaceX R ’s Falcon R Heavy), interpolating
5
splines help determine the g-force acting on the spacecraft as well as other data that
depends on an analytic function describing the physics. The size of that problem’s
equation system requires programming to solve it. Hence, it’s all in a JupyterTM
Notebook that solves the problem using Python R and also includes a number of
function definitions for re-use.
As this book is intended to be a self-contained course it does not contain references
in the text, but leaves the hints pointing towards literature, further applications, and
programming libraries for the closing remarks in the last Chapt. 5.
The appendix finally, will round off the Python code given in Chapt. 4 by
demonstrating how to construct a periodic interpolating cubic spline, again provided
in a Jupyter Notebook for re-use by the reader.
Thomas I. Maindl
6
Chapter 1
Sk–1
S0 Sn–1
Sk
This chapter introduces the concept of cubic interpolating splines. We start with
discussing the prerequisites for getting the most out of this book and then introduce
polynomial interpolation, which will lead to the splines concept. After having a brief
glance at linear splines we will see what it takes to construct cubic interpolating
splines and lay the foundation for the mini-script in Chapt. 2 which will describe how
to construct splines with different boundary conditions in detail.
7
CHAPTER 1. CUBIC SPLINE INTERPOLATION
Math prerequisites
– some calculus
• concept of continuity of functions
• derivatives of functions (polynomials)
– linear algebra
• matrix representation of systems of linear equations
• solving those systems e.g., Gaussian elimination
Before we dive into the content slides, let’s have a quick look at the course pre-
requisites. This spline course is an intermediate-level applied mathematics course
on interpolation. It targets undergraduate students of the science and engineering
disciplines and requires some basic knowledge in math and also some basic exposure
to computer programming in order to get the most out of this course. About one
year of calculus and linear algebra courses at college or university level should be
sufficient.
We will deal a lot with polynomials. In short, a function f (x) is a polynomial
p(x) if it is a finite power series in some unknown variable x with coefficients ak
where the index k ranges from 0 to the so-called degree of the polynomial n:
n
X
p(x) = ak x k = a0 + a1 x + a2 x 2 + · · · + an x n . (1.1)
k=0
In this course we will use the terms degree and order of a polynomial interchange-
ably. See the figure on this slide for an example of a 3rd -degree polynomial.
8
1.1. COURSE PREREQUISITES
Cubic spline interpolation
yn00 yn00
– linear algebra yn00 = Sn00 1 (xn ) = 2cn 1 + 6dn 1 hn 1 =) dn 1 =
6hn 1
• matrix representationHence,
of systems of linear
for all equations
n spline segements the coefficient dk can be written as
• solving those systems e.g., Gaussian elimination
y 00 yk00
dk = k+1 , k = 0, . . . n 1.
6hk
2 3
If you wonder why we don’t reduce the fraction, that yn = yis
n 1because
+ bn 1 hn 1this
+ cn example
1 hn 1 + dnis1 hn 1
c T.I.M.
9
Another Random Document on
Scribd Without Any Related Topics
Tytön vastaukset olivat niin ujostelemattoman avomieliset, entä ne
ehdottomasti vaikuttivat virkistävästi. "Minä sitä pahempi en tietänyt
mikä merkillisyys te olitte."
"Ettekö?"
"Keneltä?"
"Sitä en sano."
"Noo —"
Yleensä oli hän hemmoteltu lapsi. Hänen äitinsä oli kuollut hänen
vielä kehdossa nukkuessaan. Hän oli ainoa lapsi ja isä ja täti, jotka
häntä kasvattivat jumaloivat häntä. Kolmannesta ikävuodestaan oli
hän ollut kodin itsevaltias. Sellaisella varmuudella, joka versoi tästä
kasvatuksesta, oli hän tullut maailmaan, ja kaikkialla, minne vaan
hän oli tullutkin, oli maailma alistunut tämän varman, rikkaasta
kodista lähteneen pikku valtikan edessä.
Näillä retkillä oli täti aluksi mukana, mutta sittemmin kun seurueen
jäsenet olivat tutustuneet jonkun verran toisiinsa, jätettiin hänet
kotiin. Hänellä oli tuo esiliinoille harvinaisen onnellinen ominaisuus,
että hänellä ei koskaan ollut mitään muuta tahtoa kuin nuoren
veljentyttärensä ja pian tuli hänen palveluksensa rajoittumaan
yksinomaan niihin tilaisuuksiin, kun nuoret esiintyivät, niin sanoaksi,
enemmän julkisesti: illanvietoissa, jolloin täti asetettiin käsitöineen
nurkkaan ja yleisinä kävelytunteina, jolloin nuoret vaelsivat
ihmisvilinässä edestakaisin kylpölän sillalla.
Sitä paitse oli nuorilla tilaisuutta tapaamiseen milloin tahansa
päivällä, ja he tapasivatkin toisiaan yhä useammin. Pellen ihastus
Bansvikin potrihin poikihin väheni huomattavasti samassa suhteessa
kuin hänen ihastuksensa pieneen skånettareen, viehättävine rrrineen
kasvoi, ja Williamin valkoinen paperiarkki kävi yhä tomusemmaksi,
hänen kynänsä koskaan koskematta siihen.
"Neitosille varmaan."
"Tietysti."
William hymyili.
"Ooo! mikä kunnia tekijälle!"
Tyttö purskahti nauruun. Hän oli alusta alkaen tekeytynyt kuin hän
varsin hyvin tuntisi William Zimmermannin kirjalliset tuotteet.
"Mitä olisi minun sitte pitänyt sanoa. Tiedän varsin hyvin miten
turhamaisia herrat kirjailijat ovat."
"Niin."
"Kyllä tietysti."
"Vai niin."
"Miks'ei se sopisi?"
Katse, jonka tyttö loi häneen oli avonainen ja peloton. William piti
sen hänen viattoman tiedottomuutensa osoitteena, mutta se
todellisuudessa olikin ilmaus hänen tietoisuudestaan ja siitä, että hän
oli niin täydellisesti varma itsestään.
"Niinkö mielestänne?"
"Kuinka kauan?"
"Miksikä niin?"
"Te olette älykäs pieni neitonen", sanoi hän. "Ja alanpa melkein
myös epäillä, että olette harvinaisen rehellinen pikku neiti. Minua
huvittaisi tulla teitä tuntemaan."
"En"
"Miksi ei?"
"Mitä se hyödyttäisi?"
*****
Neiti Alma Hagberg oli yksi niistä, joka oli saanut kauneimman
sadon; hänen kasvonsa olivatkin pelkkänä autuaallisena hymyilynä.
Hän seisoi ylikannella ja hänen pienen, pyylevän vartalonsa piirteet
esiintyivät selvästi ruskeassa matkapuvussaan tupakkahytin valkeata
seinää vasten. Hänen vierellään seisoi pieni neiti Johnsson solakkana
ja suorana sinisessä kesätakissaan, jalompimuotoisena paljonkin
vartaloltaan ja asennoltaan, verrattomasti kauniimpana rohkeine,
totisine piirteineen William ajatteli hieman katkeralla mielellä, että
hänen kenties olisikin pitänyt valita hänet kesäidyllinsä
sankarittareksi, niin olisi se kenties siinä tapauksessa saanut
paremmin tyydyttävän lopun, — todellisen hyvästijätön. Hän tunsi
hurjasti janoavansa tätä hyvästiä, jota vaille hän oli jäänyt ja tämä
jano purkihe katkeruuden tunteeksi sitä kohtaan, joka nyt vetäysi
pois, antamatta muuta hyvästiä kuin käden puristuksen laivasillalla,
keskellä väen vilinää. Pelle oli vaeltanut tietä pitkin kesäsatuineen.
Hän varmaan oli saanut oikeat hyvästit, hän!
"En vielä."
William kohoutti olkapäitään ja koetti olla ivallisen näköinen. Hän
alkoi katsella ympärillä seisovia pilkallisin silmäyksin.
"Koht' sillään."
"Sinäkinkö? Minne?"
"Skooneen kenties."
"Mitä sinulla on siellä tekemistä?"
Tarkalla vaistollaan tunsi hän, että se oli jotain, josta hänen täytyi
kieltäytyä. Kosto siitä koituisi heidän välillensä ja tekisi sen elämän-
ilman ummehtuneeksi ja tukahduttavaksi. Poika pitäisi sen painavana
siteenä ja repisi siitä itsensä irti.
Ikäviä päiviä olivat olleet nämät kesäpäivät, vailla muuta iloa kuin
työn tuottama. Mutta itse tätä työtä oli äiti oppinut rakastamaan,
sillä hän tunsi, kuinka se solmi yhä lujemmin hänet pojan
maailmaan, antoi hänelle tuhat salaista tietä tulla häntä lähemmäksi,
tarttua kiinni hänen harrastuksiinsa, taistellen saavuttaa hänen
kunnioituksensa — ja rakkautensa.
Säännöllisesti, yksitoikkoisesti kului aika. Työtunnit, aterioimisajat,
lepo ja virkistyshetket — siinä hänen päivänsä. Viimemainittuja ei
hän lyönyt laimin. Hän kylpi ja teki pitkiä kävelyretkiä. Hän piti
ylpeytenään että Williamilla olisi terve, kaunis vanha äiti, jota hänen
ei koskaan tarvitsisi häveten kulettaa käsikoukussaan ja jonka ryhtiä
ja voimaa hänen mieluimmin tulisi ihaella hiukan, hiukkasen vain.
"Halvattu sisällisesti."
Oi Jumala, jos hän voisi rakastaa, jos hän voisi oppia pitämään
jostakin! Hänet itsensä saisi hän mielellään sysätä syrjään — — jos
vaan löytyisi ainoakaan ihminen maailmassa, josta hän pitäisi. Äitiä
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
ebookbell.com