Skip to main content
-37 bytes.
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106

Haskell, 100100 63 bytes

For inputs that don't converge (eg. -2) this won't terminate:

import Data.Complex f x|l<-iterate(x**)x=fst$dropWhile(\x=until(a,b)\a->magnitude(a-bx**a)>1e<1e-6)(zip l$tail lx**)!!0x 

Try it online! Thanks a lot @ØrjanJohansen for teaching me about until and saving me 37 bytes!

Try it online!

Haskell, 100 bytes

For inputs that don't converge (eg. -2) this won't terminate:

import Data.Complex f x|l<-iterate(x**)x=fst$dropWhile(\(a,b)->magnitude(a-b)>1e-6)(zip l$tail l)!!0 

Try it online!

Haskell, 100 63 bytes

For inputs that don't converge (eg. -2) this won't terminate:

import Data.Complex f x=until(\a->magnitude(a-x**a)<1e-6)(x**)x 

Thanks a lot @ØrjanJohansen for teaching me about until and saving me 37 bytes!

Try it online!

Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106

Haskell, 100 bytes

For inputs that don't converge (eg. -2) this won't terminate:

import Data.Complex f x|l<-iterate(x**)x=fst$dropWhile(\(a,b)->magnitude(a-b)>1e-6)(zip l$tail l)!!0 

Try it online!