Merge pull request #9039 from joba-1/development

Fix ln(x) via taylor series for special case x = 1
This commit is contained in:
Theo Arends 2020-08-06 09:29:13 +02:00 committed by GitHub
commit 7cd362a84e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -116,6 +116,7 @@ double TaylorLog(double x)
// https://stackoverflow.com/questions/46879166/finding-the-natural-logarithm-of-a-number-using-taylor-series-in-c
if (x <= 0.0) { return NAN; }
if (x == 1.0) { return 0; }
double z = (x + 1) / (x - 1); // We start from power -1, to make sure we get the right power in each iteration;
double step = ((x - 1) * (x - 1)) / ((x + 1) * (x + 1)); // Store step to not have to calculate it each time
double totalValue = 0;