
(FPCore (x) :precision binary64 (/ (log (- 1.0 x)) (log (+ 1.0 x))))
double code(double x) {
return log((1.0 - x)) / log((1.0 + x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = log((1.0d0 - x)) / log((1.0d0 + x))
end function
public static double code(double x) {
return Math.log((1.0 - x)) / Math.log((1.0 + x));
}
def code(x): return math.log((1.0 - x)) / math.log((1.0 + x))
function code(x) return Float64(log(Float64(1.0 - x)) / log(Float64(1.0 + x))) end
function tmp = code(x) tmp = log((1.0 - x)) / log((1.0 + x)); end
code[x_] := N[(N[Log[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] / N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ (log (- 1.0 x)) (log (+ 1.0 x))))
double code(double x) {
return log((1.0 - x)) / log((1.0 + x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = log((1.0d0 - x)) / log((1.0d0 + x))
end function
public static double code(double x) {
return Math.log((1.0 - x)) / Math.log((1.0 + x));
}
def code(x): return math.log((1.0 - x)) / math.log((1.0 + x))
function code(x) return Float64(log(Float64(1.0 - x)) / log(Float64(1.0 + x))) end
function tmp = code(x) tmp = log((1.0 - x)) / log((1.0 + x)); end
code[x_] := N[(N[Log[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] / N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\end{array}
(FPCore (x) :precision binary64 (/ (log1p (- 0.0 x)) (log1p x)))
double code(double x) {
return log1p((0.0 - x)) / log1p(x);
}
public static double code(double x) {
return Math.log1p((0.0 - x)) / Math.log1p(x);
}
def code(x): return math.log1p((0.0 - x)) / math.log1p(x)
function code(x) return Float64(log1p(Float64(0.0 - x)) / log1p(x)) end
code[x_] := N[(N[Log[1 + N[(0.0 - x), $MachinePrecision]], $MachinePrecision] / N[Log[1 + x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{log1p}\left(0 - x\right)}{\mathsf{log1p}\left(x\right)}
\end{array}
Initial program 4.7%
/-lowering-/.f64N/A
log-lowering-log.f64N/A
--lowering--.f64N/A
log1p-defineN/A
log1p-lowering-log1p.f647.3%
Simplified7.3%
sub-negN/A
log1p-defineN/A
log1p-lowering-log1p.f64N/A
neg-sub0N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
sub0-negN/A
neg-lowering-neg.f6499.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(/
(*
x
(*
(+
1.0
(*
(* x x)
(+ -0.25 (* x (+ -0.3333333333333333 (* x -0.3611111111111111))))))
(/ 1.0 (- -1.0 (* x (+ -0.5 (* x (+ -0.3333333333333333 (* x -0.25)))))))))
(* x (+ 1.0 (* x (+ -0.5 (* x (+ (* x -0.25) 0.3333333333333333))))))))
double code(double x) {
return (x * ((1.0 + ((x * x) * (-0.25 + (x * (-0.3333333333333333 + (x * -0.3611111111111111)))))) * (1.0 / (-1.0 - (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25))))))))) / (x * (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333))))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * ((1.0d0 + ((x * x) * ((-0.25d0) + (x * ((-0.3333333333333333d0) + (x * (-0.3611111111111111d0))))))) * (1.0d0 / ((-1.0d0) - (x * ((-0.5d0) + (x * ((-0.3333333333333333d0) + (x * (-0.25d0)))))))))) / (x * (1.0d0 + (x * ((-0.5d0) + (x * ((x * (-0.25d0)) + 0.3333333333333333d0))))))
end function
public static double code(double x) {
return (x * ((1.0 + ((x * x) * (-0.25 + (x * (-0.3333333333333333 + (x * -0.3611111111111111)))))) * (1.0 / (-1.0 - (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25))))))))) / (x * (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333))))));
}
def code(x): return (x * ((1.0 + ((x * x) * (-0.25 + (x * (-0.3333333333333333 + (x * -0.3611111111111111)))))) * (1.0 / (-1.0 - (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25))))))))) / (x * (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333))))))
function code(x) return Float64(Float64(x * Float64(Float64(1.0 + Float64(Float64(x * x) * Float64(-0.25 + Float64(x * Float64(-0.3333333333333333 + Float64(x * -0.3611111111111111)))))) * Float64(1.0 / Float64(-1.0 - Float64(x * Float64(-0.5 + Float64(x * Float64(-0.3333333333333333 + Float64(x * -0.25))))))))) / Float64(x * Float64(1.0 + Float64(x * Float64(-0.5 + Float64(x * Float64(Float64(x * -0.25) + 0.3333333333333333))))))) end
function tmp = code(x) tmp = (x * ((1.0 + ((x * x) * (-0.25 + (x * (-0.3333333333333333 + (x * -0.3611111111111111)))))) * (1.0 / (-1.0 - (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25))))))))) / (x * (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333)))))); end
code[x_] := N[(N[(x * N[(N[(1.0 + N[(N[(x * x), $MachinePrecision] * N[(-0.25 + N[(x * N[(-0.3333333333333333 + N[(x * -0.3611111111111111), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(-1.0 - N[(x * N[(-0.5 + N[(x * N[(-0.3333333333333333 + N[(x * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(1.0 + N[(x * N[(-0.5 + N[(x * N[(N[(x * -0.25), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(1 + \left(x \cdot x\right) \cdot \left(-0.25 + x \cdot \left(-0.3333333333333333 + x \cdot -0.3611111111111111\right)\right)\right) \cdot \frac{1}{-1 - x \cdot \left(-0.5 + x \cdot \left(-0.3333333333333333 + x \cdot -0.25\right)\right)}\right)}{x \cdot \left(1 + x \cdot \left(-0.5 + x \cdot \left(x \cdot -0.25 + 0.3333333333333333\right)\right)\right)}
\end{array}
Initial program 4.7%
/-lowering-/.f64N/A
log-lowering-log.f64N/A
--lowering--.f64N/A
log1p-defineN/A
log1p-lowering-log1p.f647.3%
Simplified7.3%
Taylor expanded in x around 0
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6499.1%
Simplified99.1%
Taylor expanded in x around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6499.3%
Simplified99.3%
flip-+N/A
div-invN/A
*-lowering-*.f64N/A
Applied egg-rr99.2%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6499.3%
Simplified99.3%
Final simplification99.3%
(FPCore (x) :precision binary64 (/ (/ (* x (+ -1.0 (* x (+ -0.5 (* x (+ -0.3333333333333333 (* x -0.25))))))) (+ 1.0 (* x (+ -0.5 (* x (+ (* x -0.25) 0.3333333333333333)))))) x))
double code(double x) {
return ((x * (-1.0 + (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25))))))) / (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333)))))) / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x * ((-1.0d0) + (x * ((-0.5d0) + (x * ((-0.3333333333333333d0) + (x * (-0.25d0)))))))) / (1.0d0 + (x * ((-0.5d0) + (x * ((x * (-0.25d0)) + 0.3333333333333333d0)))))) / x
end function
public static double code(double x) {
return ((x * (-1.0 + (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25))))))) / (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333)))))) / x;
}
def code(x): return ((x * (-1.0 + (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25))))))) / (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333)))))) / x
function code(x) return Float64(Float64(Float64(x * Float64(-1.0 + Float64(x * Float64(-0.5 + Float64(x * Float64(-0.3333333333333333 + Float64(x * -0.25))))))) / Float64(1.0 + Float64(x * Float64(-0.5 + Float64(x * Float64(Float64(x * -0.25) + 0.3333333333333333)))))) / x) end
function tmp = code(x) tmp = ((x * (-1.0 + (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25))))))) / (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333)))))) / x; end
code[x_] := N[(N[(N[(x * N[(-1.0 + N[(x * N[(-0.5 + N[(x * N[(-0.3333333333333333 + N[(x * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(x * N[(-0.5 + N[(x * N[(N[(x * -0.25), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{x \cdot \left(-1 + x \cdot \left(-0.5 + x \cdot \left(-0.3333333333333333 + x \cdot -0.25\right)\right)\right)}{1 + x \cdot \left(-0.5 + x \cdot \left(x \cdot -0.25 + 0.3333333333333333\right)\right)}}{x}
\end{array}
Initial program 4.7%
/-lowering-/.f64N/A
log-lowering-log.f64N/A
--lowering--.f64N/A
log1p-defineN/A
log1p-lowering-log1p.f647.3%
Simplified7.3%
Taylor expanded in x around 0
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6499.1%
Simplified99.1%
Taylor expanded in x around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6499.3%
Simplified99.3%
*-commutativeN/A
associate-/r*N/A
/-lowering-/.f64N/A
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (x) :precision binary64 (* (+ -1.0 (* x (+ -0.5 (* x (+ -0.3333333333333333 (* x -0.25)))))) (/ 1.0 (+ 1.0 (* x (+ -0.5 (* x (+ (* x -0.25) 0.3333333333333333))))))))
double code(double x) {
return (-1.0 + (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25)))))) * (1.0 / (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333))))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-1.0d0) + (x * ((-0.5d0) + (x * ((-0.3333333333333333d0) + (x * (-0.25d0))))))) * (1.0d0 / (1.0d0 + (x * ((-0.5d0) + (x * ((x * (-0.25d0)) + 0.3333333333333333d0))))))
end function
public static double code(double x) {
return (-1.0 + (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25)))))) * (1.0 / (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333))))));
}
def code(x): return (-1.0 + (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25)))))) * (1.0 / (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333))))))
function code(x) return Float64(Float64(-1.0 + Float64(x * Float64(-0.5 + Float64(x * Float64(-0.3333333333333333 + Float64(x * -0.25)))))) * Float64(1.0 / Float64(1.0 + Float64(x * Float64(-0.5 + Float64(x * Float64(Float64(x * -0.25) + 0.3333333333333333))))))) end
function tmp = code(x) tmp = (-1.0 + (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25)))))) * (1.0 / (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333)))))); end
code[x_] := N[(N[(-1.0 + N[(x * N[(-0.5 + N[(x * N[(-0.3333333333333333 + N[(x * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 + N[(x * N[(-0.5 + N[(x * N[(N[(x * -0.25), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-1 + x \cdot \left(-0.5 + x \cdot \left(-0.3333333333333333 + x \cdot -0.25\right)\right)\right) \cdot \frac{1}{1 + x \cdot \left(-0.5 + x \cdot \left(x \cdot -0.25 + 0.3333333333333333\right)\right)}
\end{array}
Initial program 4.7%
/-lowering-/.f64N/A
log-lowering-log.f64N/A
--lowering--.f64N/A
log1p-defineN/A
log1p-lowering-log1p.f647.3%
Simplified7.3%
Taylor expanded in x around 0
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6499.1%
Simplified99.1%
Taylor expanded in x around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6499.3%
Simplified99.3%
*-commutativeN/A
associate-/r*N/A
/-lowering-/.f64N/A
Applied egg-rr99.3%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (x) :precision binary64 (/ (+ -1.0 (* x (+ -0.5 (* x (+ -0.3333333333333333 (* x -0.25)))))) (+ 1.0 (* x (+ -0.5 (* x (+ (* x -0.25) 0.3333333333333333)))))))
double code(double x) {
return (-1.0 + (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25)))))) / (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333)))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-1.0d0) + (x * ((-0.5d0) + (x * ((-0.3333333333333333d0) + (x * (-0.25d0))))))) / (1.0d0 + (x * ((-0.5d0) + (x * ((x * (-0.25d0)) + 0.3333333333333333d0)))))
end function
public static double code(double x) {
return (-1.0 + (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25)))))) / (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333)))));
}
def code(x): return (-1.0 + (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25)))))) / (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333)))))
function code(x) return Float64(Float64(-1.0 + Float64(x * Float64(-0.5 + Float64(x * Float64(-0.3333333333333333 + Float64(x * -0.25)))))) / Float64(1.0 + Float64(x * Float64(-0.5 + Float64(x * Float64(Float64(x * -0.25) + 0.3333333333333333)))))) end
function tmp = code(x) tmp = (-1.0 + (x * (-0.5 + (x * (-0.3333333333333333 + (x * -0.25)))))) / (1.0 + (x * (-0.5 + (x * ((x * -0.25) + 0.3333333333333333))))); end
code[x_] := N[(N[(-1.0 + N[(x * N[(-0.5 + N[(x * N[(-0.3333333333333333 + N[(x * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(x * N[(-0.5 + N[(x * N[(N[(x * -0.25), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1 + x \cdot \left(-0.5 + x \cdot \left(-0.3333333333333333 + x \cdot -0.25\right)\right)}{1 + x \cdot \left(-0.5 + x \cdot \left(x \cdot -0.25 + 0.3333333333333333\right)\right)}
\end{array}
Initial program 4.7%
/-lowering-/.f64N/A
log-lowering-log.f64N/A
--lowering--.f64N/A
log1p-defineN/A
log1p-lowering-log1p.f647.3%
Simplified7.3%
Taylor expanded in x around 0
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6499.1%
Simplified99.1%
Taylor expanded in x around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6499.3%
Simplified99.3%
associate-/r*N/A
/-lowering-/.f64N/A
Applied egg-rr99.3%
*-rgt-identityN/A
+-commutativeN/A
fma-defineN/A
metadata-evalN/A
fmm-defN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f6499.3%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (x) :precision binary64 (+ -1.0 (* x (+ -1.0 (* x (+ -0.5 (* x -0.4166666666666667)))))))
double code(double x) {
return -1.0 + (x * (-1.0 + (x * (-0.5 + (x * -0.4166666666666667)))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-1.0d0) + (x * ((-1.0d0) + (x * ((-0.5d0) + (x * (-0.4166666666666667d0))))))
end function
public static double code(double x) {
return -1.0 + (x * (-1.0 + (x * (-0.5 + (x * -0.4166666666666667)))));
}
def code(x): return -1.0 + (x * (-1.0 + (x * (-0.5 + (x * -0.4166666666666667)))))
function code(x) return Float64(-1.0 + Float64(x * Float64(-1.0 + Float64(x * Float64(-0.5 + Float64(x * -0.4166666666666667)))))) end
function tmp = code(x) tmp = -1.0 + (x * (-1.0 + (x * (-0.5 + (x * -0.4166666666666667))))); end
code[x_] := N[(-1.0 + N[(x * N[(-1.0 + N[(x * N[(-0.5 + N[(x * -0.4166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + x \cdot \left(-1 + x \cdot \left(-0.5 + x \cdot -0.4166666666666667\right)\right)
\end{array}
Initial program 4.7%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6499.1%
Simplified99.1%
(FPCore (x) :precision binary64 (+ -1.0 (* x (+ -1.0 (* x -0.5)))))
double code(double x) {
return -1.0 + (x * (-1.0 + (x * -0.5)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-1.0d0) + (x * ((-1.0d0) + (x * (-0.5d0))))
end function
public static double code(double x) {
return -1.0 + (x * (-1.0 + (x * -0.5)));
}
def code(x): return -1.0 + (x * (-1.0 + (x * -0.5)))
function code(x) return Float64(-1.0 + Float64(x * Float64(-1.0 + Float64(x * -0.5)))) end
function tmp = code(x) tmp = -1.0 + (x * (-1.0 + (x * -0.5))); end
code[x_] := N[(-1.0 + N[(x * N[(-1.0 + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + x \cdot \left(-1 + x \cdot -0.5\right)
\end{array}
Initial program 4.7%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6498.8%
Simplified98.8%
Final simplification98.8%
(FPCore (x) :precision binary64 (- -1.0 x))
double code(double x) {
return -1.0 - x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-1.0d0) - x
end function
public static double code(double x) {
return -1.0 - x;
}
def code(x): return -1.0 - x
function code(x) return Float64(-1.0 - x) end
function tmp = code(x) tmp = -1.0 - x; end
code[x_] := N[(-1.0 - x), $MachinePrecision]
\begin{array}{l}
\\
-1 - x
\end{array}
Initial program 4.7%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f6498.2%
Simplified98.2%
(FPCore (x) :precision binary64 -1.0)
double code(double x) {
return -1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -1.0d0
end function
public static double code(double x) {
return -1.0;
}
def code(x): return -1.0
function code(x) return -1.0 end
function tmp = code(x) tmp = -1.0; end
code[x_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 4.7%
Taylor expanded in x around 0
Simplified97.0%
(FPCore (x) :precision binary64 (/ (log1p (- x)) (log1p x)))
double code(double x) {
return log1p(-x) / log1p(x);
}
public static double code(double x) {
return Math.log1p(-x) / Math.log1p(x);
}
def code(x): return math.log1p(-x) / math.log1p(x)
function code(x) return Float64(log1p(Float64(-x)) / log1p(x)) end
code[x_] := N[(N[Log[1 + (-x)], $MachinePrecision] / N[Log[1 + x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{log1p}\left(-x\right)}{\mathsf{log1p}\left(x\right)}
\end{array}
herbie shell --seed 2024288
(FPCore (x)
:name "qlog (example 3.10)"
:precision binary64
:pre (<= (fabs x) 1.0)
:alt
(! :herbie-platform default (/ (log1p (- x)) (log1p x)))
(/ (log (- 1.0 x)) (log (+ 1.0 x))))