
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
(FPCore (x y) :precision binary64 (* (/ x (+ 1.0 x)) (+ 1.0 (/ x y))))
double code(double x, double y) {
return (x / (1.0 + x)) * (1.0 + (x / y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / (1.0d0 + x)) * (1.0d0 + (x / y))
end function
public static double code(double x, double y) {
return (x / (1.0 + x)) * (1.0 + (x / y));
}
def code(x, y): return (x / (1.0 + x)) * (1.0 + (x / y))
function code(x, y) return Float64(Float64(x / Float64(1.0 + x)) * Float64(1.0 + Float64(x / y))) end
function tmp = code(x, y) tmp = (x / (1.0 + x)) * (1.0 + (x / y)); end
code[x_, y_] := N[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1 + x} \cdot \left(1 + \frac{x}{y}\right)
\end{array}
Initial program 86.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ y x) (pow y -1.0))))
(if (<= x -1.1e+44)
t_0
(if (<= x 2.25e-169)
(/ x (- x -1.0))
(if (<= x 1.0) (* (+ y x) (/ x y)) t_0)))))
double code(double x, double y) {
double t_0 = (y + x) * pow(y, -1.0);
double tmp;
if (x <= -1.1e+44) {
tmp = t_0;
} else if (x <= 2.25e-169) {
tmp = x / (x - -1.0);
} else if (x <= 1.0) {
tmp = (y + x) * (x / 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 = (y + x) * (y ** (-1.0d0))
if (x <= (-1.1d+44)) then
tmp = t_0
else if (x <= 2.25d-169) then
tmp = x / (x - (-1.0d0))
else if (x <= 1.0d0) then
tmp = (y + x) * (x / y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (y + x) * Math.pow(y, -1.0);
double tmp;
if (x <= -1.1e+44) {
tmp = t_0;
} else if (x <= 2.25e-169) {
tmp = x / (x - -1.0);
} else if (x <= 1.0) {
tmp = (y + x) * (x / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y + x) * math.pow(y, -1.0) tmp = 0 if x <= -1.1e+44: tmp = t_0 elif x <= 2.25e-169: tmp = x / (x - -1.0) elif x <= 1.0: tmp = (y + x) * (x / y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(y + x) * (y ^ -1.0)) tmp = 0.0 if (x <= -1.1e+44) tmp = t_0; elseif (x <= 2.25e-169) tmp = Float64(x / Float64(x - -1.0)); elseif (x <= 1.0) tmp = Float64(Float64(y + x) * Float64(x / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (y + x) * (y ^ -1.0); tmp = 0.0; if (x <= -1.1e+44) tmp = t_0; elseif (x <= 2.25e-169) tmp = x / (x - -1.0); elseif (x <= 1.0) tmp = (y + x) * (x / y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(y + x), $MachinePrecision] * N[Power[y, -1.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.1e+44], t$95$0, If[LessEqual[x, 2.25e-169], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(y + x), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y + x\right) \cdot {y}^{-1}\\
\mathbf{if}\;x \leq -1.1 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{-169}:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\left(y + x\right) \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.09999999999999998e44 or 1 < x Initial program 72.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
div-add-revN/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
unpow2N/A
distribute-lft-outN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6461.9
Applied rewrites61.9%
Taylor expanded in y around 0
div-add-revN/A
associate-/l/N/A
*-commutativeN/A
+-commutativeN/A
unpow2N/A
distribute-lft-inN/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6474.9
Applied rewrites74.9%
Taylor expanded in x around inf
Applied rewrites99.5%
if -1.09999999999999998e44 < x < 2.2499999999999999e-169Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
rgt-mult-inverseN/A
cancel-sign-subN/A
distribute-lft-neg-outN/A
rgt-mult-inverseN/A
metadata-evalN/A
lower--.f6484.6
Applied rewrites84.6%
if 2.2499999999999999e-169 < x < 1Initial program 99.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
div-add-revN/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
unpow2N/A
distribute-lft-outN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6498.8
Applied rewrites98.8%
Taylor expanded in y around 0
div-add-revN/A
associate-/l/N/A
*-commutativeN/A
+-commutativeN/A
unpow2N/A
distribute-lft-inN/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6486.2
Applied rewrites86.2%
Taylor expanded in x around 0
Applied rewrites84.3%
Final simplification92.1%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.84))) (* (+ y x) (pow y -1.0)) (fma (- (/ x y) x) x x)))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.84)) {
tmp = (y + x) * pow(y, -1.0);
} else {
tmp = fma(((x / y) - x), x, x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.84)) tmp = Float64(Float64(y + x) * (y ^ -1.0)); else tmp = fma(Float64(Float64(x / y) - x), x, x); end return tmp end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.84]], $MachinePrecision]], N[(N[(y + x), $MachinePrecision] * N[Power[y, -1.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.84\right):\\
\;\;\;\;\left(y + x\right) \cdot {y}^{-1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\
\end{array}
\end{array}
if x < -1 or 0.839999999999999969 < x Initial program 73.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
div-add-revN/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
unpow2N/A
distribute-lft-outN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6462.3
Applied rewrites62.3%
Taylor expanded in y around 0
div-add-revN/A
associate-/l/N/A
*-commutativeN/A
+-commutativeN/A
unpow2N/A
distribute-lft-inN/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6474.9
Applied rewrites74.9%
Taylor expanded in x around inf
Applied rewrites98.7%
if -1 < x < 0.839999999999999969Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6499.0
Applied rewrites99.0%
Taylor expanded in x around inf
Applied rewrites99.1%
Final simplification98.9%
(FPCore (x y) :precision binary64 (if (or (<= x -1.1e+44) (not (<= x 1.25e-11))) (* (+ y x) (pow y -1.0)) (/ x (- x -1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.1e+44) || !(x <= 1.25e-11)) {
tmp = (y + x) * pow(y, -1.0);
} else {
tmp = x / (x - -1.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1.1d+44)) .or. (.not. (x <= 1.25d-11))) then
tmp = (y + x) * (y ** (-1.0d0))
else
tmp = x / (x - (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.1e+44) || !(x <= 1.25e-11)) {
tmp = (y + x) * Math.pow(y, -1.0);
} else {
tmp = x / (x - -1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.1e+44) or not (x <= 1.25e-11): tmp = (y + x) * math.pow(y, -1.0) else: tmp = x / (x - -1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.1e+44) || !(x <= 1.25e-11)) tmp = Float64(Float64(y + x) * (y ^ -1.0)); else tmp = Float64(x / Float64(x - -1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.1e+44) || ~((x <= 1.25e-11))) tmp = (y + x) * (y ^ -1.0); else tmp = x / (x - -1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.1e+44], N[Not[LessEqual[x, 1.25e-11]], $MachinePrecision]], N[(N[(y + x), $MachinePrecision] * N[Power[y, -1.0], $MachinePrecision]), $MachinePrecision], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{+44} \lor \neg \left(x \leq 1.25 \cdot 10^{-11}\right):\\
\;\;\;\;\left(y + x\right) \cdot {y}^{-1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - -1}\\
\end{array}
\end{array}
if x < -1.09999999999999998e44 or 1.25000000000000005e-11 < x Initial program 72.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
div-add-revN/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
unpow2N/A
distribute-lft-outN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6462.2
Applied rewrites62.2%
Taylor expanded in y around 0
div-add-revN/A
associate-/l/N/A
*-commutativeN/A
+-commutativeN/A
unpow2N/A
distribute-lft-inN/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6475.1
Applied rewrites75.1%
Taylor expanded in x around inf
Applied rewrites98.8%
if -1.09999999999999998e44 < x < 1.25000000000000005e-11Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
rgt-mult-inverseN/A
cancel-sign-subN/A
distribute-lft-neg-outN/A
rgt-mult-inverseN/A
metadata-evalN/A
lower--.f6479.7
Applied rewrites79.7%
Final simplification89.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (or (<= t_0 -2e+16) (not (<= t_0 5e+166)))
(/ (* (/ x (+ 1.0 x)) x) y)
(/ (fma (/ x y) x x) (+ x 1.0)))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if ((t_0 <= -2e+16) || !(t_0 <= 5e+166)) {
tmp = ((x / (1.0 + x)) * x) / y;
} else {
tmp = fma((x / y), x, x) / (x + 1.0);
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if ((t_0 <= -2e+16) || !(t_0 <= 5e+166)) tmp = Float64(Float64(Float64(x / Float64(1.0 + x)) * x) / y); else tmp = Float64(fma(Float64(x / y), x, x) / Float64(x + 1.0)); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e+16], N[Not[LessEqual[t$95$0, 5e+166]], $MachinePrecision]], N[(N[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / y), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+16} \lor \neg \left(t\_0 \leq 5 \cdot 10^{+166}\right):\\
\;\;\;\;\frac{\frac{x}{1 + x} \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x + 1}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -2e16 or 5.0000000000000002e166 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 62.5%
Taylor expanded in y around 0
unpow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6487.4
Applied rewrites87.4%
Applied rewrites99.9%
if -2e16 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 5.0000000000000002e166Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6499.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (or (<= t_0 -200000000000.0) (not (<= t_0 2.0)))
(/ x y)
(/ x (- x -1.0)))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if ((t_0 <= -200000000000.0) || !(t_0 <= 2.0)) {
tmp = x / y;
} else {
tmp = x / (x - -1.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 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
if ((t_0 <= (-200000000000.0d0)) .or. (.not. (t_0 <= 2.0d0))) then
tmp = x / y
else
tmp = x / (x - (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if ((t_0 <= -200000000000.0) || !(t_0 <= 2.0)) {
tmp = x / y;
} else {
tmp = x / (x - -1.0);
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) tmp = 0 if (t_0 <= -200000000000.0) or not (t_0 <= 2.0): tmp = x / y else: tmp = x / (x - -1.0) return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if ((t_0 <= -200000000000.0) || !(t_0 <= 2.0)) tmp = Float64(x / y); else tmp = Float64(x / Float64(x - -1.0)); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x + 1.0); tmp = 0.0; if ((t_0 <= -200000000000.0) || ~((t_0 <= 2.0))) tmp = x / y; else tmp = x / (x - -1.0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -200000000000.0], N[Not[LessEqual[t$95$0, 2.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_0 \leq -200000000000 \lor \neg \left(t\_0 \leq 2\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - -1}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -2e11 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 69.5%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
lift-/.f64N/A
frac-2negN/A
associate-*l/N/A
associate-/l*N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
frac-2negN/A
remove-double-negN/A
lower-/.f64N/A
lift-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6410.2
Applied rewrites10.2%
Taylor expanded in x around inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f640.8
Applied rewrites0.8%
Applied rewrites89.1%
if -2e11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
rgt-mult-inverseN/A
cancel-sign-subN/A
distribute-lft-neg-outN/A
rgt-mult-inverseN/A
metadata-evalN/A
lower--.f6488.6
Applied rewrites88.6%
Final simplification88.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (or (<= t_0 -200000000000.0) (not (<= t_0 1e-11)))
(/ x y)
(* (- 1.0 x) x))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if ((t_0 <= -200000000000.0) || !(t_0 <= 1e-11)) {
tmp = x / y;
} else {
tmp = (1.0 - x) * x;
}
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 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
if ((t_0 <= (-200000000000.0d0)) .or. (.not. (t_0 <= 1d-11))) then
tmp = x / y
else
tmp = (1.0d0 - x) * x
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if ((t_0 <= -200000000000.0) || !(t_0 <= 1e-11)) {
tmp = x / y;
} else {
tmp = (1.0 - x) * x;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) tmp = 0 if (t_0 <= -200000000000.0) or not (t_0 <= 1e-11): tmp = x / y else: tmp = (1.0 - x) * x return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) tmp = 0.0 if ((t_0 <= -200000000000.0) || !(t_0 <= 1e-11)) tmp = Float64(x / y); else tmp = Float64(Float64(1.0 - x) * x); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x + 1.0); tmp = 0.0; if ((t_0 <= -200000000000.0) || ~((t_0 <= 1e-11))) tmp = x / y; else tmp = (1.0 - x) * x; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -200000000000.0], N[Not[LessEqual[t$95$0, 1e-11]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_0 \leq -200000000000 \lor \neg \left(t\_0 \leq 10^{-11}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - x\right) \cdot x\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -2e11 or 9.99999999999999939e-12 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 75.4%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
lift-/.f64N/A
frac-2negN/A
associate-*l/N/A
associate-/l*N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
frac-2negN/A
remove-double-negN/A
lower-/.f64N/A
lift-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6421.1
Applied rewrites21.1%
Taylor expanded in x around inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f641.5
Applied rewrites1.5%
Applied rewrites72.7%
if -2e11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 9.99999999999999939e-12Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6499.5
Applied rewrites99.5%
Taylor expanded in y around inf
Applied rewrites86.1%
Final simplification78.5%
(FPCore (x y) :precision binary64 (if (<= (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)) -5e+15) (* (- x) x) (* 1.0 x)))
double code(double x, double y) {
double tmp;
if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= -5e+15) {
tmp = -x * x;
} else {
tmp = 1.0 * x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (((x * ((x / y) + 1.0d0)) / (x + 1.0d0)) <= (-5d+15)) then
tmp = -x * x
else
tmp = 1.0d0 * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= -5e+15) {
tmp = -x * x;
} else {
tmp = 1.0 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if ((x * ((x / y) + 1.0)) / (x + 1.0)) <= -5e+15: tmp = -x * x else: tmp = 1.0 * x return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) <= -5e+15) tmp = Float64(Float64(-x) * x); else tmp = Float64(1.0 * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= -5e+15) tmp = -x * x; else tmp = 1.0 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], -5e+15], N[((-x) * x), $MachinePrecision], N[(1.0 * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \leq -5 \cdot 10^{+15}:\\
\;\;\;\;\left(-x\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;1 \cdot x\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -5e15Initial program 61.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6419.9
Applied rewrites19.9%
Taylor expanded in y around inf
Applied rewrites28.4%
Taylor expanded in x around inf
Applied rewrites28.4%
if -5e15 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 94.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6466.8
Applied rewrites66.8%
Taylor expanded in y around inf
Applied rewrites49.9%
Taylor expanded in x around 0
Applied rewrites50.4%
(FPCore (x y) :precision binary64 (* (- 1.0 x) x))
double code(double x, double y) {
return (1.0 - x) * x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) * x
end function
public static double code(double x, double y) {
return (1.0 - x) * x;
}
def code(x, y): return (1.0 - x) * x
function code(x, y) return Float64(Float64(1.0 - x) * x) end
function tmp = code(x, y) tmp = (1.0 - x) * x; end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) \cdot x
\end{array}
Initial program 86.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6455.3
Applied rewrites55.3%
Taylor expanded in y around inf
Applied rewrites44.6%
(FPCore (x y) :precision binary64 (* 1.0 x))
double code(double x, double y) {
return 1.0 * x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 * x
end function
public static double code(double x, double y) {
return 1.0 * x;
}
def code(x, y): return 1.0 * x
function code(x, y) return Float64(1.0 * x) end
function tmp = code(x, y) tmp = 1.0 * x; end
code[x_, y_] := N[(1.0 * x), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot x
\end{array}
Initial program 86.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6455.3
Applied rewrites55.3%
Taylor expanded in y around inf
Applied rewrites44.6%
Taylor expanded in x around 0
Applied rewrites38.9%
(FPCore (x y) :precision binary64 (* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0))))
double code(double x, double y) {
return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / 1.0d0) * (((x / y) + 1.0d0) / (x + 1.0d0))
end function
public static double code(double x, double y) {
return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0));
}
def code(x, y): return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0))
function code(x, y) return Float64(Float64(x / 1.0) * Float64(Float64(Float64(x / y) + 1.0) / Float64(x + 1.0))) end
function tmp = code(x, y) tmp = (x / 1.0) * (((x / y) + 1.0) / (x + 1.0)); end
code[x_, y_] := N[(N[(x / 1.0), $MachinePrecision] * N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1} \cdot \frac{\frac{x}{y} + 1}{x + 1}
\end{array}
herbie shell --seed 2024326
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:alt
(! :herbie-platform default (* (/ x 1) (/ (+ (/ x y) 1) (+ x 1))))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))