[Scilab-users] About the complex inverse tangent function

Pierre Vuillemin contact at pierre-vuillemin.fr
Fri Aug 15 10:52:39 CEST 2014


Le jeudi 14 août 2014 à 19:46 +0200, Samuel Gougeon a écrit :
> Hello,
> 
> Le 14/08/2014 15:12, Pierre Vuillemin a écrit :
> 
> > Hello,
> > 
> > my question concerns the practical implementation of the complex inverse
> > tangent function atan(z) in Scilab.
> > 
> > In the source code of Scilab, the file "watan.f" (in the elementary
> > functions) seems to compute this function as
> > 
> > atan(z) = i/2 log((i+z)/(i-z)),
> > 
> > where i^2=-1.
> > 
> > Yet, when comparing the result given by atan(z) and %i/2*log((%i+z)/(%
> > i-z)) in Scilab, they are different for every point on the imaginary
> > axis excepted in the unit circle. For instance,
> > 
> > z = 2*%i
> > disp([atan(z),%i/2*log((%i+z)/(%i-z))])
> > 
> > -> 1.5707963 + 0.5493061i  - 1.5707963 + 0.5493061i
> With Scilab 5.5.0 on Windows 7 x64:
> -->z = 2*%i
>  z  =
>     2.i  
> -->disp([atan(z),%i/2*log((%i+z)/(%i-z))])
>  
>     1.5707963 + 0.5493061i    1.5707963 + 0.5493061i  
> 

I am on a 64-bit linux environment (Debian Jessie, Scilab 5.5.0), the
result would be OS-dependent?

> This is a strange result for the log expression, since we could expect
> -1.57.. rather than 1.57...
> Indeed, with z = 2.i, we have: (i+z)/(i-z) = 3i/ -i = -3 = 3.i^2 =>
> ln(3.i^2) = ln(3) + 2 ln(i)
> with i = exp(i.pi/2), so : .. = ln(3) + 2.i.pi/2 = ln(3) + i.pi
> Hence: i/2 * ln((i+z)/(i-z)) = i.ln(3)/2 - pi/2 : the real part is <
> 0.
> If there is an issue, it could be with  log() rather than with atan().
> ...
> > I would like to know where does the difference comes from and if
> > 'watan.f' is really the file that computes atan.
> > 
> > The values obtained with the function atan(z) seem to coincide with
> > another definition of atan(z) :
> > 
> > atan(z) = 1/(2i) [log(1+iz)-log(1-iz)]
> > 
> > which is used by Mathematica and the function 'catan' in linux.
> 1/(2i) [log(1+iz)-log(1-iz)] 
>   = -i/2 log((1+iz)/(1-iz)) 
>   = -i/2 log(i(1+iz) / i(1-iz)) 
>   = -i/2 log((i-z)/(i+z)) 
>   =  i/2 log((i+z)/(i-z))
> So, both forms that you mention and that you compare to Scilab result are equivalent.
> 
> HTH
> Samuel
> 

The relation

log(ab) = log(a) + log(b) 

only stands for the multi-valued logarithm function (or modulo pi). With
the principal value of the log, defined as

log(z) = ln(|z|) + i * arg(z)

where -pi<arg(z)<=pi, this is not true as soon as -pi<arg(a)+arg(b)<=
pi. In particular, it is not true on the branch cut (- inf, 0].
For instance,

log(-1) = j pi

log(-1)+log(-1) = 2j pi != log(1) = 0

This is merely a problem of convention in the definitions, but this
leads to differences in the value of the atan on its branch cuts.




> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users





More information about the users mailing list