Picking Branch Cut of Square Root

47 ビュー (過去 30 日間)
bil
bil 2023 年 5 月 19 日
編集済み: David Goodmanson 2023 年 5 月 20 日
Hey all,
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.
Thanks!

採用された回答

David Goodmanson
David Goodmanson 2023 年 5 月 20 日
編集済み: David Goodmanson 2023 年 5 月 20 日
Hi bil,
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
sqrtbc(0,(a-i)/(a+i))
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
sqrtbc(pi,-4+eps*i) -sqrtbc(pi,-4-eps*i)
ans = 0.0000 + 4.0000i
% demonstrate branch cut along +x axis
sqrtbc(0,4+eps*i) -sqrtbc(0,4-eps*i)
ans = 4
% demonstrate branch cut along +y axis
sqrtbc(pi/2,4i+eps) -sqrtbc(pi/2,4i-eps)
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)
if theta==0
phi = pi;
else
phi = theta -pi*sign(theta);
end
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by