Fin500J: Mathematical Foundations in Finance Topic 5: Numerical Methods for Optimization Philip H. Dybvig

1 / 25

# Fin500J: Mathematical Foundations in Finance Topic 5: Numerical Methods for Optimization Philip H. Dybvig - PowerPoint PPT Presentation

Fin500J: Mathematical Foundations in Finance Topic 5: Numerical Methods for Optimization Philip H. Dybvig Reference: Optimization Toolbox User’s Guide in Matlab, 2008 by the MathWorks, Inc. Slides designed by Yajun Wang. Recall, with optimization, we are seeking f '(x) = 0. f '(x) = 0

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Fin500J: Mathematical Foundations in Finance Topic 5: Numerical Methods for Optimization Philip H. Dybvig' - keilah

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Fin500J: Mathematical Foundations in Finance

Topic 5: Numerical Methods for Optimization

Philip H. Dybvig

Reference: Optimization Toolbox User’s Guide in Matlab, 2008 by the MathWorks, Inc.

Slides designed by Yajun Wang

Recall, with optimization, we are seeking f '(x) = 0

f '(x) = 0

f "(x)< 0

f '(x) = 0

f "(x)>0

One Dimension Unconstrained Optimization (Example)

Find the maximum of

To solve the root problem for

and the second condition is satisfied at the root

One Dimension Unconstrained Optimization (Example)
• We can solve f '(x) =0 by Bisection using initial interval [1,2], Newton’s with initial point 1.2 or Secant method with initial points 1.2 and 2 presented in Topic 3.
• We can also solve it in Matlab.
• >> f=@(x) 2*cos(x)-1/5*x;
• >> fzero(f,[1,2])
• ans =1.4276

Objectives : Using Optimization Toolbox in Matlab to
• Solve unconstrained optimization with multiple variables
• Solve linear programming problem
• Solve quadratic programming problem (for example: optimal portfolio)
• Solve nonlinear optimization with constraints
• Mostly, we will focus on minimization in this topic, max f(x) is equivalent to min –f(x)

• If f(x) and the constraints are linear, we have linear programming
• If f(x) is quadratic, and the constraints are linear, we have quadratic programming
• If f(x) in not linear or quadratic, and/or the constraints are nonlinear, we have nonlinear programming

Recall the Optimality Conditions for Multiple Variables
• Unconstrained Minimization Problem:
• min f(x1, x2,…xn)
• Optimality Condition: x* is a local minimum if
• Example:
• What values of x make

Unconstrained Optimization with Multiple Variables in Matlab
• Step 1: Write an M-file objfun.m and save under the work path of matlab
• function f=objfun(x)
• f=exp(x(1)+x(2)-1)+exp(x(1)-x(2)-1)+exp(-x(1)-1);
• Step 2: >>optimtool in the commend window to open the optimization toolbox

• We use the function fminunc to solve unconstrained optimization problem “objfun”

Recall the Algorithm of Newton Method
• Newton’s method may fail if Hessian is not positive
• definite

Quasi-Newton Methods Replace the Hessian with some Positive Definite Matrix H
• The function “fminunc” uses BFGS (Broyden, Fletcher, Goldfarb and Shanno) Hessian Update in the Quasi-Newton algorithm. The formula given by BFGS is

Linear Programming
• Both the objective function and the constraints are linear
• Example: maximizing profit or minimizing cost
• Objective function
• Max or Min Z = c1x1 +c2x2 +…..cnxn
• where cj = payoff of each unit of the jth activity
• xj = magnitude of the jth activity
• The constraints can be represented by
• ai1x1 +ai2x2+…..ainxn  bi
• where aij = amount of the ith resource that is consumed for each
• unit of the jth activity, bi = amount of the ith resource available
• Finally, we add the constraint that all activities have a positive value, xi 0

Example

x1 = amount of regular and

Total Profit = 150 x1 + 175 x2

Maximize Z = 150 x1 + 175 x2

Objective function

7x1 + 11x2 77 (material constraint)

10x1 + 8x2  120 (time constraint)

x1  9 (storage constraint)

x2  6 (storage constraint)

x1,x2  0 (positivity constraint)

Graphical Solution

(1) 7x1 + 11x2 77

→x2  -7/11 x1 +7

(2) 10x1 + 8x2  120

→ x2  -5/4x1 + 15

(3) x1  9

(4) x2  6

(5) x1,x2  0

Graphical Solution

Z = 0 (0=150x1 + 175x2)

and

Z = 500 (500=150x1 + 175x2)

Z=1200

Z=1550

Still in feasible region

x1*= 9

x2*  1.5

Linear Programming in Matlab

Example:

• Step 1: >>optimtool in the commend window to open the optimization
• toolbox
• Step 2: Define matrices A, Aeq and the vectors f, b, lb, ub

Linear Programming in Matlab (Example)
• File->export to workspace
• can export the results including lambda,etc.

• Step 1: >>optimtool in the commend window to open the optimization
• toolbox
• Step 2: Define matrices H,A and the vectors f, b

Quadratic Programming in Matlab (Example: Portfolio Optimization)

H=[0.017087987 0.003298885 0.001224849; 0.003298885 0.005900944 0.004488271; 0.001224849 0.004488271 0.063000818]

f=[0; 0; 0]

A=[1 1 1; -0.026 -0.008 -0.074; -1 0 0; 0 -1 0; 0 0 -1]

b=[1000; -50; 0; 0; 0]

The function ‘quadprog ’ uses an active set strategy. The first phase involves the calculation of a feasible point. The second phase involves the generation of an iterative sequece of feasible points that converge to the solution.

Formulation

Nonlinear Programming in Matlab (Example)

Find x that solves

• Step 1: Write an M-file objfunc.m for the objective function.
• function f=objfunc(x)
• f=exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1);
• Step 2: Write an M-file confun.m for the constraints.
• function [c, ceq]=confun(x)
• %Nonlinear inequality constraints
• c=[1.5+x(1)*x(2)-x(1)-x(2); -x(1)*x(2)-10];
• %Nonlinear equality constraints
• ceq=[];
• Step 3: >>optimtool to open the optimization toolbox