Lecture 6: Interpolation

Similar documents
Lecture VIII. Global Approximation Methods: I

Multiple-Choice Test Spline Method Interpolation COMPLETE SOLUTION SET

ME 261: Numerical Analysis Lecture-12: Numerical Interpolation

Numerical Methods in Physics Lecture 2 Interpolation

Mar. 20 Math 2335 sec 001 Spring 2014

CS 450 Numerical Analysis. Chapter 7: Interpolation

8 Piecewise Polynomial Interpolation

Handout 4 - Interpolation Examples

Computational Physics PHYS 420

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

APPM/MATH Problem Set 4 Solutions

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

Lecture 2 Optimization with equality constraints

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

Interpolation - 2D mapping Tutorial 1: triangulation

3D Modeling Parametric Curves & Surfaces

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

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

x y

Projective spaces and Bézout s theorem

Rational Bezier Curves

Section 1.5 Transformation of Functions

Kevin James. MTHSC 102 Section 1.5 Polynomial Functions and Models

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

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

Lecture 25 Nonlinear Programming. November 9, 2009

Linear Interpolating Splines

Consider functions such that then satisfies these properties: So is represented by the cubic polynomials on on and on.

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

Volumes of Solids of Revolution

Open and Closed Sets

Supplemental 1.5. Objectives Interval Notation Increasing & Decreasing Functions Average Rate of Change Difference Quotient

Piecewise polynomial interpolation

EC5555 Economics Masters Refresher Course in Mathematics September Lecture 6 Optimization with equality constraints Francesco Feri

IB HL Mathematical Exploration

CS770/870 Spring 2017 Curve Generation

Section 1.5 Transformation of Functions

Depth First Search A B C D E F G A B C 5 D E F 3 2 G 2 3

Important Properties of B-spline Basis Functions

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

Lacunary Interpolation Using Quartic B-Spline

An introduction to interpolation and splines

EE/ACM Applications of Convex Optimization in Signal Processing and Communications Lecture 6

Lecture 2.2 Cubic Splines

lecture 10: B-Splines

Parameterization. Michael S. Floater. November 10, 2011

Interpolation by Spline Functions

AMS527: Numerical Analysis II

B-spline Curves. Smoother than other curve forms

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

COMPUTER AIDED GEOMETRIC DESIGN. Thomas W. Sederberg

Parameterization of triangular meshes

Quadratic and cubic b-splines by generalizing higher-order voronoi diagrams

(1) Given the following system of linear equations, which depends on a parameter a R, 3x y + 5z = 2 4x + y + (a 2 14)z = a + 2

Natural Quartic Spline

5.1 Introduction to the Graphs of Polynomials

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

CONSUMPTION BASICS. MICROECONOMICS Principles and Analysis Frank Cowell. July 2017 Frank Cowell: Consumption Basics 1

Introduction to Optimization Problems and Methods

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

Derivatives and Graphs of Functions

Recent Developments in Model-based Derivative-free Optimization

Introduction to optimization methods and line search

Math 113 Exam 1 Practice

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.

1 Programs for phase portrait plotting

Research Article Data Visualization Using Rational Trigonometric Spline

Computational Biology Lecture 6: Affine gap penalty function, multiple sequence alignment Saad Mneimneh

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

Four equations are necessary to evaluate these coefficients. Eqn

Background for Surface Integration

2. Convex sets. x 1. x 2. affine set: contains the line through any two distinct points in the set

First of all, we need to know what it means for a parameterize curve to be differentiable. FACT:

SPLINE APPROXIMATION VIA THE CONTROL POLYGON

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

Rational Bezier Surface

Convex Optimization. Convex Sets. ENSAE: Optimisation 1/24

Convex sets and convex functions

The Interpolating Polynomial

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

/ Approximation Algorithms Lecturer: Michael Dinitz Topic: Linear Programming Date: 2/24/15 Scribe: Runze Tang

Numerical Dynamic Programming. Jesus Fernandez-Villaverde University of Pennsylvania

Sec.4.1 Increasing and Decreasing Functions

2D Spline Curves. CS 4620 Lecture 13

Test 3 review SHORT ANSWER. Write the word or phrase that best completes each statement or answers the question.

Convex sets and convex functions

Curve fitting using linear models

Interpolation. TANA09 Lecture 7. Error analysis for linear interpolation. Linear Interpolation. Suppose we have a table x x 1 x 2...

Simple Keyframe Animation

f( x ), or a solution to the equation f( x) 0. You are already familiar with ways of solving

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

QUADRATIC FUNCTIONS. PROTOTYPE: f(x) = ax 2 + bx + c. (1) The leading coefficient a 0 is called the shape parameter.

MAT128A: Numerical Analysis Lecture Two: Finite Precision Arithmetic

Linear and quadratic Taylor polynomials for functions of several variables.

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

Differentiability and Tangent Planes October 2013

MA 323 Geometric Modelling Course Notes: Day 14 Properties of Bezier Curves

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

Convergence of C 2 Deficient Quartic Spline Interpolation

ALGEBRA 2 W/ TRIGONOMETRY MIDTERM REVIEW

Transcription:

Lecture 6: Interpolation Fatih Guvenen January 10, 2016 Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 1 / 25

General Idea Suppose you are given a grid (x 1, x 2,..., x n ) and the function values (y 1, y 2,...,y n ) at corresponding points generated by function f (x) Q: How to find values off the grid points that provides a good approximation to f (x)? A good approximation is often taken to mean to minimize f (x) b f (x) according to some norm (L p, sup-, etc). In economics another very important concern is to preserve the shape ie, concavity or convexity of the interpolated (e.g, utility or value) function Popular methods are linear-, Chebyshev-, and Splineinterpolations. I will spend most of my time on Splines. Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 2 / 25

Polynomial Approximation Weierstrass Approximation Theorem. Suppose f is a continuous real-valued function defined on the real interval [a, b]. For a given ">0, there exists a polynomial of order n, P n (x), such that for all x in [a, b], we have kf (x) P n (x)k 1 <". In the limit, lim kf (x) P n(x)k n!1 1 = 0. Runge. Let f (x) =1/(1 + x 2 ) on [-5,5], and let L m f be the unique polynomial of order m that interpolates f at m equally-spaced points. Then: lim sup f (x) L m f = m!1 ( 0 if x < 3.633..., 1 if x > 3.633... The two theorems are not contradictory. The first theorem does not provide a way of finding the right P n (x) and the second one shows a naive approach can fail spectacularly. Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 3 / 25

Runge Example

Splines: Three Objectives 1 Match the function values at grid points (y 1, y 2,...,y n ) exactly. 2 Generate first derivatives that are continuous and differentiable for all x 2 [x 1, x n ]. 3 Generate second derivatives that are continuous for all x 2 [x 1, x n ] Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 5 / 25

Splines: Building from Ground Up Begin with the interval between two generic knots, x i and x i+1. If we were to construct a linear interpolant: y = Ay j + By j+1 A(x) x j+1 x B(x) 1 A = x x j (1) x j+1 x j x j+1 x j Although linear interpolation is sometimes useful, a shortcoming is that I I First derivative changes abruptly at the knot points, i.e., the interpolants have as many kinks as the knot points. Second derivative does not exist at knot points. This can create many problems, such as difficulties with derivative based minimization algorithms. Question: How can we modify (1) to allow differentiable first derivatives and continuous second derivatives at all points? Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 6 / 25

Splines: Building from Ground Up Generalize (1) using second derivative values at knot points: y = A(x)y j + B(x)y j+1 + C(x)y 00 j + D(x)y 00 j+1 (2) where C(x) = 1 6 (A3 (x) A(x))(x j+1 x j ) 2 and D(x) = 1 6 (B3 (x) B(x))(x j+1 x j ) 2 Note that you only need to know A and B to calculate everything. Verify that d 2 y dx 2 = A(x)y 00 j + B(x)y 00 j+1 Since A(x j )=1and B(x j+1 )=1 A(x j+1 )=1, the second derivative agrees with y 00 at end points. But how to find y 00 j and y 00 j+1? Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 7 / 25

Splines: Building from Ground Up Differentiate (2) to obtain an expression for dy dx and y 00 j+1. that will involve y 00 j Then impose the condition that dy dx calculated using (x j, x j+1 ) and using (x j+1, x j+2 ) equal each other at x j+1. We get: x j x j 1 y 00 j 1 6 + x j+1 x j 3 y 00 j + x j+1 x j 6 y 00 j+1 = y j+1 y j x j+1 x j y j y j 1 x j x j 1 For interior knot points, j = 2,...,N 1 we have an equation like this. But we have N unknowns (y j for j = 1,...,N). Impose two boundary conditions to pin down y 00 00 1 and yn. (Set them to zero or some reasonable value given the economics of the problem). Notice: no condition is imposed for y 0 or y 00 to agree with f 0 and f 00, since these are unknown. This can create problems as we will see. Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 8 / 25

Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 9 / 25

Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 10 / 25

Comparing Interpolation Methods for U(C)

Comparing Boundary Conditions Figure: N = 500 pts -10 6-10 7 Log Axis -10 8-10 9-10 10 y 1 = U (0.05) y 1 =0 Natural Spline True Function -10 11 0.04 0.06 0.08 0.1 0.12 0.14 0.16

Comparing Boundary Conditions 10 10 5 Figure: N = 100 pts Linear Axis 0-5 -10 y 1 = U (0.05) y 1 =0 Natural spline True Function 0.05 0.1 0.15 0.2 0.25

Interpolation: What Can Go Wrong 2 x 108 1.5 1 0.5 0 0.5 CRRA function with γ =10 8th-order polynomial Cubic spline Shumaker quadratic spline 1 0 0.5 1 1.5 2 Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 14 / 25

Interpolation: What Can Go Wrong 10 0 10 20 30 40 50 60 0 0.5 1 1.5 2 Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 15 / 25

Standard Spline vs Shape-Preserving 1.5 1 0.5 0 0.5 1 y=tanh(x) at x= 5, 4, 3,... Cubic spline Shumaker s spline y=tanh(x) continuous 1.5 5 4 3 2 1 0 1 2 3 4 5 Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 16 / 25

Spacing of Grid Points: Crucial!! One heuristic: put more grid points where f has more curvature. Another one: put more points near the parts of the function that are more relevant. I e.g., in an RBC style model, put more points near K, even though the functions of interest may have more curvature at low K values. In incomp. mkts models, V 00 (!) is largest for very low!. So should put more points there. Is this true if there are not many individuals near the constraint? (Answer: Typically, Yes. But why?) In some DP problems, with max operator on the RHS, the value function may have a kink or significant curvature somewhere in the middle of the state space. I Linear interpolation maybe your best choice. Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 17 / 25

Figure: Grid Point Locations: 51-Point Expanding Grid From 0 to 250 θ = 1 θ = 2 θ = 3 θ = 4 θ = 1 θ = 2 θ = 3 θ = 4 0 1 2 3 4 5 Wealth 220 225 230 235 240 245 250 Wealth (a) Low End of Grid (b) High End of Grid Note: The number of grid points between 0 and 4.99 is 1, 8, 14, and 19 when is equal to 1, 2, 3, and 4, respectively.

Algorithmus 1 : CREATING APOLYNOMIALLY-EXPANDING GRID Step 1. First, create an equally-spaced [0,1] grid: { x j : x j = j 1 N 1, j = 1,...,N}. Step 2. Shift and expand the grid: x = {x j : x j = a +(b a) x j }, where >1 is the expansion factor. Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 18 / 25

Spline w/ Expanding Grid(1000 pts) Figure: N = 1000 pts 100 50 Equally-spaced, θ =1.0 θ = 1.05 θ = 1.10 0-50 -100 0 0.2 0.4 0.6 0.8 1 Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 19 / 25

Spline w/ Expanding Grid (100 pts) Figure: N = 100 pts 10 5 U(C) θ = 1.0 θ = 2.0 θ = 3.0 0-5 -10 0 1 2 3 4 5 Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 20 / 25

AWordaboutB-Splines A fundamental theorem about B-splines (see de Boor (1978)): Constructing a cubic spline interpolation with (m, n) points in (x, y) direction requires: I I O((mn) 2 ) operations using regular splines. O(m 3 + m 2 n + mn 2 + n 3 ) operations with B-splines. Suppose m = n = 10: I I Regular spline requires 1, 000, 000 operations B-splines require: 4, 000 operations! ) Learn about B-splines! Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 21 / 25

ATricktoReducetheCurvatureofV(w) Samuelson (1969) showed that in a standard portfolio choice problem with CRRA preferences and a linear budget set, the value function inherits the curvature of U: U(c 0, c 1,...)= 1X t=1 t c1 t 1 ) V (!, A) = (A)! 1 The same result holds approximately true in a variety of different problems. With incomplete markets V (w) will typically have even more curvature than U(c) especially at low wealth levels. As we have seen so far, this high curvature creates a lot of headache when you try to interpolate the value function. Fortunately, there is a way out! Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 22 / 25

ATricktoReducetheCurvatureofV(w) There is an alternative formulation of CRRA preferences: U(c 0, c 1,...)= 1X t=1 t c (1 ) t! 1/(1 ) This is a special case of Epstein-Zin (1989, E trica) utility and represents the same preferences as CRRA utility with RRA =. Now the value function is linear: V (!, A) = (A)! Although incomplete markets introduces some curvature, this value function is much easier to interpolate than the one above. In fact, I once solved a GE model with asset pricing and a risk aversion of 4 using only 30 points in the wealth grid and linear interpolation! Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 23 / 25

-10-10 0.21-10 -5 Standard CRRA Utility (left axis) -10 0 0.20-10 5 Epstein-Zin Value Func. (right axis) -10 10 0.19-10 15 0 1 2 3 4 5 Figure: Which Function Would You Rather Interpolate? Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 24 / 25

Final Thoughts For any model that you solve, you MUST eventually re-solve it on a much finer grid and confirm that your main results are not changing (much). This is the only realistic way to check if approximation errors coming from interpolations are important. You will be surprised to find that some bad-looking interpolations actually yield the same results as much more accurate (and more costly to compute) interpolations. And vice versa.. Some problems are especially sensitive to any kind of approximation errors. We will see examples. Fatih Guvenen ( ) Lecture 6: Interpolation January 10, 2016 25 / 25