- #1

- 64

- 0

I'm aiming to calculate ln(x) numerically. I'm using the following procedure for this:

1) If x is greater or equal to 1, use Newton's method.

2) If x is smaller between 0 and 1, use Taylor series expansion.

Newton's method works good, but I have problems with Taylor series expansion method.

[itex]\ln(1+x)=\sum_{n=1}^\infty \frac{(-1)^{n+1}}{n} x^n = x - \frac{x^2}{2} + \frac{x^3}{3} - \cdots \quad{\rm for}\quad \left|x\right| \leq 1\quad[/itex]

Sum of this series is [itex]\small -\infty\normalsize[/itex] for [itex]\small x=-1\normalsize[/itex], but when you try to take sum of it using a computer, it doesn't converge because of computing limitations (like using truncated series). I can't either use Newton's method for this interval, because it has a bad performance for small x values (neither it converges for small x).

For x=0.000001;

ln(x) = -13.8155... (actual)

ln(x) = -1.71828... (calculated)

(The summation goes on until absolute value of any element of the series is below a user defined [itex]\epsilon[/itex] value, which is equal to [itex]1.0 \times 10^{-14}[/itex] for this particular example.)

I need a third method to calculate ln(x) for small x argument.

Can you please suggest me one?

1) If x is greater or equal to 1, use Newton's method.

2) If x is smaller between 0 and 1, use Taylor series expansion.

Newton's method works good, but I have problems with Taylor series expansion method.

[itex]\ln(1+x)=\sum_{n=1}^\infty \frac{(-1)^{n+1}}{n} x^n = x - \frac{x^2}{2} + \frac{x^3}{3} - \cdots \quad{\rm for}\quad \left|x\right| \leq 1\quad[/itex]

Sum of this series is [itex]\small -\infty\normalsize[/itex] for [itex]\small x=-1\normalsize[/itex], but when you try to take sum of it using a computer, it doesn't converge because of computing limitations (like using truncated series). I can't either use Newton's method for this interval, because it has a bad performance for small x values (neither it converges for small x).

For x=0.000001;

ln(x) = -13.8155... (actual)

ln(x) = -1.71828... (calculated)

(The summation goes on until absolute value of any element of the series is below a user defined [itex]\epsilon[/itex] value, which is equal to [itex]1.0 \times 10^{-14}[/itex] for this particular example.)

I need a third method to calculate ln(x) for small x argument.

Can you please suggest me one?

Last edited: