Numerical Methods in Physics Lecture 2 Interpolation

Similar documents
Mar. 20 Math 2335 sec 001 Spring 2014

APPM/MATH Problem Set 4 Solutions

3D Modeling Parametric Curves & Surfaces

Fall CSCI 420: Computer Graphics. 4.2 Splines. Hao Li.

Interpolation - 2D mapping Tutorial 1: triangulation

3D Modeling Parametric Curves & Surfaces. Shandong University Spring 2013

Know it. Control points. B Spline surfaces. Implicit surfaces

Splines. Parameterization of a Curve. Curve Representations. Roller coaster. What Do We Need From Curves in Computer Graphics? Modeling Complex Shapes

Interpolation & Polynomial Approximation. Cubic Spline Interpolation II

Geometric Modeling of Curves

8 Piecewise Polynomial Interpolation

CS-184: Computer Graphics

Bézier Splines. B-Splines. B-Splines. CS 475 / CS 675 Computer Graphics. Lecture 14 : Modelling Curves 3 B-Splines. n i t i 1 t n i. J n,i.

Lecture 6: Interpolation

Objects 2: Curves & Splines Christian Miller CS Fall 2011

CS-184: Computer Graphics. Today

8 Project # 2: Bézier curves

CS 450 Numerical Analysis. Chapter 7: Interpolation

AMS527: Numerical Analysis II

Derivative. Bernstein polynomials: Jacobs University Visualization and Computer Graphics Lab : ESM4A - Numerical Methods 313

Splines. Connecting the Dots

Multiple-Choice Test Spline Method Interpolation COMPLETE SOLUTION SET

ME 261: Numerical Analysis Lecture-12: Numerical Interpolation

An introduction to interpolation and splines

Lecture 8. Divided Differences,Least-Squares Approximations. Ceng375 Numerical Computations at December 9, 2010

99 International Journal of Engineering, Science and Mathematics

Remark. Jacobs University Visualization and Computer Graphics Lab : ESM4A - Numerical Methods 331

Direction Fields; Euler s Method

LECTURE NOTES - SPLINE INTERPOLATION. 1. Introduction. Problems can arise when a single high-degree polynomial is fit to a large number

Curve fitting using linear models

15.10 Curve Interpolation using Uniform Cubic B-Spline Curves. CS Dept, UK

B-Spline Polynomials. B-Spline Polynomials. Uniform Cubic B-Spline Curves CS 460. Computer Graphics

Handout 4 - Interpolation Examples

CS 475 / CS Computer Graphics. Modelling Curves 3 - B-Splines

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics

CS770/870 Spring 2017 Curve Generation

(Refer Slide Time: 00:02:24 min)

Independent Practice #2

Piecewise Polynomial Interpolation, cont d

Interactive Graphics. Lecture 9: Introduction to Spline Curves. Interactive Graphics Lecture 9: Slide 1

Cubic Splines By Dave Slomer

AM205: lecture 2. 1 These have been shifted to MD 323 for the rest of the semester.

Lecture 2.2 Cubic Splines

Computational Physics PHYS 420

Numerical Methods in Physics. Lecture 1 Intro & IEEE Variable Types and Arithmetic

Curve Representation ME761A Instructor in Charge Prof. J. Ramkumar Department of Mechanical Engineering, IIT Kanpur

Sung-Eui Yoon ( 윤성의 )

Curves and Surfaces Computer Graphics I Lecture 9

Table for Third-Degree Spline Interpolation Using Equi-Spaced Knots. By W. D. Hoskins

Math 226A Homework 4 Due Monday, December 11th

Parameterization. Michael S. Floater. November 10, 2011

Numerical Methods 5633

Lecture 9. Curve fitting. Interpolation. Lecture in Numerical Methods from 28. April 2015 UVT. Lecture 9. Numerical. Interpolation his o

In some applications it may be important that the extrema of the interpolating function are within the extrema of the given data.

2D Spline Curves. CS 4620 Lecture 18

MA 323 Geometric Modelling Course Notes: Day 21 Three Dimensional Bezier Curves, Projections and Rational Bezier Curves

Homework Packet Week #2

Finite Element Analysis Prof. Dr. B. N. Rao Department of Civil Engineering Indian Institute of Technology, Madras. Lecture - 24

2D Spline Curves. CS 4620 Lecture 13

18.02 Multivariable Calculus Fall 2007

Optimization and least squares. Prof. Noah Snavely CS1114

Math 1525: Lab 4 Spring 2002

Chapter 18. Geometric Operations

Spline Curves. Spline Curves. Prof. Dr. Hans Hagen Algorithmic Geometry WS 2013/2014 1

Module 1: Introduction to Finite Difference Method and Fundamentals of CFD Lecture 6:

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Cubic Spline Questions

PS Geometric Modeling Homework Assignment Sheet I (Due 20-Oct-2017)

Announcements. Image Matching! Source & Destination Images. Image Transformation 2/ 3/ 16. Compare a big image to a small image

Simple Keyframe Animation

Manipulator trajectory planning

Homework #6 Brief Solutions 2012

Spline Notes. Marc Olano University of Maryland, Baltimore County. February 20, 2004

Design considerations

Chapter 19 Interpolation

An Introduction to B-Spline Curves

Kochanek-Bartels Cubic Splines (TCB Splines)

Lecture 4.5: Interpolation and Splines

Friday, 11 January 13. Interpolation

EECS 556 Image Processing W 09. Interpolation. Interpolation techniques B splines

Georeferencing & Spatial Adjustment

Kevin James. MTHSC 102 Section 1.5 Polynomial Functions and Models

Section 1.5 Transformation of Functions

COMPUTER AIDED ENGINEERING DESIGN (BFF2612)

February 2017 (1/20) 2 Piecewise Polynomial Interpolation 2.2 (Natural) Cubic Splines. MA378/531 Numerical Analysis II ( NA2 )

Section 1.5 Transformation of Functions

Lecture VIII. Global Approximation Methods: I

Natural Quartic Spline

Spatial Interpolation & Geostatistics

Understanding Gridfit

Linear Interpolating Splines

Video 11.1 Vijay Kumar. Property of University of Pennsylvania, Vijay Kumar

Polynomials tend to oscillate (wiggle) a lot, even when our true function does not.

Central issues in modelling

Spline Morphing. CG software practical course in the IWR. Carl Friedrich Bolz. Carl Friedrich Bolz

Parameterization of triangular meshes

NUMERICAL INTEGRATION

(Spline, Bezier, B-Spline)

Parametric curves. Reading. Curves before computers. Mathematical curve representation. CSE 457 Winter Required:

Computer Graphics Curves and Surfaces. Matthias Teschner

Transcription:

Numerical Methods in Physics Pat Scott Department of Physics, Imperial College November 8, 2016 Slides available from http://astro.ic.ac.uk/pscott/ course-webpage-numerical-methods-201617

Outline The problem 1 The problem 2 3

Outline The problem 1 The problem 2 3

Finite Sampling Real data are always sampled at discrete times, positions and energies (with uncertainties but that s another story) Theory is also often not practically calculable at whatever t, x and E we might like Might be expensive to compute Might rely on experimental input

Why interpolate? We may care about y at some x = t care not tabulated May need y as a continuous function of x Some other calculation depends on y at unknown x You actually need dy dx You need to calculate y(x)dx You just want a nice-looking plot for your paper/talk/mum

Requirements and Considerations The interpolating function must pass through all the points Otherwise we re doing curve fitting or data smoothing which is a whole lot shadier The function itself must be continuous (duh actually given by the above) But to how many orders? First derivative? More?

Issues of Locality Interpolation within the interval (x j, x j+1 ) may use just {y j, y j+1 }, or {y j 1, y j, y j+1, y j+2 }, or {y j 2, y j 1, y j, y j+1, y j+2, y j+3 }, etc Degree of locality of an interpolation scheme impacts continuity and stability Something must be non-continuous as we pass from using one set of points to another Less local allows for greater smoothness Less local also allows greater excursion (= insantity) Degree of interpolation scheme = number of pts used 1 Linear = degree 1, cubic = degree 3 (surprise)

Outline The problem 1 The problem 2 3

Linear interpolation the easy option Basically just connecting dots with straight lines = continuous function, no continuous derivatives Given by the formula with A x j+1 x x j+1 x j, (2) B 1 A = x x j x j+1 x j (3) y = Ay j + By j+1, (1)

Spline interpolation What if you need continuous derivatives as well? Spline interpolation: piecewise polynomials between each data point Degree n spline order n polynomial G n 1 continuous Cubic splines 4-point, 3rd degree scheme, cubic polynomials, G 2 contin. minimal way to get continuous first and second derivatives i.e. y varies linearly from x j to x j+1 = y = constant in intervals, y = 0 generated by adding corrections to linear formula: with y = Ay j + By j+1 + Cy j + Dy j+1, (4) C 1 6 (A3 A)(x j+1 x j ) 2 D 1 6 (B3 B)(x j+1 x j ) 2 (5)

Cubic Splines But what good is this?? y = Ay j + By j+1 + Cy j + Dy j+1, We don t have values of y tabulated how do we use this? Answer: We solve for y 1..n by other means (where n total num pts) How? Well, we still need to impose continuity of the first derivative...

Cubic Splines Using we get da dx = db dx = 1, (6) x j+1 x j dc dx = 1 3A2 (x j+1 x j ) 6 (7) dd dx = 3B2 1 (x j+1 x j ) 6 (8) dy dx = y j+1 y j 3A2 1 (x j+1 x j )y j + 3B2 1 (x j+1 x j )y j+1. (9) x j+1 x j 6 6

Cubic Splines Imposing the continuity of dy dx at x j (i.e. where intervals [x j 1, x j ] and [x j, x j+1 ] meet) dy dx x x j then gives the master equation x j x j 1 y 6 j 1 + x j+1 x j 1 3 valid for j = 2.. n 1 y j = dy dx x x + j (10) + x j+1 x j y j+1 = y j+1 y j y j y j 1 (11) 6 x j+1 x j x j x j 1 = system of n 2 equations in n unknowns (y 1..n) = 2D solution space need 2 more constraints to close the system

Boundary conditions Two additional constraints come from boundary conditions Need to specify either the first or second derivative at each endpoint y = 0 gives a Natural spline Other common choice is specifying first derivative at each boundary

Solution The problem x j x j 1 } {{ 6 } a j y j 1 + x j+1 x j 1 }{{ 3 } b j y j + x j+1 x j 6 } {{ } c j b 1 c 1 0 0 a 2 b 2 c 2. 0........... a j b j c j.......... 0 a n 1 b n 1 c n 1 0 0 a n b n y j+1 = y j+1 y j y j y j 1 x j+1 x j x j x j 1 }{{} F j y 1 y 2. y j. y n 1 y n = F 1 F 2. F j. F n 1 F n Endpoint equations together with master equation gives matrix equation M y = F = y = M 1 F (12) Tridiagonal system - can use tridiagonal matrix inversion tricks to do this Now we have y 1..n and can use Eq. 4 to evaluate y(x) for any x!

Outline The problem 1 The problem 2 3

Ringing - the bane of cubic splines y 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 True function Cubic spline 100 200 300 400 500 600 700 800 900 x

Ringing - the bane of cubic splines y 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 True function Cubic spline with 4 points Nodes in 4-point spline Cubic spline with 9 points Additional nodes in 9-point spline 100 200 300 400 500 600 700 800 900 x Can sometimes be solved by increasing samples Not always practical, doesn t work for many functions

Other random tips Be careful with functions possessing large higher derivatives Only need to call the setup once = important to highly optimise the evaluation, less so the setup Occasionally linear interpolation can actually be the best choice But often neither linear nor cubic splines are good enough...

Beyond basic cubic splines Higher dimensions - curves and surfaces Advanced interpolators - exponential splines, splines under tension, etc Related: curve design (Bezier curves, B splines, etc) A few (open-source) packages I like: TSPACK - 1D splines with auto tension and nice shape-preserving properties http://portal.acm.org/citation.cfm?id=151277 TENSBS - simple 2D and 3D cubic splines http://gams.nist.gov/serve.cgi/packagemodules/cmlib FITPACK - 2D splines with manual tension http://www.netlib.org/fitpack/

Housekeeping Assignment 2 now available on the homepage Covers cubic spline interpolation Tutorial/help session: 11am Fri Nov 11 Due in: Monday Nov 14 Next lecture: Random numbers (Tues Nov 15)