
(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x / (x + 1.0d0)) - ((x + 1.0d0) / (x - 1.0d0))
end function
public static double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
def code(x): return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))
function code(x) return Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) end
function tmp = code(x) tmp = (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0)); end
code[x_] := N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x / (x + 1.0d0)) - ((x + 1.0d0) / (x - 1.0d0))
end function
public static double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
def code(x): return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))
function code(x) return Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) end
function tmp = code(x) tmp = (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0)); end
code[x_] := N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\end{array}
(FPCore (x) :precision binary64 (if (<= (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))) 1e-5) (* (fma (/ -1.0 x) (/ -1.0 x) (/ 3.0 x)) (- -1.0 (/ (pow x -1.0) x))) (fma x (fma (fma x x 1.0) 3.0 x) 1.0)))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))) <= 1e-5) {
tmp = fma((-1.0 / x), (-1.0 / x), (3.0 / x)) * (-1.0 - (pow(x, -1.0) / x));
} else {
tmp = fma(x, fma(fma(x, x, 1.0), 3.0, x), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) <= 1e-5) tmp = Float64(fma(Float64(-1.0 / x), Float64(-1.0 / x), Float64(3.0 / x)) * Float64(-1.0 - Float64((x ^ -1.0) / x))); else tmp = fma(x, fma(fma(x, x, 1.0), 3.0, x), 1.0); end return tmp end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-5], N[(N[(N[(-1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision] + N[(3.0 / x), $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(N[Power[x, -1.0], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(x * x + 1.0), $MachinePrecision] * 3.0 + x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x - 1} \leq 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{x}, \frac{-1}{x}, \frac{3}{x}\right) \cdot \left(-1 - \frac{{x}^{-1}}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x, x, 1\right), 3, x\right), 1\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 1.00000000000000008e-5Initial program 8.1%
Taylor expanded in x around inf
Applied rewrites99.9%
Taylor expanded in x around inf
div-subN/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
associate-/l/N/A
mul-1-negN/A
*-commutativeN/A
times-fracN/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites100.0%
Applied rewrites100.0%
if 1.00000000000000008e-5 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
Taylor expanded in x around 0
distribute-lft-inN/A
*-commutativeN/A
associate-+r+N/A
associate-*r*N/A
unpow2N/A
distribute-rgt1-inN/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (if (<= (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))) 1e-5) (* (/ (- (pow x -1.0) -3.0) x) (- -1.0 (pow (* x x) -1.0))) (fma x (fma (fma x x 1.0) 3.0 x) 1.0)))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))) <= 1e-5) {
tmp = ((pow(x, -1.0) - -3.0) / x) * (-1.0 - pow((x * x), -1.0));
} else {
tmp = fma(x, fma(fma(x, x, 1.0), 3.0, x), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) <= 1e-5) tmp = Float64(Float64(Float64((x ^ -1.0) - -3.0) / x) * Float64(-1.0 - (Float64(x * x) ^ -1.0))); else tmp = fma(x, fma(fma(x, x, 1.0), 3.0, x), 1.0); end return tmp end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-5], N[(N[(N[(N[Power[x, -1.0], $MachinePrecision] - -3.0), $MachinePrecision] / x), $MachinePrecision] * N[(-1.0 - N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(x * x + 1.0), $MachinePrecision] * 3.0 + x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x - 1} \leq 10^{-5}:\\
\;\;\;\;\frac{{x}^{-1} - -3}{x} \cdot \left(-1 - {\left(x \cdot x\right)}^{-1}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x, x, 1\right), 3, x\right), 1\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 1.00000000000000008e-5Initial program 8.1%
Taylor expanded in x around inf
Applied rewrites99.9%
Taylor expanded in x around inf
div-subN/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
associate-*r/N/A
mul-1-negN/A
associate-/l/N/A
mul-1-negN/A
*-commutativeN/A
times-fracN/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites100.0%
Applied rewrites100.0%
if 1.00000000000000008e-5 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
Taylor expanded in x around 0
distribute-lft-inN/A
*-commutativeN/A
associate-+r+N/A
associate-*r*N/A
unpow2N/A
distribute-rgt1-inN/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (if (<= (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))) 1e-5) (/ (- -3.0 (/ (- (/ 3.0 x) -1.0) x)) x) (fma x (fma (fma x x 1.0) 3.0 x) 1.0)))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))) <= 1e-5) {
tmp = (-3.0 - (((3.0 / x) - -1.0) / x)) / x;
} else {
tmp = fma(x, fma(fma(x, x, 1.0), 3.0, x), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) <= 1e-5) tmp = Float64(Float64(-3.0 - Float64(Float64(Float64(3.0 / x) - -1.0) / x)) / x); else tmp = fma(x, fma(fma(x, x, 1.0), 3.0, x), 1.0); end return tmp end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-5], N[(N[(-3.0 - N[(N[(N[(3.0 / x), $MachinePrecision] - -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(x * N[(N[(x * x + 1.0), $MachinePrecision] * 3.0 + x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x - 1} \leq 10^{-5}:\\
\;\;\;\;\frac{-3 - \frac{\frac{3}{x} - -1}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x, x, 1\right), 3, x\right), 1\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 1.00000000000000008e-5Initial program 8.1%
Taylor expanded in x around inf
Applied rewrites99.9%
if 1.00000000000000008e-5 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
Taylor expanded in x around 0
distribute-lft-inN/A
*-commutativeN/A
associate-+r+N/A
associate-*r*N/A
unpow2N/A
distribute-rgt1-inN/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
(FPCore (x) :precision binary64 (if (<= (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))) 1e-5) (/ (- (/ -1.0 x) 3.0) x) (fma x (fma (fma x x 1.0) 3.0 x) 1.0)))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))) <= 1e-5) {
tmp = ((-1.0 / x) - 3.0) / x;
} else {
tmp = fma(x, fma(fma(x, x, 1.0), 3.0, x), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) <= 1e-5) tmp = Float64(Float64(Float64(-1.0 / x) - 3.0) / x); else tmp = fma(x, fma(fma(x, x, 1.0), 3.0, x), 1.0); end return tmp end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-5], N[(N[(N[(-1.0 / x), $MachinePrecision] - 3.0), $MachinePrecision] / x), $MachinePrecision], N[(x * N[(N[(x * x + 1.0), $MachinePrecision] * 3.0 + x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x - 1} \leq 10^{-5}:\\
\;\;\;\;\frac{\frac{-1}{x} - 3}{x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x, x, 1\right), 3, x\right), 1\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 1.00000000000000008e-5Initial program 8.1%
Taylor expanded in x around inf
associate-*r/N/A
lower-/.f64N/A
neg-mul-1N/A
+-commutativeN/A
distribute-neg-inN/A
sub-negN/A
lower--.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6499.5
Applied rewrites99.5%
if 1.00000000000000008e-5 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
Taylor expanded in x around 0
distribute-lft-inN/A
*-commutativeN/A
associate-+r+N/A
associate-*r*N/A
unpow2N/A
distribute-rgt1-inN/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
(FPCore (x) :precision binary64 (if (<= (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))) 1e-5) (/ -3.0 x) (fma x (fma (fma x x 1.0) 3.0 x) 1.0)))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))) <= 1e-5) {
tmp = -3.0 / x;
} else {
tmp = fma(x, fma(fma(x, x, 1.0), 3.0, x), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) <= 1e-5) tmp = Float64(-3.0 / x); else tmp = fma(x, fma(fma(x, x, 1.0), 3.0, x), 1.0); end return tmp end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-5], N[(-3.0 / x), $MachinePrecision], N[(x * N[(N[(x * x + 1.0), $MachinePrecision] * 3.0 + x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x - 1} \leq 10^{-5}:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x, x, 1\right), 3, x\right), 1\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 1.00000000000000008e-5Initial program 8.1%
Taylor expanded in x around inf
lower-/.f6498.4
Applied rewrites98.4%
if 1.00000000000000008e-5 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
Taylor expanded in x around 0
distribute-lft-inN/A
*-commutativeN/A
associate-+r+N/A
associate-*r*N/A
unpow2N/A
distribute-rgt1-inN/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
(FPCore (x) :precision binary64 (if (<= (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))) 1e-5) (/ -3.0 x) (* (fma x x 1.0) (fma 3.0 x 1.0))))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))) <= 1e-5) {
tmp = -3.0 / x;
} else {
tmp = fma(x, x, 1.0) * fma(3.0, x, 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) <= 1e-5) tmp = Float64(-3.0 / x); else tmp = Float64(fma(x, x, 1.0) * fma(3.0, x, 1.0)); end return tmp end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-5], N[(-3.0 / x), $MachinePrecision], N[(N[(x * x + 1.0), $MachinePrecision] * N[(3.0 * x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x - 1} \leq 10^{-5}:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, 1\right) \cdot \mathsf{fma}\left(3, x, 1\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 1.00000000000000008e-5Initial program 8.1%
Taylor expanded in x around inf
lower-/.f6498.4
Applied rewrites98.4%
if 1.00000000000000008e-5 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
Taylor expanded in x around 0
distribute-lft-inN/A
*-commutativeN/A
associate-+r+N/A
associate-*r*N/A
unpow2N/A
distribute-rgt1-inN/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
(FPCore (x) :precision binary64 (if (<= (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))) 1e-5) (/ -3.0 x) (fma (+ 3.0 x) x 1.0)))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))) <= 1e-5) {
tmp = -3.0 / x;
} else {
tmp = fma((3.0 + x), x, 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) <= 1e-5) tmp = Float64(-3.0 / x); else tmp = fma(Float64(3.0 + x), x, 1.0); end return tmp end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-5], N[(-3.0 / x), $MachinePrecision], N[(N[(3.0 + x), $MachinePrecision] * x + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x - 1} \leq 10^{-5}:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(3 + x, x, 1\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 1.00000000000000008e-5Initial program 8.1%
Taylor expanded in x around inf
lower-/.f6498.4
Applied rewrites98.4%
if 1.00000000000000008e-5 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x) :precision binary64 (fma (+ 3.0 x) x 1.0))
double code(double x) {
return fma((3.0 + x), x, 1.0);
}
function code(x) return fma(Float64(3.0 + x), x, 1.0) end
code[x_] := N[(N[(3.0 + x), $MachinePrecision] * x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(3 + x, x, 1\right)
\end{array}
Initial program 52.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6449.1
Applied rewrites49.1%
(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 52.2%
Taylor expanded in x around 0
Applied rewrites49.1%
herbie shell --seed 2024307
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))