Complex log branch cuts
8 views (last 30 days)
Show older comments
Hello,
Summary: I am having some trouble figuring out the branch cuts Matlab uses for complex logarithms and arctangents. If possible, I would like to be able to redefine the cut.
Motivation: I want to reproduce the code in a piece of literature and it would be hard to re-derive all equations based on a different branch cut. The paper begins with a function in the real plane and then rewrites the equation in the complex plane for additional work. The functions h1, h2 in the code below are the "right" answer from the real plane. The complex function should be such that h = h1+1i*h2.
Original Code:
% Variable setup
H = 0.5;
x = linspace(-5, 5, 32);
z = logspace(log10(0.01), log10(3), 128);
[X,Z] = meshgrid(x,z);
s = X+1i*Z;
% Real and complex functions as given in paper
h1 = @(x,z) z.*log(x.^2+z.^2) - 2*x.*atan(x./z);
h2 = @(x,z) -x.*log(x.^2+z.^2) - 2*z.*atan(x./z);
h = @(s) -2*1i*s.*log(s) - pi*s;
%Plotting for comparison
figure()
subplot(2,2,1)
surf(X,Z, h1(X,Z-H), 'EdgeColor', 'none')
subplot(2,2,2)
surf(X,Z, real(h(s-1i*H)),'EdgeColor', 'none')
subplot(2,2,3)
surf(X,Z, h2(X,Z-H),'EdgeColor', 'none')
subplot(2,2,4)
surf(X,Z, imag(h(s-1i*H)),'EdgeColor', 'none')
Stepping through the simplification of h, these functions match h1, h2 as appropriate:
h = @(s) 1i*s.*log(-s.^(-2));
h = @(s) 1i*s.*(log((s*1i).^(-2)));
These functions do not:
h = @(s) 1i*s.*(log(s.^(-2))+log(-1));
h = @(s) -2*1i*s.*log(s*1i);
So the definition used by Matlab for the principle value for complex logarithms appears to be such that log(xy) ~= log(x) + log(y) and log(x^y) ~= y log(x). Is there some way around this?
Thank you!
Best, A.Craig
1 Comment
murat kara
on 16 Dec 2015
Hi, I am having the similar problem on my plots due to the logarithmic branch cut. Did you have a chance to figure out or find out a way to get rid of the problem caused by the b. cut. My plots appear to strange near/around the branch cut. So, if you have a method, would you mind sharing it or suggest a way to me?
thank you
Answers (1)
See Also
Categories
Find more on Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!