
(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 12 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
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_0 (- INFINITY))
(/ x y)
(if (<= t_0 4e+271) t_0 (/ (+ x -1.0) y)))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = x / y;
} else if (t_0 <= 4e+271) {
tmp = t_0;
} else {
tmp = (x + -1.0) / y;
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = x / y;
} else if (t_0 <= 4e+271) {
tmp = t_0;
} else {
tmp = (x + -1.0) / y;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) tmp = 0 if t_0 <= -math.inf: tmp = x / y elif t_0 <= 4e+271: tmp = t_0 else: tmp = (x + -1.0) / y 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 <= Float64(-Inf)) tmp = Float64(x / y); elseif (t_0 <= 4e+271) tmp = t_0; else tmp = Float64(Float64(x + -1.0) / y); 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 <= -Inf) tmp = x / y; elseif (t_0 <= 4e+271) tmp = t_0; else tmp = (x + -1.0) / y; 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[LessEqual[t$95$0, (-Infinity)], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 4e+271], t$95$0, N[(N[(x + -1.0), $MachinePrecision] / y), $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 -\infty:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+271}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x + -1}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -inf.0Initial program 40.7%
Taylor expanded in x around inf
/-lowering-/.f64100.0
Simplified100.0%
if -inf.0 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 3.99999999999999981e271Initial program 99.9%
if 3.99999999999999981e271 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 62.4%
Taylor expanded in x around inf
associate--l+N/A
+-commutativeN/A
distribute-lft-inN/A
sub-negN/A
distribute-lft-inN/A
distribute-rgt-neg-outN/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
neg-mul-1N/A
distribute-rgt-outN/A
rgt-mult-inverseN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8
Simplified99.8%
Taylor expanded in y around 0
/-lowering-/.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f64100.0
Simplified100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_0 -1000.0)
(/ x y)
(if (<= t_0 1e-5)
(- x (* x x))
(if (<= t_0 2.0) (+ 1.0 (/ -1.0 x)) (/ x y))))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -1000.0) {
tmp = x / y;
} else if (t_0 <= 1e-5) {
tmp = x - (x * x);
} else if (t_0 <= 2.0) {
tmp = 1.0 + (-1.0 / x);
} else {
tmp = x / y;
}
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 <= (-1000.0d0)) then
tmp = x / y
else if (t_0 <= 1d-5) then
tmp = x - (x * x)
else if (t_0 <= 2.0d0) then
tmp = 1.0d0 + ((-1.0d0) / x)
else
tmp = x / y
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 <= -1000.0) {
tmp = x / y;
} else if (t_0 <= 1e-5) {
tmp = x - (x * x);
} else if (t_0 <= 2.0) {
tmp = 1.0 + (-1.0 / x);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) tmp = 0 if t_0 <= -1000.0: tmp = x / y elif t_0 <= 1e-5: tmp = x - (x * x) elif t_0 <= 2.0: tmp = 1.0 + (-1.0 / x) else: tmp = x / y 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 <= -1000.0) tmp = Float64(x / y); elseif (t_0 <= 1e-5) tmp = Float64(x - Float64(x * x)); elseif (t_0 <= 2.0) tmp = Float64(1.0 + Float64(-1.0 / x)); else tmp = Float64(x / y); 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 <= -1000.0) tmp = x / y; elseif (t_0 <= 1e-5) tmp = x - (x * x); elseif (t_0 <= 2.0) tmp = 1.0 + (-1.0 / x); else tmp = x / y; 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[LessEqual[t$95$0, -1000.0], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 1e-5], N[(x - N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], N[(x / y), $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 -1000:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 10^{-5}:\\
\;\;\;\;x - x \cdot x\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1 + \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1e3 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 73.9%
Taylor expanded in x around inf
/-lowering-/.f6483.1
Simplified83.1%
if -1e3 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1.00000000000000008e-5Initial program 100.0%
Taylor expanded in x around 0
Simplified89.4%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-lft-identityN/A
mul-1-negN/A
distribute-lft-neg-outN/A
unpow2N/A
unsub-negN/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f6488.6
Simplified88.6%
if 1.00000000000000008e-5 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 100.0%
Taylor expanded in x around 0
Simplified96.1%
Taylor expanded in x around inf
sub-negN/A
+-lowering-+.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f6494.7
Simplified94.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
(if (<= t_0 -1000.0)
(/ x y)
(if (<= t_0 2e-6) (- x (* x x)) (if (<= t_0 2.0) 1.0 (/ x y))))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double tmp;
if (t_0 <= -1000.0) {
tmp = x / y;
} else if (t_0 <= 2e-6) {
tmp = x - (x * x);
} else if (t_0 <= 2.0) {
tmp = 1.0;
} else {
tmp = x / y;
}
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 <= (-1000.0d0)) then
tmp = x / y
else if (t_0 <= 2d-6) then
tmp = x - (x * x)
else if (t_0 <= 2.0d0) then
tmp = 1.0d0
else
tmp = x / y
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 <= -1000.0) {
tmp = x / y;
} else if (t_0 <= 2e-6) {
tmp = x - (x * x);
} else if (t_0 <= 2.0) {
tmp = 1.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) tmp = 0 if t_0 <= -1000.0: tmp = x / y elif t_0 <= 2e-6: tmp = x - (x * x) elif t_0 <= 2.0: tmp = 1.0 else: tmp = x / y 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 <= -1000.0) tmp = Float64(x / y); elseif (t_0 <= 2e-6) tmp = Float64(x - Float64(x * x)); elseif (t_0 <= 2.0) tmp = 1.0; else tmp = Float64(x / y); 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 <= -1000.0) tmp = x / y; elseif (t_0 <= 2e-6) tmp = x - (x * x); elseif (t_0 <= 2.0) tmp = 1.0; else tmp = x / y; 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[LessEqual[t$95$0, -1000.0], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 2e-6], N[(x - N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2.0], 1.0, N[(x / y), $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 -1000:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-6}:\\
\;\;\;\;x - x \cdot x\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1e3 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 73.9%
Taylor expanded in x around inf
/-lowering-/.f6483.1
Simplified83.1%
if -1e3 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1.99999999999999991e-6Initial program 100.0%
Taylor expanded in x around 0
Simplified90.2%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-lft-identityN/A
mul-1-negN/A
distribute-lft-neg-outN/A
unpow2N/A
unsub-negN/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f6489.4
Simplified89.4%
if 1.99999999999999991e-6 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 100.0%
Taylor expanded in x around 0
Simplified93.3%
Taylor expanded in x around inf
Simplified89.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ (/ x y) 1.0)) (t_1 (/ (* x t_0) (+ x 1.0)))) (if (<= t_1 -1000.0) t_0 (if (<= t_1 1e-5) (- x (* x x)) t_0))))
double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double t_1 = (x * t_0) / (x + 1.0);
double tmp;
if (t_1 <= -1000.0) {
tmp = t_0;
} else if (t_1 <= 1e-5) {
tmp = x - (x * x);
} 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) :: t_1
real(8) :: tmp
t_0 = (x / y) + 1.0d0
t_1 = (x * t_0) / (x + 1.0d0)
if (t_1 <= (-1000.0d0)) then
tmp = t_0
else if (t_1 <= 1d-5) then
tmp = x - (x * x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double t_1 = (x * t_0) / (x + 1.0);
double tmp;
if (t_1 <= -1000.0) {
tmp = t_0;
} else if (t_1 <= 1e-5) {
tmp = x - (x * x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x / y) + 1.0 t_1 = (x * t_0) / (x + 1.0) tmp = 0 if t_1 <= -1000.0: tmp = t_0 elif t_1 <= 1e-5: tmp = x - (x * x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x / y) + 1.0) t_1 = Float64(Float64(x * t_0) / Float64(x + 1.0)) tmp = 0.0 if (t_1 <= -1000.0) tmp = t_0; elseif (t_1 <= 1e-5) tmp = Float64(x - Float64(x * x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) + 1.0; t_1 = (x * t_0) / (x + 1.0); tmp = 0.0; if (t_1 <= -1000.0) tmp = t_0; elseif (t_1 <= 1e-5) tmp = x - (x * x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * t$95$0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1000.0], t$95$0, If[LessEqual[t$95$1, 1e-5], N[(x - N[(x * x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + 1\\
t_1 := \frac{x \cdot t\_0}{x + 1}\\
\mathbf{if}\;t\_1 \leq -1000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{-5}:\\
\;\;\;\;x - x \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1e3 or 1.00000000000000008e-5 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 79.4%
Taylor expanded in x around inf
associate--l+N/A
+-commutativeN/A
distribute-lft-inN/A
sub-negN/A
distribute-lft-inN/A
distribute-rgt-neg-outN/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
neg-mul-1N/A
distribute-rgt-outN/A
rgt-mult-inverseN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6486.3
Simplified86.3%
Taylor expanded in x around inf
Simplified86.2%
+-lowering-+.f64N/A
*-commutativeN/A
div-invN/A
/-lowering-/.f6486.4
Applied egg-rr86.4%
if -1e3 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1.00000000000000008e-5Initial program 100.0%
Taylor expanded in x around 0
Simplified89.4%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-lft-identityN/A
mul-1-negN/A
distribute-lft-neg-outN/A
unpow2N/A
unsub-negN/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f6488.6
Simplified88.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))) (if (<= t_0 -500000000000.0) (- (* x x)) (if (<= t_0 2e-6) 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 <= -500000000000.0) {
tmp = -(x * x);
} else if (t_0 <= 2e-6) {
tmp = x;
} else {
tmp = 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 <= (-500000000000.0d0)) then
tmp = -(x * x)
else if (t_0 <= 2d-6) then
tmp = x
else
tmp = 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 <= -500000000000.0) {
tmp = -(x * x);
} else if (t_0 <= 2e-6) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) tmp = 0 if t_0 <= -500000000000.0: tmp = -(x * x) elif t_0 <= 2e-6: tmp = x else: tmp = 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 <= -500000000000.0) tmp = Float64(-Float64(x * x)); elseif (t_0 <= 2e-6) tmp = x; else tmp = 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 <= -500000000000.0) tmp = -(x * x); elseif (t_0 <= 2e-6) tmp = x; else tmp = 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[LessEqual[t$95$0, -500000000000.0], (-N[(x * x), $MachinePrecision]), If[LessEqual[t$95$0, 2e-6], x, 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\mathbf{if}\;t\_0 \leq -500000000000:\\
\;\;\;\;-x \cdot x\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-6}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -5e11Initial program 66.4%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
accelerator-lowering-fma.f64N/A
distribute-rgt-out--N/A
associate-*l/N/A
*-lft-identityN/A
*-lft-identityN/A
--lowering--.f64N/A
/-lowering-/.f6427.4
Simplified27.4%
Taylor expanded in y around inf
mul-1-negN/A
neg-lowering-neg.f6421.0
Simplified21.0%
Taylor expanded in x around inf
mul-1-negN/A
neg-lowering-neg.f64N/A
unpow2N/A
*-lowering-*.f6421.3
Simplified21.3%
if -5e11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1.99999999999999991e-6Initial program 100.0%
Taylor expanded in x around 0
Simplified87.8%
if 1.99999999999999991e-6 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 86.2%
Taylor expanded in x around 0
Simplified33.1%
Taylor expanded in x around inf
Simplified32.4%
(FPCore (x y) :precision binary64 (if (<= (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)) 2e-6) (- x (* x x)) 1.0))
double code(double x, double y) {
double tmp;
if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 2e-6) {
tmp = x - (x * x);
} else {
tmp = 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 * ((x / y) + 1.0d0)) / (x + 1.0d0)) <= 2d-6) then
tmp = x - (x * x)
else
tmp = 1.0d0
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)) <= 2e-6) {
tmp = x - (x * x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if ((x * ((x / y) + 1.0)) / (x + 1.0)) <= 2e-6: tmp = x - (x * x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) <= 2e-6) tmp = Float64(x - Float64(x * x)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 2e-6) tmp = x - (x * x); else tmp = 1.0; 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], 2e-6], N[(x - N[(x * x), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;x - x \cdot x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1.99999999999999991e-6Initial program 88.5%
Taylor expanded in x around 0
Simplified59.2%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-lft-identityN/A
mul-1-negN/A
distribute-lft-neg-outN/A
unpow2N/A
unsub-negN/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f6465.5
Simplified65.5%
if 1.99999999999999991e-6 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 86.2%
Taylor expanded in x around 0
Simplified33.1%
Taylor expanded in x around inf
Simplified32.4%
(FPCore (x y) :precision binary64 (if (<= (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)) 2e-6) x 1.0))
double code(double x, double y) {
double tmp;
if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 2e-6) {
tmp = x;
} else {
tmp = 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 * ((x / y) + 1.0d0)) / (x + 1.0d0)) <= 2d-6) then
tmp = x
else
tmp = 1.0d0
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)) <= 2e-6) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if ((x * ((x / y) + 1.0)) / (x + 1.0)) <= 2e-6: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) <= 2e-6) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 2e-6) tmp = x; else tmp = 1.0; 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], 2e-6], x, 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1.99999999999999991e-6Initial program 88.5%
Taylor expanded in x around 0
Simplified59.0%
if 1.99999999999999991e-6 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 86.2%
Taylor expanded in x around 0
Simplified33.1%
Taylor expanded in x around inf
Simplified32.4%
(FPCore (x y) :precision binary64 (let* ((t_0 (fma (/ 1.0 y) (+ x -1.0) 1.0))) (if (<= x -1.0) t_0 (if (<= x 1.0) (fma x (- (/ x y) x) x) t_0))))
double code(double x, double y) {
double t_0 = fma((1.0 / y), (x + -1.0), 1.0);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = fma(x, ((x / y) - x), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = fma(Float64(1.0 / y), Float64(x + -1.0), 1.0) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= 1.0) tmp = fma(x, Float64(Float64(x / y) - x), x); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 / y), $MachinePrecision] * N[(x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 1.0], N[(x * N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{1}{y}, x + -1, 1\right)\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{y} - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 76.5%
Taylor expanded in x around inf
associate--l+N/A
+-commutativeN/A
distribute-lft-inN/A
sub-negN/A
distribute-lft-inN/A
distribute-rgt-neg-outN/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
neg-mul-1N/A
distribute-rgt-outN/A
rgt-mult-inverseN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6498.4
Simplified98.4%
if -1 < x < 1Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
accelerator-lowering-fma.f64N/A
distribute-rgt-out--N/A
associate-*l/N/A
*-lft-identityN/A
*-lft-identityN/A
--lowering--.f64N/A
/-lowering-/.f6499.0
Simplified99.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ (/ x y) 1.0))) (if (<= x -1.0) t_0 (if (<= x 0.8) (fma x (- (/ x y) x) x) t_0))))
double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 0.8) {
tmp = fma(x, ((x / y) - x), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x / y) + 1.0) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= 0.8) tmp = fma(x, Float64(Float64(x / y) - x), x); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 0.8], N[(x * N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + 1\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.8:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{y} - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1 or 0.80000000000000004 < x Initial program 76.5%
Taylor expanded in x around inf
associate--l+N/A
+-commutativeN/A
distribute-lft-inN/A
sub-negN/A
distribute-lft-inN/A
distribute-rgt-neg-outN/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
neg-mul-1N/A
distribute-rgt-outN/A
rgt-mult-inverseN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6498.4
Simplified98.4%
Taylor expanded in x around inf
Simplified97.8%
+-lowering-+.f64N/A
*-commutativeN/A
div-invN/A
/-lowering-/.f6498.0
Applied egg-rr98.0%
if -1 < x < 0.80000000000000004Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
accelerator-lowering-fma.f64N/A
distribute-rgt-out--N/A
associate-*l/N/A
*-lft-identityN/A
*-lft-identityN/A
--lowering--.f64N/A
/-lowering-/.f6499.0
Simplified99.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ (/ x y) 1.0))) (if (<= x -1.0) t_0 (if (<= x 1.0) (fma x (/ x y) x) t_0))))
double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = fma(x, (x / y), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x / y) + 1.0) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= 1.0) tmp = fma(x, Float64(x / y), x); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 1.0], N[(x * N[(x / y), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + 1\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{y}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 76.5%
Taylor expanded in x around inf
associate--l+N/A
+-commutativeN/A
distribute-lft-inN/A
sub-negN/A
distribute-lft-inN/A
distribute-rgt-neg-outN/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
neg-mul-1N/A
distribute-rgt-outN/A
rgt-mult-inverseN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6498.4
Simplified98.4%
Taylor expanded in x around inf
Simplified97.8%
+-lowering-+.f64N/A
*-commutativeN/A
div-invN/A
/-lowering-/.f6498.0
Applied egg-rr98.0%
if -1 < x < 1Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
accelerator-lowering-fma.f64N/A
distribute-rgt-out--N/A
associate-*l/N/A
*-lft-identityN/A
*-lft-identityN/A
--lowering--.f64N/A
/-lowering-/.f6499.0
Simplified99.0%
Taylor expanded in y around 0
/-lowering-/.f6498.4
Simplified98.4%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ (/ x y) 1.0))) (if (<= x -320000.0) t_0 (if (<= x 30000000.0) (/ x (+ x 1.0)) t_0))))
double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double tmp;
if (x <= -320000.0) {
tmp = t_0;
} else if (x <= 30000000.0) {
tmp = x / (x + 1.0);
} 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 = (x / y) + 1.0d0
if (x <= (-320000.0d0)) then
tmp = t_0
else if (x <= 30000000.0d0) then
tmp = x / (x + 1.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double tmp;
if (x <= -320000.0) {
tmp = t_0;
} else if (x <= 30000000.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x / y) + 1.0 tmp = 0 if x <= -320000.0: tmp = t_0 elif x <= 30000000.0: tmp = x / (x + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x / y) + 1.0) tmp = 0.0 if (x <= -320000.0) tmp = t_0; elseif (x <= 30000000.0) tmp = Float64(x / Float64(x + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) + 1.0; tmp = 0.0; if (x <= -320000.0) tmp = t_0; elseif (x <= 30000000.0) tmp = x / (x + 1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -320000.0], t$95$0, If[LessEqual[x, 30000000.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + 1\\
\mathbf{if}\;x \leq -320000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 30000000:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.2e5 or 3e7 < x Initial program 76.0%
Taylor expanded in x around inf
associate--l+N/A
+-commutativeN/A
distribute-lft-inN/A
sub-negN/A
distribute-lft-inN/A
distribute-rgt-neg-outN/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
neg-mul-1N/A
distribute-rgt-outN/A
rgt-mult-inverseN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.7
Simplified99.7%
Taylor expanded in x around inf
Simplified99.1%
+-lowering-+.f64N/A
*-commutativeN/A
div-invN/A
/-lowering-/.f6499.3
Applied egg-rr99.3%
if -3.2e5 < x < 3e7Initial program 99.9%
Taylor expanded in x around 0
Simplified75.5%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 87.6%
Taylor expanded in x around 0
Simplified48.9%
Taylor expanded in x around inf
Simplified14.5%
(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 2024204
(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)))