-1

i have tried implementing Taylor series but for greater number (1000 and more) it takes long time to calculate. i need a program that calculates natural log in less time.

sabari rangan
  • 608
  • 1
  • 6
  • 14
  • http://www.cplusplus.com/reference/cmath/log/ – Boiethios Apr 20 '16 at 10:11
  • what's your taylor series? it shouldn't even converge for x = 1000 –  Apr 20 '16 at 10:21
  • reading it again i think he means 1000 digits or more. 1000 as a value makes no sense. – starmole Apr 20 '16 at 10:28
  • Does your system support any function calculating the logarithm to another base, different to e (Euler number)? If yes, then use `somelog(x)/somelog(e)` to get the natural logarithm of `x`. – alk Apr 20 '16 at 11:20

1 Answers1

1

Compute the log in base 2, then change it back to natural.

starmole
  • 4,836
  • 25
  • 48
  • Edit: For that range http://en.cppreference.com/w/c/numeric/math/log is just fine of course. But the above is what the homework is going for. – starmole Apr 20 '16 at 10:19
  • This got me a bit curious. And it is actually harder than I thought to compute log2 of a large number. See for example http://stackoverflow.com/questions/8232932/logarithm-of-the-very-very-large-number – starmole Apr 20 '16 at 10:43