
(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 (/ (+ x 1.0) (+ 1.0 (/ x y)))))
double code(double x, double y) {
return x / ((x + 1.0) / (1.0 + (x / y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / ((x + 1.0d0) / (1.0d0 + (x / y)))
end function
public static double code(double x, double y) {
return x / ((x + 1.0) / (1.0 + (x / y)));
}
def code(x, y): return x / ((x + 1.0) / (1.0 + (x / y)))
function code(x, y) return Float64(x / Float64(Float64(x + 1.0) / Float64(1.0 + Float64(x / y)))) end
function tmp = code(x, y) tmp = x / ((x + 1.0) / (1.0 + (x / y))); end
code[x_, y_] := N[(x / N[(N[(x + 1.0), $MachinePrecision] / N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{x + 1}{1 + \frac{x}{y}}}
\end{array}
Initial program 90.4%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (+ x -1.0) y))) (t_1 (/ x (+ x 1.0))))
(if (<= x -38.0)
t_0
(if (<= x -2.9e-34)
t_1
(if (<= x -2.2e-64)
(/ x (/ y x))
(if (<= x 54000000000000.0) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -38.0) {
tmp = t_0;
} else if (x <= -2.9e-34) {
tmp = t_1;
} else if (x <= -2.2e-64) {
tmp = x / (y / x);
} else if (x <= 54000000000000.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 = 1.0d0 + ((x + (-1.0d0)) / y)
t_1 = x / (x + 1.0d0)
if (x <= (-38.0d0)) then
tmp = t_0
else if (x <= (-2.9d-34)) then
tmp = t_1
else if (x <= (-2.2d-64)) then
tmp = x / (y / x)
else if (x <= 54000000000000.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 = 1.0 + ((x + -1.0) / y);
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -38.0) {
tmp = t_0;
} else if (x <= -2.9e-34) {
tmp = t_1;
} else if (x <= -2.2e-64) {
tmp = x / (y / x);
} else if (x <= 54000000000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + ((x + -1.0) / y) t_1 = x / (x + 1.0) tmp = 0 if x <= -38.0: tmp = t_0 elif x <= -2.9e-34: tmp = t_1 elif x <= -2.2e-64: tmp = x / (y / x) elif x <= 54000000000000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(Float64(x + -1.0) / y)) t_1 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -38.0) tmp = t_0; elseif (x <= -2.9e-34) tmp = t_1; elseif (x <= -2.2e-64) tmp = Float64(x / Float64(y / x)); elseif (x <= 54000000000000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + ((x + -1.0) / y); t_1 = x / (x + 1.0); tmp = 0.0; if (x <= -38.0) tmp = t_0; elseif (x <= -2.9e-34) tmp = t_1; elseif (x <= -2.2e-64) tmp = x / (y / x); elseif (x <= 54000000000000.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -38.0], t$95$0, If[LessEqual[x, -2.9e-34], t$95$1, If[LessEqual[x, -2.2e-64], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 54000000000000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x + -1}{y}\\
t_1 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -38:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.9 \cdot 10^{-34}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2.2 \cdot 10^{-64}:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;x \leq 54000000000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -38 or 5.4e13 < x Initial program 78.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.4%
Taylor expanded in y around -inf 99.4%
mul-1-neg99.4%
unsub-neg99.4%
neg-mul-199.4%
unsub-neg99.4%
Simplified99.4%
if -38 < x < -2.9000000000000002e-34 or -2.2e-64 < x < 5.4e13Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 87.8%
if -2.9000000000000002e-34 < x < -2.2e-64Initial program 99.5%
*-commutative99.5%
associate-/l*99.7%
remove-double-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/r*99.7%
+-commutative99.7%
remove-double-neg99.7%
unsub-neg99.7%
div-sub99.7%
*-inverses99.7%
div-sub99.7%
associate-/r*99.7%
*-commutative99.7%
neg-mul-199.7%
remove-double-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 72.6%
distribute-rgt-in72.6%
associate-*l/72.8%
*-lft-identity72.8%
*-lft-identity72.8%
Simplified72.8%
Taylor expanded in x around 0 72.8%
Final simplification92.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (+ x -1.0) y))) (t_1 (/ x (+ x 1.0))))
(if (<= x -15.0)
t_0
(if (<= x -4e-34)
t_1
(if (<= x -1.5e-65)
(/ x (+ y (/ y x)))
(if (<= x 54000000000000.0) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -15.0) {
tmp = t_0;
} else if (x <= -4e-34) {
tmp = t_1;
} else if (x <= -1.5e-65) {
tmp = x / (y + (y / x));
} else if (x <= 54000000000000.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 = 1.0d0 + ((x + (-1.0d0)) / y)
t_1 = x / (x + 1.0d0)
if (x <= (-15.0d0)) then
tmp = t_0
else if (x <= (-4d-34)) then
tmp = t_1
else if (x <= (-1.5d-65)) then
tmp = x / (y + (y / x))
else if (x <= 54000000000000.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 = 1.0 + ((x + -1.0) / y);
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -15.0) {
tmp = t_0;
} else if (x <= -4e-34) {
tmp = t_1;
} else if (x <= -1.5e-65) {
tmp = x / (y + (y / x));
} else if (x <= 54000000000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + ((x + -1.0) / y) t_1 = x / (x + 1.0) tmp = 0 if x <= -15.0: tmp = t_0 elif x <= -4e-34: tmp = t_1 elif x <= -1.5e-65: tmp = x / (y + (y / x)) elif x <= 54000000000000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(Float64(x + -1.0) / y)) t_1 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -15.0) tmp = t_0; elseif (x <= -4e-34) tmp = t_1; elseif (x <= -1.5e-65) tmp = Float64(x / Float64(y + Float64(y / x))); elseif (x <= 54000000000000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + ((x + -1.0) / y); t_1 = x / (x + 1.0); tmp = 0.0; if (x <= -15.0) tmp = t_0; elseif (x <= -4e-34) tmp = t_1; elseif (x <= -1.5e-65) tmp = x / (y + (y / x)); elseif (x <= 54000000000000.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -15.0], t$95$0, If[LessEqual[x, -4e-34], t$95$1, If[LessEqual[x, -1.5e-65], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 54000000000000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x + -1}{y}\\
t_1 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -15:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -4 \cdot 10^{-34}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.5 \cdot 10^{-65}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{elif}\;x \leq 54000000000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -15 or 5.4e13 < x Initial program 78.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.4%
Taylor expanded in y around -inf 99.4%
mul-1-neg99.4%
unsub-neg99.4%
neg-mul-199.4%
unsub-neg99.4%
Simplified99.4%
if -15 < x < -3.99999999999999971e-34 or -1.49999999999999999e-65 < x < 5.4e13Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 87.8%
if -3.99999999999999971e-34 < x < -1.49999999999999999e-65Initial program 99.5%
*-commutative99.5%
associate-/l*99.7%
remove-double-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/r*99.7%
+-commutative99.7%
remove-double-neg99.7%
unsub-neg99.7%
div-sub99.7%
*-inverses99.7%
div-sub99.7%
associate-/r*99.7%
*-commutative99.7%
neg-mul-199.7%
remove-double-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 72.6%
distribute-rgt-in72.6%
associate-*l/72.8%
*-lft-identity72.8%
*-lft-identity72.8%
Simplified72.8%
Final simplification92.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -38.0)
(/ x y)
(if (<= x -1.75e-34)
t_0
(if (<= x -7.8e-67) (* x (/ x y)) (if (<= x 4e+23) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -38.0) {
tmp = x / y;
} else if (x <= -1.75e-34) {
tmp = t_0;
} else if (x <= -7.8e-67) {
tmp = x * (x / y);
} else if (x <= 4e+23) {
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 <= (-38.0d0)) then
tmp = x / y
else if (x <= (-1.75d-34)) then
tmp = t_0
else if (x <= (-7.8d-67)) then
tmp = x * (x / y)
else if (x <= 4d+23) 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 <= -38.0) {
tmp = x / y;
} else if (x <= -1.75e-34) {
tmp = t_0;
} else if (x <= -7.8e-67) {
tmp = x * (x / y);
} else if (x <= 4e+23) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -38.0: tmp = x / y elif x <= -1.75e-34: tmp = t_0 elif x <= -7.8e-67: tmp = x * (x / y) elif x <= 4e+23: 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 <= -38.0) tmp = Float64(x / y); elseif (x <= -1.75e-34) tmp = t_0; elseif (x <= -7.8e-67) tmp = Float64(x * Float64(x / y)); elseif (x <= 4e+23) 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 <= -38.0) tmp = x / y; elseif (x <= -1.75e-34) tmp = t_0; elseif (x <= -7.8e-67) tmp = x * (x / y); elseif (x <= 4e+23) 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, -38.0], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.75e-34], t$95$0, If[LessEqual[x, -7.8e-67], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4e+23], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -38:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.75 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -7.8 \cdot 10^{-67}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+23}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -38 or 3.9999999999999997e23 < x Initial program 78.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 80.8%
if -38 < x < -1.75e-34 or -7.7999999999999997e-67 < x < 3.9999999999999997e23Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 87.8%
if -1.75e-34 < x < -7.7999999999999997e-67Initial program 99.5%
*-commutative99.5%
associate-/l*99.7%
remove-double-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/r*99.7%
+-commutative99.7%
remove-double-neg99.7%
unsub-neg99.7%
div-sub99.7%
*-inverses99.7%
div-sub99.7%
associate-/r*99.7%
*-commutative99.7%
neg-mul-199.7%
remove-double-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 72.6%
distribute-rgt-in72.6%
associate-*l/72.8%
*-lft-identity72.8%
*-lft-identity72.8%
Simplified72.8%
clear-num72.8%
associate-/r/72.2%
Applied egg-rr72.2%
Taylor expanded in x around 0 72.2%
Final simplification84.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -38.0)
(/ x y)
(if (<= x -1.45e-34)
t_0
(if (<= x -4.3e-68) (/ x (/ y x)) (if (<= x 5.2e+22) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -38.0) {
tmp = x / y;
} else if (x <= -1.45e-34) {
tmp = t_0;
} else if (x <= -4.3e-68) {
tmp = x / (y / x);
} else if (x <= 5.2e+22) {
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 <= (-38.0d0)) then
tmp = x / y
else if (x <= (-1.45d-34)) then
tmp = t_0
else if (x <= (-4.3d-68)) then
tmp = x / (y / x)
else if (x <= 5.2d+22) 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 <= -38.0) {
tmp = x / y;
} else if (x <= -1.45e-34) {
tmp = t_0;
} else if (x <= -4.3e-68) {
tmp = x / (y / x);
} else if (x <= 5.2e+22) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -38.0: tmp = x / y elif x <= -1.45e-34: tmp = t_0 elif x <= -4.3e-68: tmp = x / (y / x) elif x <= 5.2e+22: 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 <= -38.0) tmp = Float64(x / y); elseif (x <= -1.45e-34) tmp = t_0; elseif (x <= -4.3e-68) tmp = Float64(x / Float64(y / x)); elseif (x <= 5.2e+22) 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 <= -38.0) tmp = x / y; elseif (x <= -1.45e-34) tmp = t_0; elseif (x <= -4.3e-68) tmp = x / (y / x); elseif (x <= 5.2e+22) 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, -38.0], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.45e-34], t$95$0, If[LessEqual[x, -4.3e-68], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.2e+22], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -38:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.45 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -4.3 \cdot 10^{-68}:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{+22}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -38 or 5.2e22 < x Initial program 78.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 80.8%
if -38 < x < -1.4500000000000001e-34 or -4.3000000000000001e-68 < x < 5.2e22Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 87.8%
if -1.4500000000000001e-34 < x < -4.3000000000000001e-68Initial program 99.5%
*-commutative99.5%
associate-/l*99.7%
remove-double-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/r*99.7%
+-commutative99.7%
remove-double-neg99.7%
unsub-neg99.7%
div-sub99.7%
*-inverses99.7%
div-sub99.7%
associate-/r*99.7%
*-commutative99.7%
neg-mul-199.7%
remove-double-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 72.6%
distribute-rgt-in72.6%
associate-*l/72.8%
*-lft-identity72.8%
*-lft-identity72.8%
Simplified72.8%
Taylor expanded in x around 0 72.8%
Final simplification84.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -38.0)
(/ (+ x -1.0) y)
(if (<= x -1.35e-34)
t_0
(if (<= x -2.45e-64) (/ x (/ y x)) (if (<= x 8e+26) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -38.0) {
tmp = (x + -1.0) / y;
} else if (x <= -1.35e-34) {
tmp = t_0;
} else if (x <= -2.45e-64) {
tmp = x / (y / x);
} else if (x <= 8e+26) {
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 <= (-38.0d0)) then
tmp = (x + (-1.0d0)) / y
else if (x <= (-1.35d-34)) then
tmp = t_0
else if (x <= (-2.45d-64)) then
tmp = x / (y / x)
else if (x <= 8d+26) 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 <= -38.0) {
tmp = (x + -1.0) / y;
} else if (x <= -1.35e-34) {
tmp = t_0;
} else if (x <= -2.45e-64) {
tmp = x / (y / x);
} else if (x <= 8e+26) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -38.0: tmp = (x + -1.0) / y elif x <= -1.35e-34: tmp = t_0 elif x <= -2.45e-64: tmp = x / (y / x) elif x <= 8e+26: 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 <= -38.0) tmp = Float64(Float64(x + -1.0) / y); elseif (x <= -1.35e-34) tmp = t_0; elseif (x <= -2.45e-64) tmp = Float64(x / Float64(y / x)); elseif (x <= 8e+26) 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 <= -38.0) tmp = (x + -1.0) / y; elseif (x <= -1.35e-34) tmp = t_0; elseif (x <= -2.45e-64) tmp = x / (y / x); elseif (x <= 8e+26) 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, -38.0], N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, -1.35e-34], t$95$0, If[LessEqual[x, -2.45e-64], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8e+26], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -38:\\
\;\;\;\;\frac{x + -1}{y}\\
\mathbf{elif}\;x \leq -1.35 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.45 \cdot 10^{-64}:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+26}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -38Initial program 74.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.0%
Taylor expanded in y around 0 81.4%
if -38 < x < -1.35000000000000008e-34 or -2.4500000000000001e-64 < x < 8.00000000000000038e26Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 87.8%
if -1.35000000000000008e-34 < x < -2.4500000000000001e-64Initial program 99.5%
*-commutative99.5%
associate-/l*99.7%
remove-double-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/r*99.7%
+-commutative99.7%
remove-double-neg99.7%
unsub-neg99.7%
div-sub99.7%
*-inverses99.7%
div-sub99.7%
associate-/r*99.7%
*-commutative99.7%
neg-mul-199.7%
remove-double-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 72.6%
distribute-rgt-in72.6%
associate-*l/72.8%
*-lft-identity72.8%
*-lft-identity72.8%
Simplified72.8%
Taylor expanded in x around 0 72.8%
if 8.00000000000000038e26 < x Initial program 84.3%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 80.2%
Final simplification84.2%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ x y)
(if (<= x -1.46e-34)
x
(if (<= x -3e-66) (* x (/ x y)) (if (<= x 54000000000000.0) x (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= -1.46e-34) {
tmp = x;
} else if (x <= -3e-66) {
tmp = x * (x / y);
} else if (x <= 54000000000000.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 <= (-1.46d-34)) then
tmp = x
else if (x <= (-3d-66)) then
tmp = x * (x / y)
else if (x <= 54000000000000.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 <= -1.46e-34) {
tmp = x;
} else if (x <= -3e-66) {
tmp = x * (x / y);
} else if (x <= 54000000000000.0) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= -1.46e-34: tmp = x elif x <= -3e-66: tmp = x * (x / y) elif x <= 54000000000000.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 <= -1.46e-34) tmp = x; elseif (x <= -3e-66) tmp = Float64(x * Float64(x / y)); elseif (x <= 54000000000000.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 <= -1.46e-34) tmp = x; elseif (x <= -3e-66) tmp = x * (x / y); elseif (x <= 54000000000000.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, -1.46e-34], x, If[LessEqual[x, -3e-66], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 54000000000000.0], x, N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.46 \cdot 10^{-34}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-66}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 54000000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 5.4e13 < x Initial program 78.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 80.8%
if -1 < x < -1.4599999999999999e-34 or -3.0000000000000002e-66 < x < 5.4e13Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 83.9%
if -1.4599999999999999e-34 < x < -3.0000000000000002e-66Initial program 99.5%
*-commutative99.5%
associate-/l*99.7%
remove-double-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/r*99.7%
+-commutative99.7%
remove-double-neg99.7%
unsub-neg99.7%
div-sub99.7%
*-inverses99.7%
div-sub99.7%
associate-/r*99.7%
*-commutative99.7%
neg-mul-199.7%
remove-double-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 72.6%
distribute-rgt-in72.6%
associate-*l/72.8%
*-lft-identity72.8%
*-lft-identity72.8%
Simplified72.8%
clear-num72.8%
associate-/r/72.2%
Applied egg-rr72.2%
Taylor expanded in x around 0 72.2%
Final simplification82.2%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 54000000000000.0))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 54000000000000.0)) {
tmp = x / y;
} else {
tmp = x;
}
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)) .or. (.not. (x <= 54000000000000.0d0))) then
tmp = x / y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 54000000000000.0)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 54000000000000.0): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 54000000000000.0)) tmp = Float64(x / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 54000000000000.0))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 54000000000000.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 54000000000000\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 5.4e13 < x Initial program 78.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 80.8%
if -1 < x < 5.4e13Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 80.2%
Final simplification80.5%
(FPCore (x y) :precision binary64 (if (<= x -4.5e+16) 1.0 (if (<= x 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -4.5e+16) {
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 <= (-4.5d+16)) 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 <= -4.5e+16) {
tmp = 1.0;
} else if (x <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4.5e+16: tmp = 1.0 elif x <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -4.5e+16) 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 <= -4.5e+16) tmp = 1.0; elseif (x <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4.5e+16], 1.0, If[LessEqual[x, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.5 \cdot 10^{+16}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -4.5e16 or 1 < x Initial program 78.6%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around inf 23.8%
Taylor expanded in x around inf 22.8%
if -4.5e16 < x < 1Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 80.6%
Final simplification54.9%
(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 90.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 56.3%
Taylor expanded in x around inf 12.4%
Final simplification12.4%
(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 2024029
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:herbie-target
(* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0)))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))