Does MATLAB considers poles while COMPLEX integrating a function?

6 次查看(过去 30 天)
For example , suppose i want to integrate F(z)=1/(1-z^n) where n is any natural number and z is a complex variable. Now integrating simply
syms z
syms n integer
F=int(1/(1-z^n),z)
F = 
This gives us answer in hypergeometric functions. But i want to know does this integration considers poles, as F(z) has a singularity,i.e, pole at z=1 and at nth roots of unity. so, does it consider that?
If not, how can we make it consider that?

采纳的回答

David Goodmanson
David Goodmanson 2023-10-11
编辑:David Goodmanson 2023-10-11
Hi simran,
Yes, the 2F1 expression does consider the pole, as you can see by the fact that the expression gets large as z appoaches 1 from below. I am going to consider 1/(z^n-1) rather than 1/(1-z^n) since it's easier to keep track of the nth roots of unity on the unit circle. It's easy enough to multiply the solution by -1 after the calculations are done. Also, n is odd here..
The solution for |z| < 1 is found by expanding the denominator in powers of z and integrating term by term, as mentioned by Torsten. I'm kind of surprised that syms got that far, but it's helpful. For |z| >1 you can expand z^(-n)/(1-z^(-n)) and do the same thing. This results in
y = -z*2F1(1,1/n;1+1/n,z^n) |z| < 1
y = z*(2F1(1,-1/n;1-1/n,z^(-n)) -1) |z| > 1
Here y(0) = 0, y(z) -> 0 as z-> +-inf and since the integral from -inf to inf is nonzero, constants of integration have to be added to these solutions to make them match up. syms does not seem to be capable of doing definite integrals in this case, but calculations using the log expression (see below) give
n = 5;
% some definite integrals
% Int(-inf,inf) 1/(z^n-1) = -C
% Int(-inf,0) 1/(z^n-1) = -D
% Int(0,inf) 1/(z^n-1) = -E
a = exp(2*pi*i/n); % poles at z=a^m, for 0<m<n-1 pole at z=1, no pole at z=-1
sqa = sqrt(a);
% use real to eliminate very small nuisance imag values
C = real( (-i*pi/n)*(1+sqa)/(1-sqa) ) % >0
D = real( (-2*i*pi/n)*sqa/(1-a) ) % >0
E = real( (-i*pi/n)*(1+a)/(1-a) ) % >0
% calculate and plot
z1 = -10:.01:-1;
z2 = -1:.01:.99;
z3 = 1.01:.01:10;
H1 = z1.*(hypergeom([1 -1/n],1-1/n,z1.^(-n))-1);
H2 = -z2.*hypergeom([1 1/n],1+1/n,z2.^n);
H3 = z3.*(hypergeom([1 -1/n],1-1/n,z3.^(-n))-1);
H1 = H1 - H1(end) + H2(1); % match at z = -1
H3 = H3 - E; % effectively match at z = inf
figure(1)
plot(z1,H1,z2,H2,z3,H3)
grid on
You can see the effect of the pole at z = 1. The pole can be integrated across by using the so-called principal value (which is how E was determined).
The 2F1 function that syms came up with was pretty good, but a more useful expression is
1/(z^n-1) = (1/n) Sum{0,n-1} a^m/(z-a^m)
and integrating this gives the indefinite integral
y = Int 1/(z^n-1) = (1/n) Sum{0,n-1} a^m log(z-a^m)
since log(p*q) = log(p) + log(q), the argument of each log term can be divided by -a^m and the only consequence is introduction of some constants of integration. This results in
y = Int 1/(z^n-1) = (1/n) Sum{0,n-1} a^m log(1-z/a^m)
which equals 0 at z=0, just as the 2F1 expression does. Now this has to be modifed for the m=0 (pole at z = a^0 = 1) term to use the principal value, log(|1-z|) instead of log(1-z):
y = Int 1/(z^n-1) = (1/n) Sum{1,n-1} a^m log(1-z/a^m) + (1/n) log(|1-z|)
and the function can be calculated in one go, rather than piecewise.
mm = (1:n-1)';
z4 = [z1 z2 z3];
[z m] = meshgrid(z4,mm);
% again remove small nuisance imag
A4 = real((1/n)*(sum(a.^m.*log(1-z./a.^m)))) + (1/n)*log(abs(1-z4));
A plot of z4,A4 is identical to the one above.

更多回答(1 个)

Torsten
Torsten 2023-9-7
编辑:Torsten 2023-9-7
How should it consider it if you ask MATLAB for an antiderivative to a function ? Should it additionally list the poles ?
An antiderivative to f(x) = 1/x^2 , e.g., is F(x) = -1/x. That's all.
If you try to evaluate definite integrals, you can define Waypoints to circumvent poles:
  12 个评论
Torsten
Torsten 2023-9-7
编辑:Torsten 2023-9-7
Also, do you know any other methods for solving these kind of integrations? if the MATLAB doesn't solve it with the "int" command.
Why do you write it doesn't solve it with the int-command ? It's just a different representation of the antiderivative (maybe up to a constant of integration).
Bruno Luong
Bruno Luong 2023-9-7
编辑:Bruno Luong 2023-9-7
When you integrate fractions in complex plane on the path, the only term that you need to pay attention is -1 power term:
1/(z-pole)
since the primitive (anti-derivative) is log(z-zpole) and as mathematical log is multi-values function and MATLAB log is mono-value function with discontinuity at the half axis Rel(z) <= 0, you must add k(z)*2*pi whenever it crossthe semi real axis z <= 0 so that the primitive is continue along the path.
All the other terms (with power negative or positive) do not have this problem, the difference of the primitive at the end to the start is alright.
No symbolic system can tell you what is k(z) to add since you haven't specify the path.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by