(FPCore (x) :precision binary64 (- (log (- (/ 1.0 x) 1.0))))
(FPCore (x) :precision binary64 (+ (* (pow x 2.0) 0.5) (+ x (+ (log x) (* (pow x 3.0) 0.3333333333333333)))))
double code(double x) {
return -log(((1.0 / x) - 1.0));
}
double code(double x) {
return (pow(x, 2.0) * 0.5) + (x + (log(x) + (pow(x, 3.0) * 0.3333333333333333)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = -log(((1.0d0 / x) - 1.0d0))
end function
real(8) function code(x)
real(8), intent (in) :: x
code = ((x ** 2.0d0) * 0.5d0) + (x + (log(x) + ((x ** 3.0d0) * 0.3333333333333333d0)))
end function
public static double code(double x) {
return -Math.log(((1.0 / x) - 1.0));
}
public static double code(double x) {
return (Math.pow(x, 2.0) * 0.5) + (x + (Math.log(x) + (Math.pow(x, 3.0) * 0.3333333333333333)));
}
def code(x): return -math.log(((1.0 / x) - 1.0))
def code(x): return (math.pow(x, 2.0) * 0.5) + (x + (math.log(x) + (math.pow(x, 3.0) * 0.3333333333333333)))
function code(x) return Float64(-log(Float64(Float64(1.0 / x) - 1.0))) end
function code(x) return Float64(Float64((x ^ 2.0) * 0.5) + Float64(x + Float64(log(x) + Float64((x ^ 3.0) * 0.3333333333333333)))) end
function tmp = code(x) tmp = -log(((1.0 / x) - 1.0)); end
function tmp = code(x) tmp = ((x ^ 2.0) * 0.5) + (x + (log(x) + ((x ^ 3.0) * 0.3333333333333333))); end
code[x_] := (-N[Log[N[(N[(1.0 / x), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision])
code[x_] := N[(N[(N[Power[x, 2.0], $MachinePrecision] * 0.5), $MachinePrecision] + N[(x + N[(N[Log[x], $MachinePrecision] + N[(N[Power[x, 3.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
-\log \left(\frac{1}{x} - 1\right)
{x}^{2} \cdot 0.5 + \left(x + \left(\log x + {x}^{3} \cdot 0.3333333333333333\right)\right)
Results
Initial program 0.0
Simplified0.0
Taylor expanded in x around 0 0.3
Final simplification0.3
herbie shell --seed 2022209
(FPCore (x)
:name "neg log"
:precision binary64
(- (log (- (/ 1.0 x) 1.0))))