
(FPCore (x) :precision binary64 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / (x + 1.0d0)) - (2.0d0 / x)) + (1.0d0 / (x - 1.0d0))
end function
public static double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
def code(x): return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0))
function code(x) return Float64(Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x - 1.0))) end
function tmp = code(x) tmp = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0)); end
code[x_] := N[(N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / (x + 1.0d0)) - (2.0d0 / x)) + (1.0d0 / (x - 1.0d0))
end function
public static double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
def code(x): return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0))
function code(x) return Float64(Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x - 1.0))) end
function tmp = code(x) tmp = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0)); end
code[x_] := N[(N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (- 0.5 (* x 0.5)))
(t_1 (+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ 1.0 (+ x -1.0)))))
(if (<= t_1 -1e-12)
(/ (- (* x t_0) (* (+ 1.0 x) (- 1.0 (* x 0.5)))) (* x (* (+ 1.0 x) t_0)))
(if (<= t_1 0.0) (* 2.0 (pow x -3.0)) (- (* x -2.0) (/ 2.0 x))))))
double code(double x) {
double t_0 = 0.5 - (x * 0.5);
double t_1 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if (t_1 <= -1e-12) {
tmp = ((x * t_0) - ((1.0 + x) * (1.0 - (x * 0.5)))) / (x * ((1.0 + x) * t_0));
} else if (t_1 <= 0.0) {
tmp = 2.0 * pow(x, -3.0);
} else {
tmp = (x * -2.0) - (2.0 / x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 - (x * 0.5d0)
t_1 = ((1.0d0 / (1.0d0 + x)) - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))
if (t_1 <= (-1d-12)) then
tmp = ((x * t_0) - ((1.0d0 + x) * (1.0d0 - (x * 0.5d0)))) / (x * ((1.0d0 + x) * t_0))
else if (t_1 <= 0.0d0) then
tmp = 2.0d0 * (x ** (-3.0d0))
else
tmp = (x * (-2.0d0)) - (2.0d0 / x)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = 0.5 - (x * 0.5);
double t_1 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if (t_1 <= -1e-12) {
tmp = ((x * t_0) - ((1.0 + x) * (1.0 - (x * 0.5)))) / (x * ((1.0 + x) * t_0));
} else if (t_1 <= 0.0) {
tmp = 2.0 * Math.pow(x, -3.0);
} else {
tmp = (x * -2.0) - (2.0 / x);
}
return tmp;
}
def code(x): t_0 = 0.5 - (x * 0.5) t_1 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0)) tmp = 0 if t_1 <= -1e-12: tmp = ((x * t_0) - ((1.0 + x) * (1.0 - (x * 0.5)))) / (x * ((1.0 + x) * t_0)) elif t_1 <= 0.0: tmp = 2.0 * math.pow(x, -3.0) else: tmp = (x * -2.0) - (2.0 / x) return tmp
function code(x) t_0 = Float64(0.5 - Float64(x * 0.5)) t_1 = Float64(Float64(Float64(1.0 / Float64(1.0 + x)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) tmp = 0.0 if (t_1 <= -1e-12) tmp = Float64(Float64(Float64(x * t_0) - Float64(Float64(1.0 + x) * Float64(1.0 - Float64(x * 0.5)))) / Float64(x * Float64(Float64(1.0 + x) * t_0))); elseif (t_1 <= 0.0) tmp = Float64(2.0 * (x ^ -3.0)); else tmp = Float64(Float64(x * -2.0) - Float64(2.0 / x)); end return tmp end
function tmp_2 = code(x) t_0 = 0.5 - (x * 0.5); t_1 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0)); tmp = 0.0; if (t_1 <= -1e-12) tmp = ((x * t_0) - ((1.0 + x) * (1.0 - (x * 0.5)))) / (x * ((1.0 + x) * t_0)); elseif (t_1 <= 0.0) tmp = 2.0 * (x ^ -3.0); else tmp = (x * -2.0) - (2.0 / x); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(0.5 - N[(x * 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-12], N[(N[(N[(x * t$95$0), $MachinePrecision] - N[(N[(1.0 + x), $MachinePrecision] * N[(1.0 - N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[(1.0 + x), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(2.0 * N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision], N[(N[(x * -2.0), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 - x \cdot 0.5\\
t_1 := \left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-12}:\\
\;\;\;\;\frac{x \cdot t_0 - \left(1 + x\right) \cdot \left(1 - x \cdot 0.5\right)}{x \cdot \left(\left(1 + x\right) \cdot t_0\right)}\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\mathbf{else}:\\
\;\;\;\;x \cdot -2 - \frac{2}{x}\\
\end{array}
\end{array}
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -9.9999999999999998e-13Initial program 99.2%
associate-+l-99.2%
+-commutative99.2%
sub-neg99.2%
distribute-neg-frac99.2%
metadata-eval99.2%
metadata-eval99.2%
metadata-eval99.2%
associate-/r*99.2%
metadata-eval99.2%
neg-mul-199.2%
sub0-neg99.2%
associate-+l-99.2%
neg-sub099.2%
+-commutative99.2%
unsub-neg99.2%
Simplified99.2%
Applied egg-rr97.5%
*-commutative97.5%
associate-*l*97.5%
metadata-eval97.5%
+-commutative97.5%
*-commutative97.5%
associate-*l*97.5%
+-commutative97.5%
Simplified97.5%
Applied egg-rr100.0%
neg-sub0100.0%
associate--r+100.0%
metadata-eval100.0%
neg-sub0100.0%
+-commutative100.0%
associate--r+100.0%
metadata-eval100.0%
*-commutative100.0%
associate-*l*100.0%
neg-sub0100.0%
associate--r+100.0%
metadata-eval100.0%
Simplified100.0%
if -9.9999999999999998e-13 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 0.0Initial program 68.1%
Simplified68.1%
Taylor expanded in x around inf 99.2%
div-inv99.2%
*-commutative99.2%
pow-flip100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if 0.0 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (+ (/ 1.0 (+ 1.0 x)) (* (/ (+ (* x 0.5) -1.0) x) (/ -1.0 (+ (* x 0.5) -0.5)))))
double code(double x) {
return (1.0 / (1.0 + x)) + ((((x * 0.5) + -1.0) / x) * (-1.0 / ((x * 0.5) + -0.5)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (1.0d0 + x)) + ((((x * 0.5d0) + (-1.0d0)) / x) * ((-1.0d0) / ((x * 0.5d0) + (-0.5d0))))
end function
public static double code(double x) {
return (1.0 / (1.0 + x)) + ((((x * 0.5) + -1.0) / x) * (-1.0 / ((x * 0.5) + -0.5)));
}
def code(x): return (1.0 / (1.0 + x)) + ((((x * 0.5) + -1.0) / x) * (-1.0 / ((x * 0.5) + -0.5)))
function code(x) return Float64(Float64(1.0 / Float64(1.0 + x)) + Float64(Float64(Float64(Float64(x * 0.5) + -1.0) / x) * Float64(-1.0 / Float64(Float64(x * 0.5) + -0.5)))) end
function tmp = code(x) tmp = (1.0 / (1.0 + x)) + ((((x * 0.5) + -1.0) / x) * (-1.0 / ((x * 0.5) + -0.5))); end
code[x_] := N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(x * 0.5), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision] * N[(-1.0 / N[(N[(x * 0.5), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 + x} + \frac{x \cdot 0.5 + -1}{x} \cdot \frac{-1}{x \cdot 0.5 + -0.5}
\end{array}
Initial program 84.3%
associate-+l-84.3%
+-commutative84.3%
sub-neg84.3%
distribute-neg-frac84.3%
metadata-eval84.3%
metadata-eval84.3%
metadata-eval84.3%
associate-/r*84.3%
metadata-eval84.3%
neg-mul-184.3%
sub0-neg84.3%
associate-+l-84.3%
neg-sub084.3%
+-commutative84.3%
unsub-neg84.3%
Simplified84.3%
Applied egg-rr57.0%
*-commutative57.0%
associate-*l*57.0%
metadata-eval57.0%
+-commutative57.0%
*-commutative57.0%
associate-*l*57.0%
+-commutative57.0%
Simplified57.0%
associate-/r*83.1%
div-inv83.1%
Applied egg-rr84.3%
Final simplification84.3%
(FPCore (x) :precision binary64 (+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ 1.0 (+ x -1.0))))
double code(double x) {
return ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / (1.0d0 + x)) - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))
end function
public static double code(double x) {
return ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0));
}
def code(x): return ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0))
function code(x) return Float64(Float64(Float64(1.0 / Float64(1.0 + x)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) end
function tmp = code(x) tmp = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0)); end
code[x_] := N[(N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x + -1}
\end{array}
Initial program 84.3%
Final simplification84.3%
(FPCore (x) :precision binary64 (if (<= x -1.0) 0.0 (if (<= x 1.0) (- (* x -2.0) (/ 2.0 x)) 0.0)))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = 0.0;
} else if (x <= 1.0) {
tmp = (x * -2.0) - (2.0 / x);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = 0.0d0
else if (x <= 1.0d0) then
tmp = (x * (-2.0d0)) - (2.0d0 / x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = 0.0;
} else if (x <= 1.0) {
tmp = (x * -2.0) - (2.0 / x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = 0.0 elif x <= 1.0: tmp = (x * -2.0) - (2.0 / x) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = 0.0; elseif (x <= 1.0) tmp = Float64(Float64(x * -2.0) - Float64(2.0 / x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.0) tmp = 0.0; elseif (x <= 1.0) tmp = (x * -2.0) - (2.0 / x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.0], 0.0, If[LessEqual[x, 1.0], N[(N[(x * -2.0), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot -2 - \frac{2}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 68.1%
Simplified68.1%
Applied egg-rr26.3%
associate-+l+24.1%
expm1-log1p24.1%
expm1-def2.2%
associate-+l-2.2%
fma-udef2.2%
distribute-lft-neg-out2.2%
pow-sqr5.2%
metadata-eval5.2%
unpow-15.2%
+-commutative5.2%
sub-neg5.2%
+-inverses5.2%
metadata-eval5.2%
Simplified67.2%
clear-num67.2%
frac-2neg67.2%
metadata-eval67.2%
frac-add67.2%
*-un-lft-identity67.2%
neg-sub067.2%
+-commutative67.2%
associate--r+67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
neg-sub067.2%
+-commutative67.2%
associate--r+67.2%
metadata-eval67.2%
Applied egg-rr67.2%
associate-/r*67.2%
*-commutative67.2%
associate-+l-54.5%
*-commutative54.5%
associate-*l*54.5%
metadata-eval54.5%
Simplified54.5%
Applied egg-rr67.0%
if -1 < x < 1Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification83.8%
(FPCore (x) :precision binary64 (+ (/ -2.0 x) (/ 2.0 (+ 1.0 x))))
double code(double x) {
return (-2.0 / x) + (2.0 / (1.0 + x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-2.0d0) / x) + (2.0d0 / (1.0d0 + x))
end function
public static double code(double x) {
return (-2.0 / x) + (2.0 / (1.0 + x));
}
def code(x): return (-2.0 / x) + (2.0 / (1.0 + x))
function code(x) return Float64(Float64(-2.0 / x) + Float64(2.0 / Float64(1.0 + x))) end
function tmp = code(x) tmp = (-2.0 / x) + (2.0 / (1.0 + x)); end
code[x_] := N[(N[(-2.0 / x), $MachinePrecision] + N[(2.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{x} + \frac{2}{1 + x}
\end{array}
Initial program 84.3%
Simplified84.3%
Applied egg-rr63.0%
associate-+l+61.9%
expm1-log1p61.9%
expm1-def51.1%
associate-+l-51.1%
fma-udef51.1%
distribute-lft-neg-out51.1%
pow-sqr52.6%
metadata-eval52.6%
unpow-152.6%
+-commutative52.6%
sub-neg52.6%
+-inverses52.6%
metadata-eval52.6%
Simplified83.1%
Final simplification83.1%
(FPCore (x) :precision binary64 (if (<= x -1.0) 0.0 (if (<= x 1.0) (/ -2.0 x) 0.0)))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = 0.0;
} else if (x <= 1.0) {
tmp = -2.0 / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = 0.0d0
else if (x <= 1.0d0) then
tmp = (-2.0d0) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = 0.0;
} else if (x <= 1.0) {
tmp = -2.0 / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = 0.0 elif x <= 1.0: tmp = -2.0 / x else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = 0.0; elseif (x <= 1.0) tmp = Float64(-2.0 / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.0) tmp = 0.0; elseif (x <= 1.0) tmp = -2.0 / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.0], 0.0, If[LessEqual[x, 1.0], N[(-2.0 / x), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 68.1%
Simplified68.1%
Applied egg-rr26.3%
associate-+l+24.1%
expm1-log1p24.1%
expm1-def2.2%
associate-+l-2.2%
fma-udef2.2%
distribute-lft-neg-out2.2%
pow-sqr5.2%
metadata-eval5.2%
unpow-15.2%
+-commutative5.2%
sub-neg5.2%
+-inverses5.2%
metadata-eval5.2%
Simplified67.2%
clear-num67.2%
frac-2neg67.2%
metadata-eval67.2%
frac-add67.2%
*-un-lft-identity67.2%
neg-sub067.2%
+-commutative67.2%
associate--r+67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
neg-sub067.2%
+-commutative67.2%
associate--r+67.2%
metadata-eval67.2%
Applied egg-rr67.2%
associate-/r*67.2%
*-commutative67.2%
associate-+l-54.5%
*-commutative54.5%
associate-*l*54.5%
metadata-eval54.5%
Simplified54.5%
Applied egg-rr67.0%
if -1 < x < 1Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 99.7%
Final simplification83.6%
(FPCore (x) :precision binary64 -8.0)
double code(double x) {
return -8.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -8.0d0
end function
public static double code(double x) {
return -8.0;
}
def code(x): return -8.0
function code(x) return -8.0 end
function tmp = code(x) tmp = -8.0; end
code[x_] := -8.0
\begin{array}{l}
\\
-8
\end{array}
Initial program 84.3%
Simplified84.3%
Applied egg-rr63.0%
associate-+l+61.9%
expm1-log1p61.9%
expm1-def51.1%
associate-+l-51.1%
fma-udef51.1%
distribute-lft-neg-out51.1%
pow-sqr52.6%
metadata-eval52.6%
unpow-152.6%
+-commutative52.6%
sub-neg52.6%
+-inverses52.6%
metadata-eval52.6%
Simplified83.1%
clear-num83.1%
frac-2neg83.1%
metadata-eval83.1%
frac-add83.1%
*-un-lft-identity83.1%
neg-sub083.1%
+-commutative83.1%
associate--r+83.1%
metadata-eval83.1%
div-inv83.1%
metadata-eval83.1%
div-inv83.1%
metadata-eval83.1%
neg-sub083.1%
+-commutative83.1%
associate--r+83.1%
metadata-eval83.1%
Applied egg-rr83.1%
associate-/r*83.1%
*-commutative83.1%
associate-+l-76.9%
*-commutative76.9%
associate-*l*76.9%
metadata-eval76.9%
Simplified76.9%
Applied egg-rr3.2%
Final simplification3.2%
(FPCore (x) :precision binary64 -0.5)
double code(double x) {
return -0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -0.5d0
end function
public static double code(double x) {
return -0.5;
}
def code(x): return -0.5
function code(x) return -0.5 end
function tmp = code(x) tmp = -0.5; end
code[x_] := -0.5
\begin{array}{l}
\\
-0.5
\end{array}
Initial program 84.3%
Simplified84.3%
Applied egg-rr63.0%
associate-+l+61.9%
expm1-log1p61.9%
expm1-def51.1%
associate-+l-51.1%
fma-udef51.1%
distribute-lft-neg-out51.1%
pow-sqr52.6%
metadata-eval52.6%
unpow-152.6%
+-commutative52.6%
sub-neg52.6%
+-inverses52.6%
metadata-eval52.6%
Simplified83.1%
clear-num83.1%
frac-2neg83.1%
metadata-eval83.1%
frac-add83.1%
*-un-lft-identity83.1%
neg-sub083.1%
+-commutative83.1%
associate--r+83.1%
metadata-eval83.1%
div-inv83.1%
metadata-eval83.1%
div-inv83.1%
metadata-eval83.1%
neg-sub083.1%
+-commutative83.1%
associate--r+83.1%
metadata-eval83.1%
Applied egg-rr83.1%
associate-/r*83.1%
*-commutative83.1%
associate-+l-76.9%
*-commutative76.9%
associate-*l*76.9%
metadata-eval76.9%
Simplified76.9%
Applied egg-rr3.2%
Final simplification3.2%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 84.3%
Simplified84.3%
Applied egg-rr63.0%
associate-+l+61.9%
expm1-log1p61.9%
expm1-def51.1%
associate-+l-51.1%
fma-udef51.1%
distribute-lft-neg-out51.1%
pow-sqr52.6%
metadata-eval52.6%
unpow-152.6%
+-commutative52.6%
sub-neg52.6%
+-inverses52.6%
metadata-eval52.6%
Simplified83.1%
clear-num83.1%
frac-2neg83.1%
metadata-eval83.1%
frac-add83.1%
*-un-lft-identity83.1%
neg-sub083.1%
+-commutative83.1%
associate--r+83.1%
metadata-eval83.1%
div-inv83.1%
metadata-eval83.1%
div-inv83.1%
metadata-eval83.1%
neg-sub083.1%
+-commutative83.1%
associate--r+83.1%
metadata-eval83.1%
Applied egg-rr83.1%
associate-/r*83.1%
*-commutative83.1%
associate-+l-76.9%
*-commutative76.9%
associate-*l*76.9%
metadata-eval76.9%
Simplified76.9%
Applied egg-rr34.1%
Final simplification34.1%
(FPCore (x) :precision binary64 (/ 2.0 (* x (- (* x x) 1.0))))
double code(double x) {
return 2.0 / (x * ((x * x) - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.0d0 / (x * ((x * x) - 1.0d0))
end function
public static double code(double x) {
return 2.0 / (x * ((x * x) - 1.0));
}
def code(x): return 2.0 / (x * ((x * x) - 1.0))
function code(x) return Float64(2.0 / Float64(x * Float64(Float64(x * x) - 1.0))) end
function tmp = code(x) tmp = 2.0 / (x * ((x * x) - 1.0)); end
code[x_] := N[(2.0 / N[(x * N[(N[(x * x), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{x \cdot \left(x \cdot x - 1\right)}
\end{array}
herbie shell --seed 2023305
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:herbie-target
(/ 2.0 (* x (- (* x x) 1.0)))
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))