
(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 11 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 (/ (+ (/ 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(x * Float64(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[(x * N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\frac{x}{y} + 1}{x + 1}
\end{array}
Initial program 87.5%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.9%
Simplified99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (+ x y) y)) (t_1 (/ x (+ x 1.0))))
(if (<= x -6300000.0)
t_0
(if (<= x 2.95e-95)
t_1
(if (<= x 2e-48) (/ x (/ y x)) (if (<= x 1400.0) t_1 t_0))))))
double code(double x, double y) {
double t_0 = (x + y) / y;
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -6300000.0) {
tmp = t_0;
} else if (x <= 2.95e-95) {
tmp = t_1;
} else if (x <= 2e-48) {
tmp = x / (y / x);
} else if (x <= 1400.0) {
tmp = t_1;
} 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) / y
t_1 = x / (x + 1.0d0)
if (x <= (-6300000.0d0)) then
tmp = t_0
else if (x <= 2.95d-95) then
tmp = t_1
else if (x <= 2d-48) then
tmp = x / (y / x)
else if (x <= 1400.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x + y) / y;
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -6300000.0) {
tmp = t_0;
} else if (x <= 2.95e-95) {
tmp = t_1;
} else if (x <= 2e-48) {
tmp = x / (y / x);
} else if (x <= 1400.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) / y t_1 = x / (x + 1.0) tmp = 0 if x <= -6300000.0: tmp = t_0 elif x <= 2.95e-95: tmp = t_1 elif x <= 2e-48: tmp = x / (y / x) elif x <= 1400.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) / y) t_1 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -6300000.0) tmp = t_0; elseif (x <= 2.95e-95) tmp = t_1; elseif (x <= 2e-48) tmp = Float64(x / Float64(y / x)); elseif (x <= 1400.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x + y) / y; t_1 = x / (x + 1.0); tmp = 0.0; if (x <= -6300000.0) tmp = t_0; elseif (x <= 2.95e-95) tmp = t_1; elseif (x <= 2e-48) tmp = x / (y / x); elseif (x <= 1400.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6300000.0], t$95$0, If[LessEqual[x, 2.95e-95], t$95$1, If[LessEqual[x, 2e-48], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1400.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{y}\\
t_1 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -6300000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.95 \cdot 10^{-95}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-48}:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;x \leq 1400:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -6.3e6 or 1400 < x Initial program 73.2%
Taylor expanded in x around inf
Simplified72.6%
Taylor expanded in y around 0
/-lowering-/.f64N/A
+-lowering-+.f6499.4%
Simplified99.4%
if -6.3e6 < x < 2.9499999999999999e-95 or 1.9999999999999999e-48 < x < 1400Initial program 99.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in y around inf
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6477.5%
Simplified77.5%
if 2.9499999999999999e-95 < x < 1.9999999999999999e-48Initial program 99.8%
*-commutativeN/A
distribute-lft1-inN/A
+-lowering-+.f64N/A
associate-/r/N/A
/-lowering-/.f64N/A
/-lowering-/.f6499.9%
Applied egg-rr99.9%
Taylor expanded in x around 0
Simplified99.9%
/-rgt-identityN/A
associate-/r/N/A
associate-*l/N/A
remove-double-divN/A
frac-addN/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
*-rgt-identityN/A
div-invN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f6492.5%
Applied egg-rr92.5%
Taylor expanded in x around inf
Simplified83.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -1.75e+21)
(/ x y)
(if (<= x 3.6e-95)
t_0
(if (<= x 2.3e-46) (/ x (/ y x)) (if (<= x 2.45e+30) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -1.75e+21) {
tmp = x / y;
} else if (x <= 3.6e-95) {
tmp = t_0;
} else if (x <= 2.3e-46) {
tmp = x / (y / x);
} else if (x <= 2.45e+30) {
tmp = t_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 + 1.0d0)
if (x <= (-1.75d+21)) then
tmp = x / y
else if (x <= 3.6d-95) then
tmp = t_0
else if (x <= 2.3d-46) then
tmp = x / (y / x)
else if (x <= 2.45d+30) then
tmp = t_0
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -1.75e+21) {
tmp = x / y;
} else if (x <= 3.6e-95) {
tmp = t_0;
} else if (x <= 2.3e-46) {
tmp = x / (y / x);
} else if (x <= 2.45e+30) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -1.75e+21: tmp = x / y elif x <= 3.6e-95: tmp = t_0 elif x <= 2.3e-46: tmp = x / (y / x) elif x <= 2.45e+30: tmp = t_0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -1.75e+21) tmp = Float64(x / y); elseif (x <= 3.6e-95) tmp = t_0; elseif (x <= 2.3e-46) tmp = Float64(x / Float64(y / x)); elseif (x <= 2.45e+30) tmp = t_0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + 1.0); tmp = 0.0; if (x <= -1.75e+21) tmp = x / y; elseif (x <= 3.6e-95) tmp = t_0; elseif (x <= 2.3e-46) tmp = x / (y / x); elseif (x <= 2.45e+30) tmp = t_0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.75e+21], N[(x / y), $MachinePrecision], If[LessEqual[x, 3.6e-95], t$95$0, If[LessEqual[x, 2.3e-46], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.45e+30], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -1.75 \cdot 10^{+21}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-95}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-46}:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;x \leq 2.45 \cdot 10^{+30}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.75e21 or 2.44999999999999992e30 < x Initial program 72.0%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in x around inf
/-lowering-/.f6478.2%
Simplified78.2%
if -1.75e21 < x < 3.6e-95 or 2.2999999999999999e-46 < x < 2.44999999999999992e30Initial program 99.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in y around inf
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6476.8%
Simplified76.8%
if 3.6e-95 < x < 2.2999999999999999e-46Initial program 99.8%
*-commutativeN/A
distribute-lft1-inN/A
+-lowering-+.f64N/A
associate-/r/N/A
/-lowering-/.f64N/A
/-lowering-/.f6499.9%
Applied egg-rr99.9%
Taylor expanded in x around 0
Simplified99.9%
/-rgt-identityN/A
associate-/r/N/A
associate-*l/N/A
remove-double-divN/A
frac-addN/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
*-rgt-identityN/A
div-invN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f6492.5%
Applied egg-rr92.5%
Taylor expanded in x around inf
Simplified83.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -5.5e+21)
(/ x y)
(if (<= x 3.6e-95)
t_0
(if (<= x 4.5e-47) (* x (/ x y)) (if (<= x 1.3e+30) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -5.5e+21) {
tmp = x / y;
} else if (x <= 3.6e-95) {
tmp = t_0;
} else if (x <= 4.5e-47) {
tmp = x * (x / y);
} else if (x <= 1.3e+30) {
tmp = t_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 + 1.0d0)
if (x <= (-5.5d+21)) then
tmp = x / y
else if (x <= 3.6d-95) then
tmp = t_0
else if (x <= 4.5d-47) then
tmp = x * (x / y)
else if (x <= 1.3d+30) then
tmp = t_0
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -5.5e+21) {
tmp = x / y;
} else if (x <= 3.6e-95) {
tmp = t_0;
} else if (x <= 4.5e-47) {
tmp = x * (x / y);
} else if (x <= 1.3e+30) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -5.5e+21: tmp = x / y elif x <= 3.6e-95: tmp = t_0 elif x <= 4.5e-47: tmp = x * (x / y) elif x <= 1.3e+30: tmp = t_0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -5.5e+21) tmp = Float64(x / y); elseif (x <= 3.6e-95) tmp = t_0; elseif (x <= 4.5e-47) tmp = Float64(x * Float64(x / y)); elseif (x <= 1.3e+30) tmp = t_0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + 1.0); tmp = 0.0; if (x <= -5.5e+21) tmp = x / y; elseif (x <= 3.6e-95) tmp = t_0; elseif (x <= 4.5e-47) tmp = x * (x / y); elseif (x <= 1.3e+30) tmp = t_0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.5e+21], N[(x / y), $MachinePrecision], If[LessEqual[x, 3.6e-95], t$95$0, If[LessEqual[x, 4.5e-47], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.3e+30], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -5.5 \cdot 10^{+21}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-95}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-47}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+30}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -5.5e21 or 1.29999999999999994e30 < x Initial program 72.0%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in x around inf
/-lowering-/.f6478.2%
Simplified78.2%
if -5.5e21 < x < 3.6e-95 or 4.5e-47 < x < 1.29999999999999994e30Initial program 99.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in y around inf
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6476.8%
Simplified76.8%
if 3.6e-95 < x < 4.5e-47Initial program 99.8%
*-commutativeN/A
distribute-lft1-inN/A
+-lowering-+.f64N/A
associate-/r/N/A
/-lowering-/.f64N/A
/-lowering-/.f6499.9%
Applied egg-rr99.9%
Taylor expanded in x around 0
Simplified99.9%
/-rgt-identityN/A
associate-/r/N/A
distribute-lft1-inN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f6499.8%
Applied egg-rr99.8%
Taylor expanded in x around inf
/-lowering-/.f6483.8%
Simplified83.8%
Final simplification77.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (- 1.0 x))))
(if (<= x -1.0)
(/ x y)
(if (<= x 3.6e-95)
t_0
(if (<= x 1.55e-47) (* x (/ x y)) (if (<= x 0.32) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x * (1.0 - x);
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 3.6e-95) {
tmp = t_0;
} else if (x <= 1.55e-47) {
tmp = x * (x / y);
} else if (x <= 0.32) {
tmp = t_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 * (1.0d0 - x)
if (x <= (-1.0d0)) then
tmp = x / y
else if (x <= 3.6d-95) then
tmp = t_0
else if (x <= 1.55d-47) then
tmp = x * (x / y)
else if (x <= 0.32d0) then
tmp = t_0
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (1.0 - x);
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 3.6e-95) {
tmp = t_0;
} else if (x <= 1.55e-47) {
tmp = x * (x / y);
} else if (x <= 0.32) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x * (1.0 - x) tmp = 0 if x <= -1.0: tmp = x / y elif x <= 3.6e-95: tmp = t_0 elif x <= 1.55e-47: tmp = x * (x / y) elif x <= 0.32: tmp = t_0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(x * Float64(1.0 - x)) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 3.6e-95) tmp = t_0; elseif (x <= 1.55e-47) tmp = Float64(x * Float64(x / y)); elseif (x <= 0.32) tmp = t_0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = x * (1.0 - x); tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= 3.6e-95) tmp = t_0; elseif (x <= 1.55e-47) tmp = x * (x / y); elseif (x <= 0.32) tmp = t_0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 3.6e-95], t$95$0, If[LessEqual[x, 1.55e-47], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.32], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - x\right)\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-95}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-47}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 0.32:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 0.320000000000000007 < x Initial program 74.2%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in x around inf
/-lowering-/.f6473.7%
Simplified73.7%
if -1 < x < 3.6e-95 or 1.5499999999999999e-47 < x < 0.320000000000000007Initial program 99.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in y around inf
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6478.1%
Simplified78.1%
Taylor expanded in x around 0
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f6477.5%
Simplified77.5%
if 3.6e-95 < x < 1.5499999999999999e-47Initial program 99.8%
*-commutativeN/A
distribute-lft1-inN/A
+-lowering-+.f64N/A
associate-/r/N/A
/-lowering-/.f64N/A
/-lowering-/.f6499.9%
Applied egg-rr99.9%
Taylor expanded in x around 0
Simplified99.9%
/-rgt-identityN/A
associate-/r/N/A
distribute-lft1-inN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f6499.8%
Applied egg-rr99.8%
Taylor expanded in x around inf
/-lowering-/.f6483.8%
Simplified83.8%
Final simplification76.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (+ x y) y))) (if (<= x -1.0) t_0 (if (<= x 0.85) (* x (- (+ (/ x y) 1.0) x)) t_0))))
double code(double x, double y) {
double t_0 = (x + y) / y;
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 0.85) {
tmp = x * (((x / y) + 1.0) - 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) :: tmp
t_0 = (x + y) / y
if (x <= (-1.0d0)) then
tmp = t_0
else if (x <= 0.85d0) then
tmp = x * (((x / y) + 1.0d0) - x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x + y) / y;
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 0.85) {
tmp = x * (((x / y) + 1.0) - x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) / y tmp = 0 if x <= -1.0: tmp = t_0 elif x <= 0.85: tmp = x * (((x / y) + 1.0) - x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) / y) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= 0.85) tmp = Float64(x * Float64(Float64(Float64(x / y) + 1.0) - x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x + y) / y; tmp = 0.0; if (x <= -1.0) tmp = t_0; elseif (x <= 0.85) tmp = x * (((x / y) + 1.0) - x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 0.85], N[(x * N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{y}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.85:\\
\;\;\;\;x \cdot \left(\left(\frac{x}{y} + 1\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1 or 0.849999999999999978 < x Initial program 74.2%
Taylor expanded in x around inf
Simplified71.3%
Taylor expanded in y around 0
/-lowering-/.f64N/A
+-lowering-+.f6497.0%
Simplified97.0%
if -1 < x < 0.849999999999999978Initial program 99.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in x around 0
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
distribute-rgt-inN/A
associate-*l/N/A
*-lft-identityN/A
associate-+r+N/A
lft-mult-inverseN/A
*-lft-identityN/A
associate-*l/N/A
distribute-rgt-inN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
distribute-rgt-inN/A
lft-mult-inverseN/A
associate-*l/N/A
*-lft-identityN/A
+-lowering-+.f64N/A
/-lowering-/.f6498.4%
Simplified98.4%
Final simplification97.7%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (+ x y) y))) (if (<= x -1.0) t_0 (if (<= x 1.0) (* x (+ (/ x y) 1.0)) t_0))))
double code(double x, double y) {
double t_0 = (x + y) / y;
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = x * ((x / y) + 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) / y
if (x <= (-1.0d0)) then
tmp = t_0
else if (x <= 1.0d0) then
tmp = x * ((x / y) + 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) / y;
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = x * ((x / y) + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) / y tmp = 0 if x <= -1.0: tmp = t_0 elif x <= 1.0: tmp = x * ((x / y) + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) / y) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= 1.0) tmp = Float64(x * Float64(Float64(x / y) + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x + y) / y; tmp = 0.0; if (x <= -1.0) tmp = t_0; elseif (x <= 1.0) tmp = x * ((x / y) + 1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 1.0], N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{y}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot \left(\frac{x}{y} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 74.2%
Taylor expanded in x around inf
Simplified71.3%
Taylor expanded in y around 0
/-lowering-/.f64N/A
+-lowering-+.f6497.0%
Simplified97.0%
if -1 < x < 1Initial program 99.9%
*-commutativeN/A
distribute-lft1-inN/A
+-lowering-+.f64N/A
associate-/r/N/A
/-lowering-/.f64N/A
/-lowering-/.f6499.9%
Applied egg-rr99.9%
Taylor expanded in x around 0
Simplified97.9%
/-rgt-identityN/A
associate-/r/N/A
distribute-lft1-inN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f6497.8%
Applied egg-rr97.8%
Final simplification97.4%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x 0.78) (* x (- 1.0 x)) (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 0.78) {
tmp = x * (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) :: tmp
if (x <= (-1.0d0)) then
tmp = x / y
else if (x <= 0.78d0) then
tmp = x * (1.0d0 - x)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 0.78) {
tmp = x * (1.0 - x);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 0.78: tmp = x * (1.0 - x) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 0.78) tmp = Float64(x * Float64(1.0 - x)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= 0.78) tmp = x * (1.0 - x); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 0.78], N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 0.78:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 0.78000000000000003 < x Initial program 74.2%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in x around inf
/-lowering-/.f6473.7%
Simplified73.7%
if -1 < x < 0.78000000000000003Initial program 99.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in y around inf
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6472.2%
Simplified72.2%
Taylor expanded in x around 0
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f6471.6%
Simplified71.6%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x 160.0) x (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 160.0) {
tmp = 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) :: tmp
if (x <= (-1.0d0)) then
tmp = x / y
else if (x <= 160.0d0) then
tmp = x
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 160.0) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 160.0: tmp = x else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 160.0) tmp = x; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= 160.0) tmp = x; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 160.0], x, N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 160:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 160 < x Initial program 74.0%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in x around inf
/-lowering-/.f6474.3%
Simplified74.3%
if -1 < x < 160Initial program 99.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in x around 0
Simplified70.6%
(FPCore (x y) :precision binary64 (if (<= x -1.0) 1.0 (if (<= x 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 1.0) {
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 <= (-1.0d0)) then
tmp = 1.0d0
else if (x <= 1.0d0) 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 <= -1.0) {
tmp = 1.0;
} else if (x <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 elif x <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = 1.0; elseif (x <= 1.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = 1.0; elseif (x <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 74.2%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in y around inf
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6427.0%
Simplified27.0%
Taylor expanded in x around inf
Simplified25.7%
if -1 < x < 1Initial program 99.9%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.8%
Simplified99.8%
Taylor expanded in x around 0
Simplified71.0%
(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.5%
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in y around inf
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6450.3%
Simplified50.3%
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 2024158
(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)))