Introduction to Numerical Methods (Algorithm)

Similar documents
CS227-Scientific Computing. Lecture 6: Nonlinear Equations

Chapter 7 One-Dimensional Search Methods

February 2 Math 2335 sec 51 Spring 2016

Feb. 4 Math 2335 sec 001 Spring 2014

4.2 Rolle's Theorem and Mean Value Theorem

Interpolation. 1 What is interpolation? 2 Why are we interested in this?

Analysing and computing cash flow streams

Using derivatives to find the shape of a graph

Golden-Section Search for Optimization in One Dimension

25 Increasing and Decreasing Functions

Solution of Equations

This method uses not only values of a function f(x), but also values of its derivative f'(x). If you don't know the derivative, you can't use it.

Lecture Quantitative Finance Spring Term 2015

Math 1314 Week 6 Session Notes

CS 3331 Numerical Methods Lecture 2: Functions of One Variable. Cherung Lee

Sensitivity Analysis with Data Tables. 10% annual interest now =$110 one year later. 10% annual interest now =$121 one year later

Math 1526 Summer 2000 Session 1

Mathematics (Project Maths Phase 2)

Unit 3: Writing Equations Chapter Review

PORTFOLIO OPTIMIZATION AND EXPECTED SHORTFALL MINIMIZATION FROM HISTORICAL DATA

b) According to the statistics above the graph, the slope is What are the units and meaning of this value?

Graphing Equations Chapter Test Review

Lecture 10: The knapsack problem

MLC at Boise State Polynomials Activity 2 Week #3

You may be given raw data concerning costs and revenues. In that case, you ll need to start by finding functions to represent cost and revenue.

Principles of Financial Computing

Numerical Analysis Math 370 Spring 2009 MWF 11:30am - 12:25pm Fowler 110 c 2009 Ron Buckmire

CS360 Homework 14 Solution

Finding Roots by "Closed" Methods

Theory of Consumer Behavior First, we need to define the agents' goals and limitations (if any) in their ability to achieve those goals.

Penalty Functions. The Premise Quadratic Loss Problems and Solutions

3/1/2016. Intermediate Microeconomics W3211. Lecture 4: Solving the Consumer s Problem. The Story So Far. Today s Aims. Solving the Consumer s Problem

Questions 3-6 are each weighted twice as much as each of the other questions.

A. B. C. D. Graphing Quadratics Practice Quiz. Question 1. Select the graph of the quadratic function. f (x ) = 2x 2. 2/26/2018 Print Assignment

Econ 582 Nonlinear Regression

lecture 31: The Secant Method: Prototypical Quasi-Newton Method

Chapter 6: Quadratic Functions & Their Algebra

Benchmarking. Club Fund. We like to think about being in an investment club as a group of people running a little business.

Math1090 Midterm 2 Review Sections , Solve the system of linear equations using Gauss-Jordan elimination.

Notes on a Basic Business Problem MATH 104 and MATH 184 Mark Mac Lean (with assistance from Patrick Chan) 2011W

Techniques for Calculating the Efficient Frontier

Properties of IRR Equation with Regard to Ambiguity of Calculating of Rate of Return and a Maximum Number of Solutions

EconS Constrained Consumer Choice

Lecture Notes #3 Page 1 of 15

The method of false position is also an Enclosure or bracketing method. For this method we will be able to remedy some of the minuses of bisection.

THE TRAVELING SALESMAN PROBLEM FOR MOVING POINTS ON A LINE

Global Financial Management

EGR 102 Introduction to Engineering Modeling. Lab 09B Recap Regression Analysis & Structured Programming

The Baumol-Tobin and the Tobin Mean-Variance Models of the Demand

ECON Chapter 6: Economic growth: The Solow growth model (Part 1)

Can we have no Nash Equilibria? Can you have more than one Nash Equilibrium? CS 430: Artificial Intelligence Game Theory II (Nash Equilibria)

GE in production economies

1 Income statement and cash flows

Graphs Details Math Examples Using data Tax example. Decision. Intermediate Micro. Lecture 5. Chapter 5 of Varian

Module 3: Factor Models

Question 3: How do you find the relative extrema of a function?

WEEK 1 REVIEW Lines and Linear Models. A VERTICAL line has NO SLOPE. All other lines have change in y rise y2-

1 Economical Applications

35 38 point slope day 2.notebook February 26, a) Write an equation in point slope form of the line.

Transactions Demand for Money

Optimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur. Lecture - 18 PERT

(Note: Please label your diagram clearly.) Answer: Denote by Q p and Q m the quantity of pizzas and movies respectively.

Mathematics Success Grade 8

ECON Micro Foundations

Symmetric Game. In animal behaviour a typical realization involves two parents balancing their individual investment in the common

F A S C I C U L I M A T H E M A T I C I

Calculus Chapter 3 Smartboard Review with Navigator.notebook. November 04, What is the slope of the line segment?

UNIT 1 THEORY OF COSUMER BEHAVIOUR: BASIC THEMES

Factoring Quadratic Expressions VOCABULARY

1 Dynamic programming

Chapter 6 Rate of Return Analysis: Multiple Alternatives 6-1

Support Vector Machines: Training with Stochastic Gradient Descent

Topic #1: Evaluating and Simplifying Algebraic Expressions

We are going to see the consumer s decision theory that you have seen in ECON 111 in another way.

Fundamental Theorems of Welfare Economics

1 Maximizing profits when marginal costs are increasing

Factoring is the process of changing a polynomial expression that is essentially a sum into an expression that is essentially a product.

Mathematics for Management Science Notes 07 prepared by Professor Jenny Baglivo

This appendix discusses two extensions of the cost concepts developed in Chapter 10.

Market Risk Analysis Volume I

Chapter 19 Optimal Fiscal Policy

MLC at Boise State Lines and Rates Activity 1 Week #2

Chapter 10: Mixed strategies Nash equilibria, reaction curves and the equality of payoffs theorem

4.3 The money-making machine.

Chapter 7: Investment Decision Rules

We take up chapter 7 beginning the week of October 16.

Chapter 1 Microeconomics of Consumer Theory

CCAC ELEMENTARY ALGEBRA

MATH20330: Optimization for Economics Homework 1: Solutions

Chapter 7 Rate of Return Analysis

5.6 Special Products of Polynomials

Queens College, CUNY, Department of Computer Science Computational Finance CSCI 365 / 765 Spring 2018 Instructor: Dr. Sateesh Mane. September 16, 2018

MATH THAT MAKES ENTS

Figure (1) The approximation can be substituted into equation (1) to yield the following iterative equation:

Chapter 9 Dynamic Models of Investment

1 Consumption and saving under uncertainty

Extend the ideas of Kan and Zhou paper on Optimal Portfolio Construction under parameter uncertainty

Engineering Economics

Intro to Economic analysis

Factors of 10 = = 2 5 Possible pairs of factors:

Transcription:

Introduction to Numerical Methods (Algorithm) 1

2 Example: Find the internal rate of return (IRR) Consider an investor who pays CF 0 to buy a bond that will pay coupon interest CF 1 after one year and CF 2 (coupon interest plus face value) after two years. The investor wants to find the internal rate of return or yield to maturity that solves the following equation Letting x = 1+IRR 1, we can rewrite the polynomial equation as CF 0 = CF 1 1 + IRR + CF 2 (1 + IRR) 2 (1) 0 = CF 0 +CF 1 x +CF 2 x 2 (2) To fix idea, let CF 0 = 90,CF 1 = 10,CF 2 = 100. So we want to solve 0 = 90 + 10x + 100x 2 (3)

3 Eye-ball method We can plot a range of possible values of x against 90 + 10x + 100x 2, which is called net present value (npv) in finance. The root is a special x that makes npv equal zero. From the graph below we see x = 0.9 is the root, and the resulting IRR is IRR = 1 x 1 = 1 0.9 1 = 0.11. npv 80 60 40 20 0 20 0.0 0.2 0.4 0.6 0.8 1.0 x

4 R code The R codes for the eye-ball method is x = seq(0.01, 0.99, by = 0.01) npv = rep(0, length(x)) for (i in seq(1,length(x))) { npv[i] = -90 + 10*x[i] + 100*x[i]ˆ2 } plot(x, npv) abline(h=0,lty=2) cbind(npv, x)

5 While loop We can use a while loop to automatically find the root without using eyeball. x = 0.01 npv = -90 + 10*x + 100*xˆ2 while(npv < 0) { x = x + 0.001 npv = -90 + 10*x + 100*xˆ2 } cat("root x is ", x, "\n") cat("irr is ", 1/x-1, "\n") Basically, the npv changes from being negative to positive at the root x, where the while loop stops. Does this sound like artificial intelligence?

6 Bisection method The fact that npv switches the sign around the root motivates the bisection method, which 1. evaluates npv at two points (a,b) that produce opposite signs of npv 2. lets the tentative root be a+b 2, and evaluate both ( a, a+b ) ( 2 and a+b 2,b) 3. picks whichever pair that gives the npv with opposite signs, and let the average of them be the next tentative root 4. the iteration continues until the npv of the tentative root is sufficiently close to zero The bisection method is justified by the intermediate value theorem, which states that given two points a and b such that f (a) and f (b) have opposite signs, a continues f must have at least one root in the interval [a,b].

7 R code npv = function(x) { y = -90 + 10*x + 100*xˆ2; return(y) } a = 0.10; b = 0.99; root = (a+b)/2 while (npv(a)*npv(b)<0 & abs(npv(root))>0.001) { root = (a+b)/2 if (npv(a)*npv(root)<0) {a = a; b = root} else {a = root; b = b} } cat("root x is ", root, "\n") cat("irr is ", 1/root-1, "\n")

8 Newton Raphson method Notice that the npv is a continuous and differentiable (smooth) function of x. So we can pick an initial value x 0, draw a tangent line at npv(x 0 ) and use the intersection of the tangent line and the horizonal axis as the next value x 1. See the graph below for an illustration. Again, the iteration continues until the npv is very close to zero. NPV 0 x1 x0 x

9 Newton Raphson method Mathematically, let npv () denote the first order derivative, then the first iteration is x 1 = x 0 npv(x 0) npv (x 0 ) (4) which is based on the definition of slope of tangent line npv(x 0 ) x 0 x 1 = npv (x 0 ) More generally, after the i-th iteration, the i + 1-th iteration is ( ) npv(xi ) x i+1 = x i k i npv (x i ) (5) where the step size k i is used to avoid overshooting

10 R code npv = function(x) { y = -90 + 10*x + 100*xˆ2; return(y) } npvprime = function(x) { y = 10 + 200*x; return(y) } root = 0.98 while (abs(npv(root))>0.001) { step = npv(root)/npvprime(root) while (abs(step)>0.1) {step = step/10} root = root- step } cat("root x is ", root, "\n") cat("irr is ", 1/root-1, "\n")

11 Comparison of three numerical methods 1. The eyeball method works only when we know the possible range of roots. It does not assume continuity or differentiability. 2. The bisection method assumes the function is continuous and we can find two points with opposite signs 3. The Newton Raphson method assumes differentiability and we can calculate the first order derivative

12 Comparison of numerical methods and analytical solution Analytical solution exists for the quadratic equation (2), but are unavailable for a polynomial equation with order greater than two. For those highly non-linear equations, we have to use numerical methods.

13 Numerical methods for optimization problem Suppose we want to maximize an objective function f (x) (such as a total utility function). Assuming the objective function is differentiable, a necessary condition is that the first order derivative is equal to zero f ( x optimal) = 0 (6) The optimal value x optimal is just the root that solves the equation (6). We already know numerical methods can be used to find the roots (and in this case, optimal values). For example, the optimal consumption that maximizes total utility satisfies the condition (equation) that marginal utility is equal to zero

14 Numerical methods and initial values The solution for the equation (6) can be either local maximum or local minimum. To tell which is which, and whether the local optimum is a global one, we need to try different initial values and compare the objective values.

15 Exercises 1. Draw a graph to illustrate the idea behind the bisection method 2. Modify the bisection method code so that the root is not a simple average, but a weighted average of end points wa + (1 w)b. How to determine the weight w? 3. Try to remove while (abs(step)>0.1) {step = step/10} from the Newton Raphson method code, and explain the difference you see in the result. What is overshooting?