Branch cut in log or square root

Hi All,
I do have some kind of functions which either have logarithmic or square root functions which cause a branch cut. I solve the question analytically and draw the picture by hand in order to have a confirmation of the matlab figure but even for simple functions matlab sometime provide the wrong plot, which I think occurs due to branch cut. For example, let's say we have the function u=-(x+iy).^(3/2) and want to plot imaginary or real part of its counter picture and I use the very basic following code
syms x y
axis equal
figure(1)
hold on
ezplot('imag(-(x+1i*y).^(3/2))');
% this picture should be three line on positive x axis and 2 pi/3 and 4 pi/3
%but it gives positive x axis and 2 pi/3 and 4 pi/3 and negative x axis
ezplot('real((-4/3)*(x+1i*y).^(3/2))');
%this does not provide the negative x-axis
end
or I use
contourf(x,y,imag(u),1);
or
contourf(x,y,real(u),1);
It does have to draw the negative axis in real parts picture but it does not do it, and there should not be a line along the negative axis for imaginary part pictures but there is. I think these are happening because of the branch cut.
Could somebody please provide me some information or help to avoid the the branch cut or to get the right picture with branch cut.

Answers (1)

In MATLAB -(x+1i*y).^(3/2) is -power(complex(x,y),1.5) which is -exp(1.5 * log(complex(x,y)) .
That in turn is -exp(1.5 *( log(abs(complex(x,y))) + 1i*atan2(y,x) ))
You can expand this further algebraically, and take its imaginary part, but you will find there is no branch cut.
This might differ from what you are expecting, but you have to remember that in MATLAB, fractions are resolved to floating point numbers so it cannot tell that your intention is to talk about square roots of cubes.
See also realpow() and nthroot()
By the way, if you meant 3/2 in the fraction sense, then the imaginary part, using this interpretation, is equivalent to
-(x^2+y^2)^(3/4)*sin((3/2)*arctan(y, x))

5 Comments

Thanks for the answer. I have plotted this function and the similar problem occurred, I will try realpow and nthroot, thanks a lot for your help. I think matlab has a problem defining the Branch cut and take it as one certain line. If I want to plot Imaginary part of above expansion while the real part is positive or negative, does matlab have any code for this? I meant, lets say, I like to plot a contour plot of a complex function, say that is f(z),
Im(f(z)) while Re(f(z))>0
or
Im(f(z)) while Re(f(z))< 0
Thank you
The difficulty is that you have not defined the function in such a way that it has a branch cut. The .^ operator in MATLAB does not have a branch cut, because A.^B is defined in terms of exp(B*log(A)) including when A and B are complex. If that is not what you want then you need to provide a definition of your function that we could then try to find an implementation mechanism for. For example,
syms x y
simplify(imag(-(x+1i*y)^(sym(3)/sym(2))))
Most of my functions are very complicated, the simplest one is this
f(z) = -z.^(3/2)
= -(x+i*y).^(3/2)
As far as I know, this function has a square root branch cut along the negative axis (please correct me if I am mistaken). So If I want to plot its imaginary part while its real part is positive, or while its real part is negative, meanly,
Im(f(z)) while Re(f(z))>0 (*)
What type of command we use? Analytically solving this (*) gives there are two lines one with 2pi/3 and 4 pi/3, but matlab says pi is also satisfies (*) although it is not correct and and that line (pi) is a branch cut. So, if you want to plot imaginary part of any function or above function while its real part is positive, how do you code it or is there any technique to have this type of plotting? Thaank you
No, '.^' is a specific operator in MATLAB that is defined in terms of log, so there is no square root branch cut. If you want the branch cuts then you need to proceed carefully, and it is more ready if you use the Symbolic Toolbox
If you want the n'th branch cut then replace calls to log() with something like
clogn = @(x,n) log(x) + n*2i*pi*(imag(log(x))~=0);
and then call it passing it the branch cut number, such as 0 to replicate the normal log function.

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 9 Oct 2015

Commented:

on 21 Dec 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!