summaryrefslogtreecommitdiff
path: root/src/pkg/math/log.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/math/log.go')
-rw-r--r--src/pkg/math/log.go46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/pkg/math/log.go b/src/pkg/math/log.go
index e92650131..0564689f4 100644
--- a/src/pkg/math/log.go
+++ b/src/pkg/math/log.go
@@ -76,15 +76,15 @@ package math
// Log(NaN) = NaN
func Log(x float64) float64 {
const (
- Ln2Hi = 6.93147180369123816490e-01; /* 3fe62e42 fee00000 */
- Ln2Lo = 1.90821492927058770002e-10; /* 3dea39ef 35793c76 */
- L1 = 6.666666666666735130e-01; /* 3FE55555 55555593 */
- L2 = 3.999999999940941908e-01; /* 3FD99999 9997FA04 */
- L3 = 2.857142874366239149e-01; /* 3FD24924 94229359 */
- L4 = 2.222219843214978396e-01; /* 3FCC71C5 1D8E78AF */
- L5 = 1.818357216161805012e-01; /* 3FC74664 96CB03DE */
- L6 = 1.531383769920937332e-01; /* 3FC39A09 D078C69F */
- L7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
+ Ln2Hi = 6.93147180369123816490e-01 /* 3fe62e42 fee00000 */
+ Ln2Lo = 1.90821492927058770002e-10 /* 3dea39ef 35793c76 */
+ L1 = 6.666666666666735130e-01 /* 3FE55555 55555593 */
+ L2 = 3.999999999940941908e-01 /* 3FD99999 9997FA04 */
+ L3 = 2.857142874366239149e-01 /* 3FD24924 94229359 */
+ L4 = 2.222219843214978396e-01 /* 3FCC71C5 1D8E78AF */
+ L5 = 1.818357216161805012e-01 /* 3FC74664 96CB03DE */
+ L6 = 1.531383769920937332e-01 /* 3FC39A09 D078C69F */
+ L7 = 1.479819860511658591e-01 /* 3FC2F112 DF3E5244 */
)
// special cases
@@ -98,23 +98,23 @@ func Log(x float64) float64 {
}
// reduce
- f1, ki := Frexp(x);
+ f1, ki := Frexp(x)
if f1 < Sqrt2/2 {
- f1 *= 2;
- ki--;
+ f1 *= 2
+ ki--
}
- f := f1 - 1;
- k := float64(ki);
+ f := f1 - 1
+ k := float64(ki)
// compute
- s := f / (2 + f);
- s2 := s * s;
- s4 := s2 * s2;
- t1 := s2 * (L1 + s4*(L3+s4*(L5+s4*L7)));
- t2 := s4 * (L2 + s4*(L4+s4*L6));
- R := t1 + t2;
- hfsq := 0.5 * f * f;
- return k*Ln2Hi - ((hfsq - (s*(hfsq+R) + k*Ln2Lo)) - f);
+ s := f / (2 + f)
+ s2 := s * s
+ s4 := s2 * s2
+ t1 := s2 * (L1 + s4*(L3+s4*(L5+s4*L7)))
+ t2 := s4 * (L2 + s4*(L4+s4*L6))
+ R := t1 + t2
+ hfsq := 0.5 * f * f
+ return k*Ln2Hi - ((hfsq - (s*(hfsq+R) + k*Ln2Lo)) - f)
}
// Log10 returns the decimal logarithm of x.
@@ -123,5 +123,5 @@ func Log10(x float64) float64 {
if x <= 0 {
return NaN()
}
- return Log(x) * (1 / Ln10);
+ return Log(x) * (1 / Ln10)
}