where the jump of the phase function happen?
Mostra commenti meno recenti
I know that (if Iam correct), phase(f(z)) =arctan(f(z)) ,(where f(z) is complex number ) is multivalued function, that means for example if arctan(f(z))= x, there is infinite number of angles (x) has the same tan value = the value f(z). So if we want to make arctan continuous we have to ristrect the rang of this function in this interval (-pi/2 pi/2). where z=x+iy
My questions are:
1- How can I determined the points where the jump happen? are they when the real part of complex number=0?(but phase =arcta(y/x)= arctan (y/0) =pi/2)
2-why when I plotted the phase of the function f(z) in this interval (-pi/2 pi/2) , I still have the same jump which appear as discontinuity of the phase of the function f(z)?

I use this code
re_z = -pi/2:0.01:pi/2;
im_z = -pi/2:0.01:pi/2;
[re_z,im_z] = meshgrid(re_z,im_z);
z = re_z + 1i*im_z;
f_of_z_result = polyval(p,z);
figure();
subplot(2,2,1)
surf(re_z,im_z,angle(f_of_z_result),'EdgeColor','none')
colorbar
title('phase(f_k(z))')
xlabel('Z_R')
ylabel('Z_I')
I appreciate any help
1 Commento
Star Strider
il 6 Set 2022
Risposta accettata
Più risposte (1)
Bruno Luong
il 6 Set 2022
Modificato: Bruno Luong
il 6 Set 2022
0 voti
angle(z) is discontinue at the half line { y=0; x<=0, z=x+1i*y }.
The phase jumps from -pi for imaginary part y < 0 to +pi for y > 0. To make thing more complicated for y=0 in IEEE754 it can take the "IEEE-sign" of either +1 or -1, and the angle(z) returns +/-pi depending of the IEEE-sign of y (which is 0 mathematically).
In your case you have to determine when polyval(p,z)* is real and negative, which will implies angle discontinuity.
(*) you didn't tell us what is p.
20 Commenti
Torsten
il 6 Set 2022
@Aisha Mohamed comment moved here:
Sorry, this is the function.
the function f(z)= (-0.1540 + 0.2600i)+ ( 0.4347 + 0.0914i)z+( 0.7756 - 0.4566i)z^2.
which I wrote it in MATLAB as ,
p=[ ( 0.7756 - 0.4566i) ( 0.4347 + 0.0914i) (-0.1540 + 0.2600i) ];
1-What did you mean by the "IEEE-sign" please?
2-why the angle(z) is discontinue at the half line { y=0; x<=0, z=x+1i*y }.? can I say that:
On this half line phase =arctan(0/-x) =0
and phase =arctan(0/0) = undefine.
3 -Also could you please how can I determine when polyval(p,z)* is real and negative?
I appreciate your efforts
1-What did you mean by the "IEEE-sign" please?
Illustration, the function getsgnbit returns IEEE-sign of x
getsgnbit=@(x)bitshift(typecast(x,'uint64'),-63);
zerop=1/inf,
zerom=1/-inf,
getsgnbit(zerop)
getsgnbit(zerom) % different than getsgnbit(zerop)
zp=complex(-1,zerop)
zm=complex(-1,zerom)
zp==zm
angle(zp) % pi angle
angle(zm) % -pi angle
2-why the angle(z) is discontinue at the half line { y=0; x<=0, z=x+1i*y }.? can I say that:
On this half line phase =arctan(0/-x) =0
and phase =arctan(0/0) = undefine.
No: angle(z) is equivalent to atan2(imag(z),real(z))
3 -Also could you please how can I determine when polyval(p,z)* is real and negative?
p is is second degree polynomial so you should be able to solve
polyval(p,z) = x
for x that is real and x < 0, it must hacve 2 solutions z according to the fundamental algebra theorem. I believe that is why there are 2 lines with doscontinuity in your angle surface plot.
Aisha Mohamed
il 7 Set 2022
Bruno Luong
il 7 Set 2022
Modificato: Bruno Luong
il 7 Set 2022
"Is this the explenation of what Bruno Luong said that ((angle(z) is discontinuies at the half line { y=0; x<=0, z=x+1i*y }.))."
No explanation other than this demi-line is the place what the angle() (from atan2) is discontinuous by convention.This convention is adopted by MATLAB and mmany other software and mathematics community that's all. Just like people agree sqrt(2) is 1.1414 and not -1.1414, the electron charge is negative, etc....
"is that mean there is another jump in x>0?"
No, I keep saying the same thing over and over : because your polynomial p(z) has two solutions of p(z)=x with x real and negative. So angle(p(z)) is discontnue at two "places", both correposonds to p(z) real and negative.
Does this coincide with the jumps in angle(f(z)) ?
syms z x
p = (-0.1540 + 0.2600*1i)+ ( 0.4347 + 0.0914*1i)*z+( 0.7756 - 0.4566*1i)*z.^2;
assume(x,'real')
ps = p - x;
sol = solve(ps==0,z);
rsol1 = matlabFunction(real(sol(1)));
isol1 = matlabFunction(imag(sol(1)));
rsol2 = matlabFunction(real(sol(2)));
isol2 = matlabFunction(imag(sol(2)));
x = -10:0.1:0;
hold on
plot(rsol1(x),isol1(x),'o')
plot(rsol2(x),isol2(x),'x')
hold off
Bruno Luong
il 7 Set 2022
Modificato: Bruno Luong
il 7 Set 2022
@Torsen, of course, better view and enlarge domain.
NOTE: The phase surface does look like what @Aisha Mohamed plots so his information is not consistent.
p=[ ( 0.7756 - 0.4566i) ( 0.4347 + 0.0914i) (-0.1540 + 0.2600i) ];
x = linspace(-100,0,513);
a = p(1); b = p(2); c = p(3)-x;
% who recalls this formula?
delta = b^2-4*a*c;
z1 = (-b+sqrt(delta))/(2*a);
z2 = (-b-sqrt(delta))/(2*a);
% Group them as single complex curve
zjump = [z1, NaN, z2];
zjr = real(zjump);
zji = imag(zjump);
% Graphic
x=linspace(min(zjr),max(zjr));
y=linspace(min(zji),max(zji));
[X,Y]=meshgrid(x,y);
Z=X+1i*Y;
close all
surf(x,y,angle(polyval(p,Z)))
hold on
zlo = -5; % jut below -pî, the lowest possible value of phase
plot3(zjr, zji, zlo*ones(size(zjr)), 'k', 'linewidth',2)
Aisha Mohamed
il 11 Set 2022
Modificato: Torsten
il 11 Set 2022
Aisha Mohamed
il 12 Set 2022
Bruno Luong
il 12 Set 2022
Modificato: Bruno Luong
il 12 Set 2022
Nothing meaningful in z=-5 beside making visible graphic; I just plot the curves of phase discontinuity at arbitrary chosen z=-5 since it is just below the phase values which is (-pi,pi).
Bruno Luong
il 12 Set 2022
Modificato: Bruno Luong
il 12 Set 2022
I also modify my code to avoid switching branches (the diagonal line):
p=[ ( 0.7756 - 0.4566i) ( 0.4347 + 0.0914i) (-0.1540 + 0.2600i) ];
x = linspace(-100,0,513);
a = p(1); b = p(2); c = p(3)-x;
% who recalls this formula?
delta = b^2-4*a*c;
z = (-b + [-1;1].*sqrt(delta))/(2*a);
% reorder the points so that each row contain the same "branch" of solution
cu = max(abs(z(:)));
extrapn = 2;
for j=2:size(z,2)
% prediction by fitting a polynomaial on old data
kp = max(j-extrapn,1):j;
zp = z(:,kp);
m = size(zp,2)-1;
order = m-1;
for i=1:size(zp,1)
Pi = polyfit(1:m, zp(i,1:m), order);
zp(i,end) = polyval(Pi,m+1);
end
M = matchpairs(abs(zp(:,end)-z(:,j).'),cu);
M = sortrows(M,2);
pj = M(:,1);
z(:,j) = z(pj,j);
end
z1 = z(1,:);
z2 = z(2,:);
% Group them as single complex curve
zjump = [z1, NaN, z2];
zjr = real(zjump);
zji = imag(zjump);
% Graphic
x=linspace(min(zjr),max(zjr));
y=linspace(min(zji),max(zji));
[X,Y]=meshgrid(x,y);
Z=X+1i*Y;
close all
surf(x,y,angle(polyval(p,Z)))
hold on
zlo = -5; % just below -pî, the lowest possible value of phase
plot3(zjr, zji, zlo*ones(size(zjr)), 'r', 'linewidth',2)
Bruno Luong
il 12 Set 2022
Modificato: Bruno Luong
il 12 Set 2022
Here is the code for p(z) of polynomial of order > 2
clear
%p=[ ( 0.7756 - 0.4566i) ( 0.4347 + 0.0914i) (-0.1540 + 0.2600i) ];
p = rand(1,7) + 1i*rand(1,7);
x = linspace(-100,0,513);
% Solve p(z) = x
npnts = length(x);
z = zeros(length(p)-1,npnts);
for k = 1:npnts
pk = p;
pk(end) = pk(end)-x(k);
z(:,k) = roots(pk);
end
% reorder the points so that each row contain the same "branch" of solution
cu = max(abs(z(:)));
extrapn = 5; % how many points used to predict the next point in a branch
for j=2:npnts
% prediction by fitting a polynomaial on old data
kp = max(j-extrapn,1):j-1;
m = size(kp,2);
% Build Vandermonde matrix: Vj = ((0:m-1)'/m).^(0:m-1);
v = (0:m-1)'/m;
Vj = zeros(m);
vp = 1;
Vj(:,1) = vp;
for k=2:m
vp = vp.*v;
Vj(:,k) = vp;
end
zp = sum(Vj \ z(:,kp).',1);
M = matchpairs(abs(zp-z(:,j)),cu);
M = sortrows(M,2);
pj = M(:,1);
z(:,j) = z(pj,j);
end
% Group them as single complex curve
z(:,end+1) = NaN;
zjump = reshape(z.', 1, []);
zjr = real(zjump);
zji = imag(zjump);
% Graphic
x=linspace(min(zjr),max(zjr));
y=linspace(min(zji),max(zji));
[X,Y]=meshgrid(x,y);
Z=X+1i*Y;
close all
surf(x,y,angle(polyval(p,Z)))
hold on
zlo = -10; % just below -pî, the lowest possible value of phase
plot3(zjr, zji, zlo*ones(size(zjr)), 'r', 'linewidth',2);

Aisha Mohamed
il 12 Set 2022
Aisha Mohamed
il 12 Set 2022
Bruno Luong
il 12 Set 2022
Modificato: Bruno Luong
il 12 Set 2022
You need R2019a or later and possibly ythe toolbox required https://fr.mathworks.com/help/matlab/ref/matchpairs.html
There are some file on File-exchange, keywords are Munkres, Hungarian Assignment
Aisha Mohamed
il 12 Set 2022
Bruno Luong
il 12 Set 2022
Modificato: Bruno Luong
il 13 Set 2022
One more simplification. The extrapolation can be computed with Pascal's triangle without using Vandermond matrix.
p = rand(1,7) + 1i*rand(1,7);
x = linspace(-100,0,513);
% Solve p(z) = x
npnts = length(x);
z = zeros(length(p)-1,npnts);
for k = 1:npnts
pk = p;
pk(end) = pk(end)-x(k);
z(:,k) = roots(pk);
end
% reorder the points so that each row contain the same "branch" of solution
cu = max(abs(z(:)));
extrapn = 5; % how many points used to predict the next point in a branch
Pascal = pascal(extrapn+1,1);
for j=2:npnts
% prediction by fitting a polynomaial on old data
if j <= extrapn+1
a = -Pascal(j,j:-1:2).';
end
zp = z(:,max(j-extrapn,1):j-1)*a;
% find permutation to match the prediction
M = matchpairs(abs(zp.'-z(:,j)),cu);
M = sortrows(M,2);
z(:,j) = z(M(:,1),j);
end
% Group them as single complex curve
z(:,end+1) = NaN;
zjump = reshape(z.', 1, []);
zjr = real(zjump);
zji = imag(zjump);
% Graphic
x=linspace(min(zjr),max(zjr));
y=linspace(min(zji),max(zji));
[X,Y]=meshgrid(x,y);
Z=X+1i*Y;
close all
surf(x,y,angle(polyval(p,Z)))
hold on
zlo = -10; % just below -pî, the lowest possible value of phase
plot3(zjr, zji, zlo*ones(size(zjr)), 'r', 'linewidth',2);

Aisha Mohamed
il 7 Apr 2023
You took the extreme case x = 0 for the two points you selected. If you restrict yourself to the values of z for which p(z) is real and < 0 instead of <= 0, it works out fine.
syms z x
p = (-0.1540 + 0.2600*1i)+ ( 0.4347 + 0.0914*1i)*z+( 0.7756 - 0.4566*1i)*z.^2;
assume(x,'real')
ps = p - x;
sol = solve(ps==0,z);
rsol1 = matlabFunction(real(sol(1)));
isol1 = matlabFunction(imag(sol(1)));
rsol2 = matlabFunction(real(sol(2)));
isol2 = matlabFunction(imag(sol(2)));
format long
x = 0;
z1 = rsol1(x) + 1i*isol1(x);
z2 = rsol2(x) + 1i*isol2(x);
double(angle(subs(p,z,z1)))
double(angle(subs(p,z,z2)))
x = -1e-8;
z1 = rsol1(x) + 1i*isol1(x);
z2 = rsol2(x) + 1i*isol2(x);
disp(pi)
double(angle(subs(p,z,z1)))
double(angle(subs(p,z,z2)))
Aisha Mohamed
il 10 Apr 2023
Categorie
Scopri di più su Data Distribution Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!








