Displaying 20 results from an estimated 2000 matches similar to: "atan2(1,1i)"
2006 Mar 28
1
Help understanding behavior of apply vs sapply
Hi,
I was surprised that apply and sapply don't return the same results in
the example below. Can someone tell me what I'm missing?
> zls <- function(x) character(0)
> m <- matrix(0, nrow=2, ncol=2)
> apply(m, 1, zls)
character(0)
> sapply(m, zls)
[[1]]
character(0)
[[2]]
character(0)
[[3]]
character(0)
[[4]]
character(0)
> R.version
_
2005 Apr 14
1
Strange behavior of atan2
Dear all,
I've got a problem with the function atan2. For a couple of coordinates
x and y,
This function returns the angle between the vector of coordinates (x, y)
and the
abscissa axis, i.e. it is the same as atan(y/x) (as indicated on the
help page).
If we consider the vector with coordinates x = 0 and y = 0, we have
the following result:
> atan(0/0)
[1] NaN
This is expected.
2024 Sep 05
2
BUG: atan(1i) / 5 = NaN+Infi ?
atan(1i) -> 0 + Inf i
complex(1/5) -> 0.2 + 0i
atan(1i) -> (0 + Inf i) * (0.2 + 0i)
-> 0*0.2 + 0*0i + Inf i * 0.2 + Inf i * 0i
infinity times zero is undefined
-> 0 + 0i + Inf i + NaN * i^2
-> 0 + 0i + Inf i - NaN
-> NaN + Inf i
I am not sure how complex arithmetic could arrive at another answer.
I advise against messing with infinities... use atan2() if you don't
2024 Sep 05
1
BUG: atan(1i) / 5 = NaN+Infi ?
> complex(real = 0, imaginary = Inf)
[1] 0+Infi
> Inf*1i
[1] NaN+Infi
>> complex(real = 0, imaginary = Inf)/5
[1] NaN+Infi
See the Note in ?complex for the explanation, I think. Duncan can correct
if I'm wrong.
-- Bert
On Thu, Sep 5, 2024 at 3:20?PM Leo Mada <leo.mada at syonic.eu> wrote:
> Dear Bert,
>
> These behave like real divisions/multiplications:
>
2024 Sep 06
1
BUG: atan(1i) / 5 = NaN+Infi ?
The thing is that real*complex, complex*real, and complex/real are not
"complex arithmetic"
in the requisite sense. The complex numbers are a vector space over
the reals, and
complex*real and real*complex are vector*scalar and scalar*vector.
For example, in the Ada programming language, we have
function "*" (Left, Right : Complex) return Complex;
function "*" (Left :
2024 Sep 06
1
BUG: atan(1i) / 5 = NaN+Infi ?
>>>>> Richard O'Keefe
>>>>> on Fri, 6 Sep 2024 17:24:07 +1200 writes:
> The thing is that real*complex, complex*real, and complex/real are not
> "complex arithmetic" in the requisite sense.
> The complex numbers are a vector space over the reals,
Yes, but they _also_ are field (and as others have argued mathematically only
2007 Nov 27
3
[LLVMdev] Other Intrinsics?
> > Do you have plans to add other intrinsics? I'm curious as to why there
> > is an llvm.sin intrinsic and an llvm.cos intrinsic, but no llvm.atan
> > intrinsic. Why is there an llvm.pow intrinsic but no llvm.log
> > intrinsic?
>
> Intrinsics get added on demand. Generally there has to be a good reason
> to add them. llvm.sin was implemented (for
2024 Sep 06
1
BUG: atan(1i) / 5 = NaN+Infi ?
G.5.1 para 2 can be found in the C17 standard -- I actually have the
final draft not the published standard. It's in earlier standards, I
just didn't check earlier standards. Complex arithmetic was not in
the first C standard (C89) but was in C99.
The complex numbers do indeed form a field, and Z*W invokes an
operation in that field when Z and W are both complex numbers. Z*R
and R*Z,
2005 May 16
1
branch cuts of atan()
Hi
the following gave me a shock:
> atan(2)
[1] 1.107149
> atan(2+0i)
[1] -0.4636476+0i
>
or, perhaps more of a gotcha:
> atan(1.0001+0i)
[1] -0.7853482+0i
> atan(0.9999+0i)
[1] 0.7853482+0i
>
evidently atan()'s branch cuts aren't where I thought they were.
Where do I look for documentation on this?
--
Robin Hankin
Uncertainty Analyst
National
2024 Sep 05
3
BUG: atan(1i) / 5 = NaN+Infi ?
On 2024-09-05 4:23 p.m., Leo Mada via R-help wrote:
> Dear R Users,
>
> Is this desired behaviour?
> I presume it's a bug.
>
> atan(1i)
> # 0+Infi
>
> tan(atan(1i))
> # 0+1i
>
> atan(1i) / 5
> # NaN+Infi
There's no need to involve atan() and tan() in this:
> (0+Inf*1i)/5
[1] NaN+Infi
Why do you think this is a bug?
Duncan Murdoch
2024 Sep 06
1
BUG: atan(1i) / 5 = NaN+Infi ?
I expect that atan(1i) = (0 + infinity i) and that atan(1i)/5 = (0 +
infinity i)/5 = (0 + infinity i).
Here's what I get in C:
(0,1) = (0, 1)
atan((0,1)) = (0, inf)
atan((0,1))/5 = (0, inf)
Note the difference between I*infinity = (0,1)*infinity =
(0*infinity,1*infinity) = (NaN,infinity)
and (0,infinity)/5 = (0/5,infinity/5) = (0,infinity).
The former involves multiplying 0 by infinity, which
2024 Sep 05
2
BUG: atan(1i) / 5 = NaN+Infi ?
Perhaps
> Inf*1i
[1] NaN+Infi
clarifies why it is *not* a bug.
(Boy, did that jog some long dusty math memories :-) )
-- Bert
On Thu, Sep 5, 2024 at 2:48?PM Duncan Murdoch <murdoch.duncan at gmail.com>
wrote:
> On 2024-09-05 4:23 p.m., Leo Mada via R-help wrote:
> > Dear R Users,
> >
> > Is this desired behaviour?
> > I presume it's a bug.
> >
2024 Sep 05
2
BUG: atan(1i) / 5 = NaN+Infi ?
Dear R Users,
Is this desired behaviour?
I presume it's a bug.
atan(1i)
# 0+Infi
tan(atan(1i))
# 0+1i
atan(1i) / 5
# NaN+Infi
There were some changes in handling of complex numbers. But it looks like a bug.
Sincerely,
Leonard
[[alternative HTML version deleted]]
2007 Feb 01
3
Need help writing a faster code
Hi,
I apologize for this repeat posting, which I first posted yesterday. I would
appreciate any hints on solving this problem:
I have two matrices A (m x 2) and B (n x 2), where m and n are large
integers (on the order of 10^4). I am looking for an efficient way to
create another matrix, W (m x n), which can be defined as follows:
for (i in 1:m){
for (j in 1:n) {
W[i,j] <-
2024 Sep 05
1
BUG: atan(1i) / 5 = NaN+Infi ?
Dear Bert,
These behave like real divisions/multiplications:
complex(re=Inf, im = Inf) * 5
# Inf+Infi
complex(re=-Inf, im = Inf) * 5
# -Inf+Infi
The real division / multiplication should be faster and also is well behaved. I was expecting R to do the real division/multiplication on a complex number. Which R actually does for these very particular cases; but not when only Im(x) is Inf.
2007 Nov 27
0
[LLVMdev] Other Intrinsics?
On Tue, Nov 27, 2007 at 10:50:03AM -0700, Jon Sargeant wrote:
> > > Do you have plans to add other intrinsics? I'm curious as to why there
> > > is an llvm.sin intrinsic and an llvm.cos intrinsic, but no llvm.atan
> > > intrinsic. Why is there an llvm.pow intrinsic but no llvm.log
> > > intrinsic?
> >
> > Intrinsics get added on demand.
2010 Jul 19
5
par("uin") ?
I inherited a function written either for an older version of R or SPlus
to draw a brace, "{", in a graph. It uses par("uin") to determine the
scaling of the
quarter circles that make up segments of the brace, but that setting
doesn't
exist in current R.
I'm guessing that, in the function below, ux, uy can be defined from
par("usr") and
2024 Sep 06
1
BUG: atan(1i) / 5 = NaN+Infi ?
On 2024-09-06 12:44 a.m., Richard O'Keefe wrote:
> I expect that atan(1i) = (0 + infinity i) and that atan(1i)/5 = (0 +
> infinity i)/5 = (0 + infinity i).
> Here's what I get in C:
> (0,1) = (0, 1)
> atan((0,1)) = (0, inf)
> atan((0,1))/5 = (0, inf)
>
> Note the difference between I*infinity = (0,1)*infinity =
> (0*infinity,1*infinity) = (NaN,infinity)
> and
2007 Jan 01
4
if ... problem with compound instructions
I am having problems with the 'if' syntax.
I have an n x 4 matrix, X say. The first two columns hold x, y values and
I am attempting to fill the second two columns with the quadrant in which
the datapoint (x, y) is and with the heading angle.
So I have two problems
1) how to do this elegantly (at which I've failed as I can't seem to
vectorize the problem) and
2) how to
2003 Aug 20
2
Weighted circular mean
Hello,
Once again, I posted a message without a subject line. Sorry.... here is
the question again.
Is there a simple way to modify the circ.mean function in the CircStats
package to include a vector of weights to obtain a weighted average angle?
Thanks!
Martin
--
Martin Biuw
Sea Mammal Research Unit
Gatty Marine Laboratory, University of St Andrews
St Andrews, Fife KY16 8PA
Scotland
Ph: