Serving the Quantitative Finance Community

 
User avatar
LesleYLyu
Topic Author
Posts: 0
Joined: October 11th, 2012, 9:01 pm

Matlab ode45

March 19th, 2013, 11:50 pm

Hi all,Would someone give me some hints on how to use Matlab ode45? I checked some examples as well as matlab documentation, but still feel confused...Anyway here is what I would like to solve. I am trying to solve heston characteristic function numerically, to compare with analytical one. The system is y = [C(u,t), D(u,t)], where C(u,t) and D(u,t) satisfies:where k is constant, and a,b,c are function of u.I am confused about how to write odefun when using ode45. If a,b,c are function of t, there is example in matlab documentation, but now they are function of a variable not appearing in the system...Thanks in advance for any hints.Best
Last edited by LesleYLyu on March 19th, 2013, 11:00 pm, edited 1 time in total.
 
User avatar
OOglesby
Posts: 1
Joined: August 26th, 2011, 5:34 am

Matlab ode45

March 20th, 2013, 9:01 pm

Normally, the odefun has the form: ydot = odefun(t, y). However, you can pass extra arguments into the function: ydot = odefun(t, y, arg1, arg2, argn). Below are two code examples. The first example passes in u and computes a, b, and c inside the function. The second example assumes u is constant over the integration, and therefore assumes a, b, and c are constants.I am no expert, but it seems like the resulting solution will be very smooth and continuous. If that is the case, then you get better speeds and can increase the solution accuracy by using ode113.