- vandervolt
**Posts:**51**Joined:**

edit: 2D Black-Scholes with r=0 of course....

- Cuchulainn
**Posts:**62626**Joined:****Location:**Amsterdam-
**Contact:**

QuoteOriginally posted by: vandervoltAlan,I think you are correct about the Matlab 2D PDE toolbox (ie not supporting advection/diffusion equation in 2D). So I don' think anyone will give you an answer to your Heston model test case.Its strength is in solving elliptic problems in nasty geometries. The GUI for setting up domains and meshes in nice and very easy to use, but unless your trying to solve 2D Black Scholes in a wrench it is perhaps not of much use in finance. The 1D solver pdepe is however, very easy to use and very accurate. It can be pretty slow though if you choose a fine spatial grid. Unless, maybe you can semidiscretise in S to get a ODE that you can solve with ODEI don't know how Matlab handles functions, but why not?

Step over the gap, not into it. Watch the space between platform and train.

http://www.datasimfinancial.com

http://www.datasim.nl

http://www.datasimfinancial.com

http://www.datasim.nl

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: vandervoltI don't know how Matlab handles functions, but why not?No reason why not, should work fine.

- Cuchulainn
**Posts:**62626**Joined:****Location:**Amsterdam-
**Contact:**

QuoteOriginally posted by: HansiQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: vandervoltI don't know how Matlab handles functions, but why not?No reason why not, should work fine.I saw once Matlab binding; so a function diffusion f(S, t) will be converted to a vector function (f1(t), ... fN(t)) where fj(t) = f(jh, t) and h is mesh size in S space. Then assemble all the stuff to y' = F(y,t). At least that's in Bind or Phoenix. Boost.Matlab anyone?Any Matlabbers' comment?

Last edited by Cuchulainn on May 31st, 2010, 10:00 pm, edited 1 time in total.

Step over the gap, not into it. Watch the space between platform and train.

http://www.datasimfinancial.com

http://www.datasim.nl

http://www.datasimfinancial.com

http://www.datasim.nl

Never looked closely into Matlab Toolbox option for creating such a mesh for you automatically as I've always done it explicitly but I'm sure there is something for that.Also just ran across this on google, haven't read through it but it might give insight into what is possible with Matlab in this space:http://www.iaeng.org/publication/WCE200 ... 022.pdfThe semidiscretisation is handled in the following manner for BS and Heston:

performance wise Mathematica and Matlab are on the same plane. you dont implement production software in them. figure out your algorithms in either of them, then implement the prod software in real programming language.

- Cuchulainn
**Posts:**62626**Joined:****Location:**Amsterdam-
**Contact:**

QuoteOriginally posted by: jawabeanperformance wise Mathematica and Matlab are on the same plane. you dont implement production software in them. figure out your algorithms in either of them, then implement the prod software in real programming language.Oi vey!MM and Matlab are real languages. There is more than Java ... And for the record, if you want speed you need a fast language

Last edited by Cuchulainn on May 31st, 2010, 10:00 pm, edited 1 time in total.

Step over the gap, not into it. Watch the space between platform and train.

http://www.datasimfinancial.com

http://www.datasim.nl

http://www.datasimfinancial.com

http://www.datasim.nl

QuoteOriginally posted by: CuchulainnOi vey!MM and Matlab are real languages. There is more than Java ... And for the record, if you want speed you need a fast language "fast" is only one dimension, otherwise we'd all be in ASM. Matlab is not the real language. it's a good scripting language for array processing. i'd say it's a nice tool for rapid prototyping or research, i wrote my thesis almost entirely on Matlab, love it. i dont write prod code in it though. it's too much hassle to support it.

- Cuchulainn
**Posts:**62626**Joined:****Location:**Amsterdam-
**Contact:**

QuoteThe semidiscretisation is handled in the following manner for BS and Heston:function [x,y0,A,u]=get_ode_blackscholes(kind,N,L,r,sigma)%Semidiscretization of Black-Scholes call option PDE% Usage: [x,y0,A,u]=get_ode_blackscholes(kind,N,L,r,sigma)% kind='fd' (finite difference) or 'sc' (spectral collocation)[...]Yes, that's the idea I had. Then you can just translate your SD scheme a mano to ODE Matlab form and off you go. A nice exercise would be to do it from exsiting C++/C# code.

http://www.datasimfinancial.com

http://www.datasim.nl

QuoteOriginally posted by: vandervoltAlan,I think you are correct about the Matlab 2D PDE toolbox (ie not supporting advection/diffusion equation in 2D). So I don' think anyone will give you an answer to your Heston model test case.Yes, agree - I am not holding my breath. p.s. Regarding elliptic problems, we had an interesting thread in the Numerical forum about that.As we also agree, the ones that occur in finance have very simple boundaries, usually rectangular.At first, because Mathematica's NDSolve does not support elliptical problems, I went searching elsewhereto solve a particular problem I was interested in. Found FreeFem++; however this proved disappointing on this problem (see the thread) and I finally ended up simply goingback to Mathematica and setting it up as the stationary limit of a parabolic problem, which NDSolve can handle. Since, as you point out, Matlab apparently does have an FEM toolbox, again disappointing to not seeany Matlab users chime in to that thread with a quick toolbox result. So, here is a second challenge to the Matlab folks. Use the Matlab FEM toolbox to solvethe elliptic problem discussed in the linked thread. It is theultimate hitting probability of the stock price to S=0 in the (beta=0) SABR model.The pde operator, boundary conditions, and exact solution are given in the thread.Post a brief summary of your methods in the Numerical Methods forum.

Last edited by Alan on June 4th, 2010, 10:00 pm, edited 1 time in total.

- Cuchulainn
**Posts:**62626**Joined:****Location:**Amsterdam-
**Contact:**

Another solution is to program an iterative solver for the elliptic PDE directly in Matlab. The FEM route seems to be a bit heavy.Most of the posts on Matlab here tend to centred on debugging lattice model. With the exception of a couple of posters, MM threads are thinly distributed.

http://www.datasimfinancial.com

http://www.datasim.nl

Yes, I am not doubting that you can program solvers directly in Matlab. What I am trying toflesh out is whether or not the Matlab pde toolbox can solve some basic finance pde problems (Heston model, SABR, etc.)

- Cuchulainn
**Posts:**62626**Joined:****Location:**Amsterdam-
**Contact:**

QuoteOriginally posted by: AlanYes, I am not doubting that you can program solvers directly in Matlab. What I am trying toflesh out is whether or not the Matlab pde toolbox can solve some basic finance pde problems (Heston model, SABR, etc.)I had a look, but I suspect not. The 'specials' are not supported? Juergen Topper uses pde2d for 2d/3d baskets. It has a trial version and output to Matlab.Anyways, a bit closer ....

Last edited by Cuchulainn on June 5th, 2010, 10:00 pm, edited 1 time in total.

http://www.datasimfinancial.com

http://www.datasim.nl

QuoteOriginally posted by: CuchulainnWhat about VBA? And this 750 page book by Nick Webber does it step-by-step and is very clear.The price differential in packages can be steep. And VBA works with Excel.Thanks a lot, that book is really going to sort my IT issues in the field neatly. Just preordered.

- Cuchulainn
**Posts:**62626**Joined:****Location:**Amsterdam-
**Contact:**

QuoteOriginally posted by: GiusCoQuoteOriginally posted by: CuchulainnWhat about VBA? And this 750 page book by Nick Webber does it step-by-step and is very clear.The price differential in packages can be steep. And VBA works with Excel.Thanks a lot, that book is really going to sort my IT issues in the field neatly. Just preordered.You're welcome.

http://www.datasimfinancial.com

http://www.datasim.nl

GZIP: On