August 6th, 2008, 10:38 am
Hi guys,when implementing the Heston model, or Shobel-Zhu model, a problem is that the complex logarithm has a branch cut. This leads to irregular jumps, as these screenshots from my Matlab implementation show:(1,2,3... on the "pi-axis" are numbers, not multiples of pi, pi=3.14...)Now I spent some time searching for a solution to this. I found various discussions on the board, as well as a few papers, "Why the rotating algorithm works" and "The Little Heston trap" among them, however, I don't really see the solution to the problem. And I'm lost on how to implement the solution into Matlab.I think it all boils down to the wrong handling of the complex log in Matlab. Now let's say I have ln(z) where z is a complex number. What must I do exactly in Matlab to get some representation of ln(z) without the discontinuities?Or more specificly: If I try to calculate f2 from Shobel/Zhu [1999], and use the notation from this paper, then I have at some point C1 = log(dn); where dn is the denominator that is build from ch + g2.*sh;I somehow have to change C1 = log(dn) into a correct reprentation of the log.I tried C1 = log(abs(dn))+i*(abs(dn)+pi*2);as well asC1 = log(abs(dn))+i*angle(dn);but both does not work.I know that this problem has been discussed in a few threads here, so some of you guys must know the fix. Help much appreciated!