[R] atan2(1,1i)

Robin Hankin r.hankin at noc.soton.ac.uk
Wed Mar 29 08:58:52 CEST 2006


Hi guys

perhaps my original message wasn't so clear.

My point was that the documentation is inconsistent with the
function.

How to remedy this?

(i) add a line to Trig.Rd along the lines of "atan2() will not work  
if the first argument
is real and the second argument complex"

or
(ii) Modify atan2() so that it coerces the first argument to a  
complex if necessary.


I'd prefer option (ii) but can't see a quick fix.



rksh




On 28 Mar 2006, at 19:52, Jeff Newmiller wrote:

> Robin Hankin wrote:
>> Hi
>>
>> ?atan2 says that atan2(y,x)=atan(y/x) for x and y numeric or complex
>> vectors.
>>
>> Well, I would expect atan2(1,1i) to be equal to atan(-1i), but
>>
>>> atan2(1,1i)
>> Error in atan2(y, x) : Non-numeric argument to mathematical function
>
> Ravi Varadhan pointed out that you need to make both arguments complex
> to address the error message you obtained... but atan2 wasn't  
> originally
> designed for complex arguments. I suspect that what you really want is
> to use the Arg function:
>
>> Arg(1/1i)
> [1] -1.570796
>
> -- 


--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743




More information about the R-help mailing list