Picking Branch Cut of Square Root
23 visualizzazioni (ultimi 30 giorni)
I just wanted to know if there was a way of making matlab pick a different branch cut for the square root. Consider the following function:
When we evaluate , we get , which tells me that Matlab chooses the branch cut along the negative real axis in the complex plane. This then means that if I pick a very small a, and evaluate, say, , I get . The problem now is that I want the function f to be continuous in a where the expression will cross the negative real axis. One way to resolve this is to make it so that the branch cut is located along the positive real axis instead. I would like to know how to implement this in Matlab if possible.
David Goodmanson il 20 Mag 2023
Modificato: David Goodmanson il 20 Mag 2023
Here is a function that does that job. It appears that you want to do the division (a-i)/(a+i) before taking the square root. To put the branch cut on the +x axis, use
It's also possible to do sqrt(a-i) / sqrt(a+i) in which case the function below can send the <branch cut from the brance point at i> and the <branch cut from the branch point at -i> in two different directions if needed.
eps = 1e-10;
% demonstrate branch cut along -x axis
ans = 0.0000 + 4.0000i
% demonstrate branch cut along +x axis
ans = 4
% demonstrate branch cut along +y axis
ans = 2.8284 + 2.8284i
function y = sqrtbc(theta,zarg)
% sqrt function with branch cut in zarg from 0 to infinity along a ray
% at angle theta (in radians) measured from the +x axis in the usual way,
% with -pi<=theta<=pi. theta = pi is the usual square root.
% for zarg on the +x axis, sqrt behavior is conserved,
% i.e. sqrtbc(theta,zarg) is positive and real for any theta.
% y = sqrtbc(theta,zarg)
phi = pi;
phi = theta -pi*sign(theta);
y = exp(i*phi/2)*sqrt(zarg*exp(-i*phi));
% translations: sqrtbc(theta, z-b) has branch cut in the z plane from
% branch point z = b out to infinity, along a ray at angle theta.
% for the usual square root with branch cut along -x,
% the real part of sqrt(z) is positive (or 0) for all z.
% for the modified square root with branch cut along +x,
% the imaginary part of sqrt(z) is positive (or 0) for all z.