0

I noticed when a function I wrote to identify common roots didn't catch some, can anyone explain why this is or how to get around it? See the below code and output.

phi=c(1,-1); theta=c(1,-0.5, -0.5)
a = polyroot(phi)
b = polyroot(theta)
a
#[1] 1+0i
b
#[1]  1-0i -2+0i
intersect(a,b)
complex(0)
intersect(1+0i, c(1-0i, -2+0i))
#[1] 1+0i
nicola
  • 24,005
  • 3
  • 35
  • 56
Ben
  • 459
  • 4
  • 16
  • The issue seems to come from b, since `b==c(1-0i,-2+0i)` returns `FALSE FALSE`, whereas `a==c(1+0i)` returns `TRUE`. – Ben Sep 25 '17 at 04:45
  • This is a variation of https://stackoverflow.com/questions/9508518/why-are-these-numbers-not-equal. See `Im(a)` and `Im(b)`. – nicola Sep 25 '17 at 05:20

0 Answers0