Serving the Quantitative Finance Community

 
User avatar
Edgey
Topic Author
Posts: 14
Joined: March 23rd, 2005, 11:01 am

Numerical differentiation of a complex function.

January 6th, 2012, 2:07 pm

I have a complex function and I wish to find its derivatives at arbitrary points in the complex plane. Are there more efficient approaches than the usual finite difference algorithms? Analytically, using a complex stepsize makes no difference (presuming the function is differentiable). Does it make any difference numerically?Are there methods for higher order derivatives where the function evaluations are not along the same re/im line?Thanks
Last edited by Edgey on January 5th, 2012, 11:00 pm, edited 1 time in total.
 
User avatar
frenchX
Posts: 11
Joined: March 29th, 2010, 6:54 pm

Numerical differentiation of a complex function.

January 6th, 2012, 2:48 pm

Just a question your function is analytic or not ? It may help to know it.
Last edited by frenchX on January 5th, 2012, 11:00 pm, edited 1 time in total.
 
User avatar
Edgey
Topic Author
Posts: 14
Joined: March 23rd, 2005, 11:01 am

Numerical differentiation of a complex function.

January 6th, 2012, 3:27 pm

I meant to say it could be any complex function. Assume it is not analytical (hence the reason for numerical methods) but I'll use an analytical one for testing.
 
User avatar
FinancialAlex
Posts: 1
Joined: April 11th, 2005, 10:34 pm

Numerical differentiation of a complex function.

January 6th, 2012, 8:56 pm

QuoteDoes it make any difference numerically?Yes, it does. See discussion on CSDA in paper
 
User avatar
Alan
Posts: 2958
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

Numerical differentiation of a complex function.

January 6th, 2012, 9:25 pm

If df/dz exists at some point z0, then f(z) is analytic in some neighborhood of z0. Suppose C is any closed curve in that neighborhood,enclosing z0. The curve might be quite far from z0. Then, an interesting thing about analytic functions is that you could get thederivative by doing an integration which only uses the values of the function _away_ from the point of interest:For example, you could integrate around a square surrounding z_0.Or, if the function falls off fast enough, you could integrate along the entire real axis, since the contribution from the rest of contour will vanish.Efficient way to get the derivative? Not at all -- just interesting
Last edited by Alan on January 5th, 2012, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Numerical differentiation of a complex function.

January 7th, 2012, 9:12 am

This article (and the reference to the work of Lyness and Moler) deals with the problem http://citeseerx.ist.psu.edu/viewdoc/su ... eEfficient way to get the derivative? Not at all -- just interesting The above article uses Taylor expansions, so it would seem that the approach can be used. It would seem that ND for real-valued functions is ill-conditioned while in complex case it is well-conditioned.The classic by Peter Henrici might also be useful
Last edited by Cuchulainn on January 6th, 2012, 11:00 pm, edited 1 time in total.
 
User avatar
Edgey
Topic Author
Posts: 14
Joined: March 23rd, 2005, 11:01 am

Numerical differentiation of a complex function.

January 7th, 2012, 2:14 pm

This is bringing back distant memories of complex analysis and numerical methods lectures. All good leads to follow. Thanks guys.
 
User avatar
mj
Posts: 12
Joined: December 20th, 2001, 12:32 pm

Numerical differentiation of a complex function.

January 8th, 2012, 8:31 pm

have you considered automatic differentiation? see eg http://ssrn.com/abstract=1828503I've also got a chapter on it in More Mathematical FInance.
 
User avatar
Edgey
Topic Author
Posts: 14
Joined: March 23rd, 2005, 11:01 am

Numerical differentiation of a complex function.

January 8th, 2012, 10:26 pm

I've had a look at AD. Interesting idea, but it seems to only do the 1st derivative. Not sure the chain rule applies to 2nd derivatives and higher. Also I've noticed that the complex step approach doesn't work if the derivative is complex (i.e. characteristic functions), or am I incorrect? I may just fall back to finite difference, as it works in all circumstances.
 
User avatar
mj
Posts: 12
Joined: December 20th, 2001, 12:32 pm

Numerical differentiation of a complex function.

January 8th, 2012, 10:46 pm

you can use AD for higher orders:http://ssrn.com/abstract=1626547
 
User avatar
AVt
Posts: 90
Joined: December 29th, 2001, 8:23 pm

Numerical differentiation of a complex function.

January 11th, 2012, 8:00 pm

Still not clear, whether you want the complex derivative of a holomorphic functionor whether you are asking for function to R^2 (see FrenchX).One can use complex step for the former case - as far as one has an *analytic*decomposition fct = realPart + imaginaryPart*I. But that is *not* given by thesimple use of Real(fct), that is not analytic (this way one can not extend tothe Complex domain to have a Taylor Series, which is what the method needs, orsimply: one must provide a Complexification).For the Cauchy formula: that is not off, for hypergeometric functions it may bea must and for higher derivatives it may be not so much more expensive then theusual finite differences.
 
User avatar
Edgey
Topic Author
Posts: 14
Joined: March 23rd, 2005, 11:01 am

Numerical differentiation of a complex function.

January 12th, 2012, 11:08 am

One example application is deriving, numerically, the cumulants from a Characteristic function.
 
User avatar
AVt
Posts: 90
Joined: December 29th, 2001, 8:23 pm

Numerical differentiation of a complex function.

January 13th, 2012, 7:21 pm

And why is that a complex problem? Look at http://en.wikipedia.org/wiki/Cumulant: up to scaling you want the Taylorcoefficients of log(M(t)), M(t) = E(exp(t*x) = phi(-t*x), which is the integralof exp(t*x)*f(x) over the Reals and f = probability density function, 0 <= f.Hence M(t) is positive and its log is real, no?
 
User avatar
Edgey
Topic Author
Posts: 14
Joined: March 23rd, 2005, 11:01 am

Numerical differentiation of a complex function.

January 13th, 2012, 10:30 pm

Using moment generating functions, yes it is all real. But the Characteristic function is complex. It is preferable to MGFs because the derivatives are more likely to exist and it has close ties with the Fourier transform. I'm only choosing this example because it is familiar. My question can be applied to any holomorphic complex function. The problem I have is how to choose the step size as it can be complex. The modulus of the stepsize probably still controls the precision, but how do I choose the argument? Do I calculate multiple arguments? Do I then take an average? Do I exclude the outliers? Basically, how do I use this extra degree of freedom?