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 > R.version _ platform powerpc-apple-darwin8.5.0 arch powerpc os darwin8.5.0 system powerpc, darwin8.5.0 status alpha major 2 minor 3.0 year 2006 month 03 day 27 svn rev 37590 language R version.string Version 2.3.0 alpha (2006-03-27 r37590) > -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743
Try this:> atan2(1+0i,1i)[1] NaN-Infi Ravi.> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch [mailto:r-help- > bounces at stat.math.ethz.ch] On Behalf Of Robin Hankin > Sent: Tuesday, March 28, 2006 9:13 AM > To: RHelp > Subject: [R] atan2(1,1i) > > 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 > > R.version > _ > platform powerpc-apple-darwin8.5.0 > arch powerpc > os darwin8.5.0 > system powerpc, darwin8.5.0 > status alpha > major 2 > minor 3.0 > year 2006 > month 03 > day 27 > svn rev 37590 > language R > version.string Version 2.3.0 alpha (2006-03-27 r37590) > > > > > > > -- > Robin Hankin > Uncertainty Analyst > National Oceanography Centre, Southampton > European Way, Southampton SO14 3ZH, UK > tel 023-8059-7743 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting- > guide.html
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 functionRavi 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 -- --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k