You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// } while (AddRes > MediumDec::JustAboveZero);//Total Result should be -0.346573590279972654708616060729088284037750067180127627060340004746696810984847357802931663498209344
398
-
// return TotalRes * 2;//Should result in -0.693147180559
399
-
//}
400
-
//if (value.IntValue == 0 && value.DecimalHalf01 > 500000000)//Ln[X] Power series from http://hyperphysics.phy-astr.gsu.edu/hbase/Math/lnseries.html
else if (value.IntValue==1)//Threshold between 0 and 2 based on Taylor code series from https://stackoverflow.com/questions/26820871/c-program-which-calculates-ln-for-a-given-variable-x-without-using-any-ready-f
429
-
{//This section gives accurate answer(for values between 1 and 2)
430
-
MediumDec threshold = MediumDec::FiveMillionth;
431
-
MediumDec base = value - 1; // Base of the numerator; exponent will be explicit
432
-
int den = 1; // Denominator of the nth term
433
-
bool posSign = true; // Used to swap the sign of each term
434
-
MediumDec term = base; // First term
435
-
MediumDec prev; // Previous sum
436
-
MediumDec result = term; // Kick it off
437
-
438
-
do
439
-
{
440
-
den++;
441
-
posSign = !posSign;
442
-
term *= base;
443
-
prev = result;
444
-
if (posSign)
445
-
result += term / den;
446
-
else
447
-
result -= term / den;
448
-
} while (MediumDec::Abs(prev - result) > threshold);
449
-
450
-
return result;
451
-
}
452
-
else//Returns a positive value(http://www.netlib.org/cephes/qlibdoc.html#qlog)
453
-
{//Increasing iterations brings closer to accurate result(Larger numbers need more iterations to get accurate level of result)
0 commit comments