
(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 2.0d0) * y) / (x - y)
end function
public static double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
def code(x, y): return ((x * 2.0) * y) / (x - y)
function code(x, y) return Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) end
function tmp = code(x, y) tmp = ((x * 2.0) * y) / (x - y); end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 2.0d0) * y) / (x - y)
end function
public static double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
def code(x, y): return ((x * 2.0) * y) / (x - y)
function code(x, y) return Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) end
function tmp = code(x, y) tmp = ((x * 2.0) * y) / (x - y); end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\end{array}
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (* x 2.0) y) (- x y))) (t_1 (* y (/ (* x 2.0) (- x y)))))
(if (<= t_0 -0.04)
t_1
(if (<= t_0 -1e-303)
t_0
(if (<= t_0 0.0)
(/ (+ y y) (- 1.0 (/ y x)))
(if (<= t_0 0.5) t_0 t_1))))))
double code(double x, double y) {
double t_0 = ((x * 2.0) * y) / (x - y);
double t_1 = y * ((x * 2.0) / (x - y));
double tmp;
if (t_0 <= -0.04) {
tmp = t_1;
} else if (t_0 <= -1e-303) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = (y + y) / (1.0 - (y / x));
} else if (t_0 <= 0.5) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((x * 2.0d0) * y) / (x - y)
t_1 = y * ((x * 2.0d0) / (x - y))
if (t_0 <= (-0.04d0)) then
tmp = t_1
else if (t_0 <= (-1d-303)) then
tmp = t_0
else if (t_0 <= 0.0d0) then
tmp = (y + y) / (1.0d0 - (y / x))
else if (t_0 <= 0.5d0) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((x * 2.0) * y) / (x - y);
double t_1 = y * ((x * 2.0) / (x - y));
double tmp;
if (t_0 <= -0.04) {
tmp = t_1;
} else if (t_0 <= -1e-303) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = (y + y) / (1.0 - (y / x));
} else if (t_0 <= 0.5) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = ((x * 2.0) * y) / (x - y) t_1 = y * ((x * 2.0) / (x - y)) tmp = 0 if t_0 <= -0.04: tmp = t_1 elif t_0 <= -1e-303: tmp = t_0 elif t_0 <= 0.0: tmp = (y + y) / (1.0 - (y / x)) elif t_0 <= 0.5: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) t_1 = Float64(y * Float64(Float64(x * 2.0) / Float64(x - y))) tmp = 0.0 if (t_0 <= -0.04) tmp = t_1; elseif (t_0 <= -1e-303) tmp = t_0; elseif (t_0 <= 0.0) tmp = Float64(Float64(y + y) / Float64(1.0 - Float64(y / x))); elseif (t_0 <= 0.5) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = ((x * 2.0) * y) / (x - y); t_1 = y * ((x * 2.0) / (x - y)); tmp = 0.0; if (t_0 <= -0.04) tmp = t_1; elseif (t_0 <= -1e-303) tmp = t_0; elseif (t_0 <= 0.0) tmp = (y + y) / (1.0 - (y / x)); elseif (t_0 <= 0.5) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(N[(x * 2.0), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.04], t$95$1, If[LessEqual[t$95$0, -1e-303], t$95$0, If[LessEqual[t$95$0, 0.0], N[(N[(y + y), $MachinePrecision] / N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.5], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot 2\right) \cdot y}{x - y}\\
t_1 := y \cdot \frac{x \cdot 2}{x - y}\\
\mathbf{if}\;t\_0 \leq -0.04:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-303}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{y + y}{1 - \frac{y}{x}}\\
\mathbf{elif}\;t\_0 \leq 0.5:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -0.0400000000000000008 or 0.5 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) Initial program 61.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if -0.0400000000000000008 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -9.99999999999999931e-304 or -0.0 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 0.5Initial program 99.0%
if -9.99999999999999931e-304 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -0.0Initial program 12.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
lift--.f64N/A
flip--N/A
div-invN/A
difference-of-squaresN/A
lift--.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-/.f64N/A
rgt-mult-inverseN/A
*-lft-identityN/A
clear-numN/A
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f6499.9
Applied rewrites99.9%
Final simplification99.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (* x 2.0) y) (- x y))) (t_1 (* y (/ (* x 2.0) (- x y)))))
(if (<= t_0 -0.04)
t_1
(if (<= t_0 -1e-303)
t_0
(if (<= t_0 0.0) t_1 (if (<= t_0 0.5) t_0 t_1))))))
double code(double x, double y) {
double t_0 = ((x * 2.0) * y) / (x - y);
double t_1 = y * ((x * 2.0) / (x - y));
double tmp;
if (t_0 <= -0.04) {
tmp = t_1;
} else if (t_0 <= -1e-303) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 0.5) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((x * 2.0d0) * y) / (x - y)
t_1 = y * ((x * 2.0d0) / (x - y))
if (t_0 <= (-0.04d0)) then
tmp = t_1
else if (t_0 <= (-1d-303)) then
tmp = t_0
else if (t_0 <= 0.0d0) then
tmp = t_1
else if (t_0 <= 0.5d0) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((x * 2.0) * y) / (x - y);
double t_1 = y * ((x * 2.0) / (x - y));
double tmp;
if (t_0 <= -0.04) {
tmp = t_1;
} else if (t_0 <= -1e-303) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 0.5) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = ((x * 2.0) * y) / (x - y) t_1 = y * ((x * 2.0) / (x - y)) tmp = 0 if t_0 <= -0.04: tmp = t_1 elif t_0 <= -1e-303: tmp = t_0 elif t_0 <= 0.0: tmp = t_1 elif t_0 <= 0.5: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) t_1 = Float64(y * Float64(Float64(x * 2.0) / Float64(x - y))) tmp = 0.0 if (t_0 <= -0.04) tmp = t_1; elseif (t_0 <= -1e-303) tmp = t_0; elseif (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 0.5) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = ((x * 2.0) * y) / (x - y); t_1 = y * ((x * 2.0) / (x - y)); tmp = 0.0; if (t_0 <= -0.04) tmp = t_1; elseif (t_0 <= -1e-303) tmp = t_0; elseif (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 0.5) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(N[(x * 2.0), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.04], t$95$1, If[LessEqual[t$95$0, -1e-303], t$95$0, If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 0.5], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot 2\right) \cdot y}{x - y}\\
t_1 := y \cdot \frac{x \cdot 2}{x - y}\\
\mathbf{if}\;t\_0 \leq -0.04:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-303}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.5:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -0.0400000000000000008 or -9.99999999999999931e-304 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -0.0 or 0.5 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) Initial program 46.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if -0.0400000000000000008 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -9.99999999999999931e-304 or -0.0 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 0.5Initial program 99.0%
Final simplification99.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (/ (* x 2.0) (- x y)))))
(if (<= x -1.15e-174)
t_0
(if (<= x 1.25e-186) (* -2.0 (fma x (/ x y) x)) t_0))))
double code(double x, double y) {
double t_0 = y * ((x * 2.0) / (x - y));
double tmp;
if (x <= -1.15e-174) {
tmp = t_0;
} else if (x <= 1.25e-186) {
tmp = -2.0 * fma(x, (x / y), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(y * Float64(Float64(x * 2.0) / Float64(x - y))) tmp = 0.0 if (x <= -1.15e-174) tmp = t_0; elseif (x <= 1.25e-186) tmp = Float64(-2.0 * fma(x, Float64(x / y), x)); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(N[(x * 2.0), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.15e-174], t$95$0, If[LessEqual[x, 1.25e-186], N[(-2.0 * N[(x * N[(x / y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x \cdot 2}{x - y}\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{-174}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-186}:\\
\;\;\;\;-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.1499999999999999e-174 or 1.25e-186 < x Initial program 81.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6496.4
Applied rewrites96.4%
if -1.1499999999999999e-174 < x < 1.25e-186Initial program 75.0%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
unpow2N/A
distribute-rgt-outN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6493.4
Applied rewrites93.4%
Final simplification95.8%
(FPCore (x y)
:precision binary64
(if (<= x -5.1e+56)
(+ y y)
(if (<= x 1.72e-121)
(* -2.0 (fma x (/ x y) x))
(+ y (fma (/ y x) (+ y y) y)))))
double code(double x, double y) {
double tmp;
if (x <= -5.1e+56) {
tmp = y + y;
} else if (x <= 1.72e-121) {
tmp = -2.0 * fma(x, (x / y), x);
} else {
tmp = y + fma((y / x), (y + y), y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -5.1e+56) tmp = Float64(y + y); elseif (x <= 1.72e-121) tmp = Float64(-2.0 * fma(x, Float64(x / y), x)); else tmp = Float64(y + fma(Float64(y / x), Float64(y + y), y)); end return tmp end
code[x_, y_] := If[LessEqual[x, -5.1e+56], N[(y + y), $MachinePrecision], If[LessEqual[x, 1.72e-121], N[(-2.0 * N[(x * N[(x / y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(y + N[(N[(y / x), $MachinePrecision] * N[(y + y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\
\;\;\;\;-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + \mathsf{fma}\left(\frac{y}{x}, y + y, y\right)\\
\end{array}
\end{array}
if x < -5.1000000000000002e56Initial program 73.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6473.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.4
Applied rewrites73.4%
Taylor expanded in x around inf
count-2N/A
lower-+.f6480.1
Applied rewrites80.1%
if -5.1000000000000002e56 < x < 1.72000000000000007e-121Initial program 81.3%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
unpow2N/A
distribute-rgt-outN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6479.9
Applied rewrites79.9%
if 1.72000000000000007e-121 < x Initial program 82.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6481.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.8
Applied rewrites81.8%
Taylor expanded in x around inf
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6476.2
Applied rewrites76.2%
Applied rewrites76.2%
Final simplification78.8%
(FPCore (x y) :precision binary64 (if (<= x -5.1e+56) (+ y y) (if (<= x 1.72e-121) (* -2.0 (fma x (/ x y) x)) (* 2.0 (fma y (/ y x) y)))))
double code(double x, double y) {
double tmp;
if (x <= -5.1e+56) {
tmp = y + y;
} else if (x <= 1.72e-121) {
tmp = -2.0 * fma(x, (x / y), x);
} else {
tmp = 2.0 * fma(y, (y / x), y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -5.1e+56) tmp = Float64(y + y); elseif (x <= 1.72e-121) tmp = Float64(-2.0 * fma(x, Float64(x / y), x)); else tmp = Float64(2.0 * fma(y, Float64(y / x), y)); end return tmp end
code[x_, y_] := If[LessEqual[x, -5.1e+56], N[(y + y), $MachinePrecision], If[LessEqual[x, 1.72e-121], N[(-2.0 * N[(x * N[(x / y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[(y / x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\
\;\;\;\;-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, \frac{y}{x}, y\right)\\
\end{array}
\end{array}
if x < -5.1000000000000002e56Initial program 73.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6473.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.4
Applied rewrites73.4%
Taylor expanded in x around inf
count-2N/A
lower-+.f6480.1
Applied rewrites80.1%
if -5.1000000000000002e56 < x < 1.72000000000000007e-121Initial program 81.3%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
unpow2N/A
distribute-rgt-outN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6479.9
Applied rewrites79.9%
if 1.72000000000000007e-121 < x Initial program 82.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6481.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.8
Applied rewrites81.8%
Taylor expanded in x around inf
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6476.2
Applied rewrites76.2%
(FPCore (x y) :precision binary64 (if (<= x -5.1e+56) (+ y y) (if (<= x 1.72e-121) (* x -2.0) (* 2.0 (fma y (/ y x) y)))))
double code(double x, double y) {
double tmp;
if (x <= -5.1e+56) {
tmp = y + y;
} else if (x <= 1.72e-121) {
tmp = x * -2.0;
} else {
tmp = 2.0 * fma(y, (y / x), y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -5.1e+56) tmp = Float64(y + y); elseif (x <= 1.72e-121) tmp = Float64(x * -2.0); else tmp = Float64(2.0 * fma(y, Float64(y / x), y)); end return tmp end
code[x_, y_] := If[LessEqual[x, -5.1e+56], N[(y + y), $MachinePrecision], If[LessEqual[x, 1.72e-121], N[(x * -2.0), $MachinePrecision], N[(2.0 * N[(y * N[(y / x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\
\;\;\;\;x \cdot -2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, \frac{y}{x}, y\right)\\
\end{array}
\end{array}
if x < -5.1000000000000002e56Initial program 73.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6473.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.4
Applied rewrites73.4%
Taylor expanded in x around inf
count-2N/A
lower-+.f6480.1
Applied rewrites80.1%
if -5.1000000000000002e56 < x < 1.72000000000000007e-121Initial program 81.3%
Taylor expanded in x around 0
lower-*.f6479.7
Applied rewrites79.7%
if 1.72000000000000007e-121 < x Initial program 82.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6481.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.8
Applied rewrites81.8%
Taylor expanded in x around inf
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6476.2
Applied rewrites76.2%
Final simplification78.7%
(FPCore (x y) :precision binary64 (if (<= x -5.1e+56) (+ y y) (if (<= x 1.72e-121) (* x -2.0) (+ y y))))
double code(double x, double y) {
double tmp;
if (x <= -5.1e+56) {
tmp = y + y;
} else if (x <= 1.72e-121) {
tmp = x * -2.0;
} else {
tmp = y + y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-5.1d+56)) then
tmp = y + y
else if (x <= 1.72d-121) then
tmp = x * (-2.0d0)
else
tmp = y + y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5.1e+56) {
tmp = y + y;
} else if (x <= 1.72e-121) {
tmp = x * -2.0;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.1e+56: tmp = y + y elif x <= 1.72e-121: tmp = x * -2.0 else: tmp = y + y return tmp
function code(x, y) tmp = 0.0 if (x <= -5.1e+56) tmp = Float64(y + y); elseif (x <= 1.72e-121) tmp = Float64(x * -2.0); else tmp = Float64(y + y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.1e+56) tmp = y + y; elseif (x <= 1.72e-121) tmp = x * -2.0; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.1e+56], N[(y + y), $MachinePrecision], If[LessEqual[x, 1.72e-121], N[(x * -2.0), $MachinePrecision], N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\
\;\;\;\;x \cdot -2\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if x < -5.1000000000000002e56 or 1.72000000000000007e-121 < x Initial program 78.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6478.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.3
Applied rewrites78.3%
Taylor expanded in x around inf
count-2N/A
lower-+.f6477.8
Applied rewrites77.8%
if -5.1000000000000002e56 < x < 1.72000000000000007e-121Initial program 81.3%
Taylor expanded in x around 0
lower-*.f6479.7
Applied rewrites79.7%
Final simplification78.7%
(FPCore (x y) :precision binary64 (+ y y))
double code(double x, double y) {
return y + y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y + y
end function
public static double code(double x, double y) {
return y + y;
}
def code(x, y): return y + y
function code(x, y) return Float64(y + y) end
function tmp = code(x, y) tmp = y + y; end
code[x_, y_] := N[(y + y), $MachinePrecision]
\begin{array}{l}
\\
y + y
\end{array}
Initial program 79.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6488.7
Applied rewrites88.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6479.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.6
Applied rewrites79.6%
Taylor expanded in x around inf
count-2N/A
lower-+.f6452.2
Applied rewrites52.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (/ (* 2.0 x) (- x y)) y)))
(if (< x -1.7210442634149447e+81)
t_0
(if (< x 83645045635564430.0) (/ (* x 2.0) (/ (- x y) y)) t_0))))
double code(double x, double y) {
double t_0 = ((2.0 * x) / (x - y)) * y;
double tmp;
if (x < -1.7210442634149447e+81) {
tmp = t_0;
} else if (x < 83645045635564430.0) {
tmp = (x * 2.0) / ((x - y) / y);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = ((2.0d0 * x) / (x - y)) * y
if (x < (-1.7210442634149447d+81)) then
tmp = t_0
else if (x < 83645045635564430.0d0) then
tmp = (x * 2.0d0) / ((x - y) / y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((2.0 * x) / (x - y)) * y;
double tmp;
if (x < -1.7210442634149447e+81) {
tmp = t_0;
} else if (x < 83645045635564430.0) {
tmp = (x * 2.0) / ((x - y) / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = ((2.0 * x) / (x - y)) * y tmp = 0 if x < -1.7210442634149447e+81: tmp = t_0 elif x < 83645045635564430.0: tmp = (x * 2.0) / ((x - y) / y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(Float64(2.0 * x) / Float64(x - y)) * y) tmp = 0.0 if (x < -1.7210442634149447e+81) tmp = t_0; elseif (x < 83645045635564430.0) tmp = Float64(Float64(x * 2.0) / Float64(Float64(x - y) / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = ((2.0 * x) / (x - y)) * y; tmp = 0.0; if (x < -1.7210442634149447e+81) tmp = t_0; elseif (x < 83645045635564430.0) tmp = (x * 2.0) / ((x - y) / y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(2.0 * x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[Less[x, -1.7210442634149447e+81], t$95$0, If[Less[x, 83645045635564430.0], N[(N[(x * 2.0), $MachinePrecision] / N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2 \cdot x}{x - y} \cdot y\\
\mathbf{if}\;x < -1.7210442634149447 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x < 83645045635564430:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024238
(FPCore (x y)
:name "Linear.Projection:perspective from linear-1.19.1.3, B"
:precision binary64
:alt
(! :herbie-platform default (if (< x -1721044263414944700000000000000000000000000000000000000000000000000000000000000000) (* (/ (* 2 x) (- x y)) y) (if (< x 83645045635564430) (/ (* x 2) (/ (- x y) y)) (* (/ (* 2 x) (- x y)) y))))
(/ (* (* x 2.0) y) (- x y)))