Guest User

Untitled

a guest
Jun 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. class Real
  2. def log
  3. return if zero?
  4. _ = self
  5. return (- _).log if _ < zero
  6. if _ > 2 or _ < unity
  7. e = 0
  8. e, _ = e + 1, _ / 2 while _ > 2
  9. e, _ = e - 1, _ * 2 while _ < 1
  10. _.log + e * 2.log
  11. else
  12. _ = x = unity - inverse
  13. t = 1
  14. i, r = 1, 0
  15. until t.zero?
  16. r += t
  17. i += 1
  18. _ *= x
  19. t = _ / i
  20. end
  21. r
  22. end
  23. end
  24. end
Add Comment
Please, Sign In to add comment