[Scilab-users] About the complex inverse tangent function

Samuel Gougeon sgougeon at free.fr
Thu Aug 14 19:46:58 CEST 2014


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

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20140814/b3d9f8c8/attachment.htm>


More information about the users mailing list