
(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 (let* ((t_0 (/ x (+ x 1.0)))) (+ t_0 (* t_0 (/ x y)))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
return t_0 + (t_0 * (x / y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = x / (x + 1.0d0)
code = t_0 + (t_0 * (x / y))
end function
public static double code(double x, double y) {
double t_0 = x / (x + 1.0);
return t_0 + (t_0 * (x / y));
}
def code(x, y): t_0 = x / (x + 1.0) return t_0 + (t_0 * (x / y))
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) return Float64(t_0 + Float64(t_0 * Float64(x / y))) end
function tmp = code(x, y) t_0 = x / (x + 1.0); tmp = t_0 + (t_0 * (x / y)); end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 + N[(t$95$0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t\_0 + t\_0 \cdot \frac{x}{y}
\end{array}
\end{array}
Initial program 86.4%
associate-/l*99.9%
Simplified99.9%
associate-/r/99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= x -35000000000.0)
(/ x y)
(if (<= x -2.7e-73)
(* x (/ x y))
(if (<= x 2.6e-17)
x
(if (or (<= x 1.5e+89) (not (<= x 1.55e+95))) (/ x y) 1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -35000000000.0) {
tmp = x / y;
} else if (x <= -2.7e-73) {
tmp = x * (x / y);
} else if (x <= 2.6e-17) {
tmp = x;
} else if ((x <= 1.5e+89) || !(x <= 1.55e+95)) {
tmp = x / y;
} 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 <= (-35000000000.0d0)) then
tmp = x / y
else if (x <= (-2.7d-73)) then
tmp = x * (x / y)
else if (x <= 2.6d-17) then
tmp = x
else if ((x <= 1.5d+89) .or. (.not. (x <= 1.55d+95))) then
tmp = x / y
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -35000000000.0) {
tmp = x / y;
} else if (x <= -2.7e-73) {
tmp = x * (x / y);
} else if (x <= 2.6e-17) {
tmp = x;
} else if ((x <= 1.5e+89) || !(x <= 1.55e+95)) {
tmp = x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -35000000000.0: tmp = x / y elif x <= -2.7e-73: tmp = x * (x / y) elif x <= 2.6e-17: tmp = x elif (x <= 1.5e+89) or not (x <= 1.55e+95): tmp = x / y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -35000000000.0) tmp = Float64(x / y); elseif (x <= -2.7e-73) tmp = Float64(x * Float64(x / y)); elseif (x <= 2.6e-17) tmp = x; elseif ((x <= 1.5e+89) || !(x <= 1.55e+95)) tmp = Float64(x / y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -35000000000.0) tmp = x / y; elseif (x <= -2.7e-73) tmp = x * (x / y); elseif (x <= 2.6e-17) tmp = x; elseif ((x <= 1.5e+89) || ~((x <= 1.55e+95))) tmp = x / y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -35000000000.0], N[(x / y), $MachinePrecision], If[LessEqual[x, -2.7e-73], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e-17], x, If[Or[LessEqual[x, 1.5e+89], N[Not[LessEqual[x, 1.55e+95]], $MachinePrecision]], N[(x / y), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -35000000000:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -2.7 \cdot 10^{-73}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-17}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+89} \lor \neg \left(x \leq 1.55 \cdot 10^{+95}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -3.5e10 or 2.60000000000000003e-17 < x < 1.50000000000000006e89 or 1.5500000000000001e95 < x Initial program 72.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 77.6%
if -3.5e10 < x < -2.69999999999999994e-73Initial program 99.9%
*-commutative99.9%
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.5%
*-inverses99.5%
div-sub99.5%
associate-/r*99.5%
*-commutative99.5%
neg-mul-199.5%
remove-double-neg99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in y around 0 75.3%
distribute-lft-in75.0%
*-rgt-identity75.0%
associate-*r/75.3%
*-rgt-identity75.3%
Simplified75.3%
Taylor expanded in x around 0 67.7%
associate-/r/68.0%
Applied egg-rr68.0%
if -2.69999999999999994e-73 < x < 2.60000000000000003e-17Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 82.7%
if 1.50000000000000006e89 < x < 1.5500000000000001e95Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/r*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
*-inverses100.0%
div-sub100.0%
associate-/r*100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around inf 100.0%
Final simplification79.5%
(FPCore (x y)
:precision binary64
(if (<= x -35000000000.0)
(/ x y)
(if (<= x -4.3e-72)
(* x (/ x y))
(if (<= x 2.6e-17)
(/ x (+ x 1.0))
(if (or (<= x 8.5e+90) (not (<= x 1.65e+95))) (/ x y) 1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -35000000000.0) {
tmp = x / y;
} else if (x <= -4.3e-72) {
tmp = x * (x / y);
} else if (x <= 2.6e-17) {
tmp = x / (x + 1.0);
} else if ((x <= 8.5e+90) || !(x <= 1.65e+95)) {
tmp = x / y;
} 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 <= (-35000000000.0d0)) then
tmp = x / y
else if (x <= (-4.3d-72)) then
tmp = x * (x / y)
else if (x <= 2.6d-17) then
tmp = x / (x + 1.0d0)
else if ((x <= 8.5d+90) .or. (.not. (x <= 1.65d+95))) then
tmp = x / y
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -35000000000.0) {
tmp = x / y;
} else if (x <= -4.3e-72) {
tmp = x * (x / y);
} else if (x <= 2.6e-17) {
tmp = x / (x + 1.0);
} else if ((x <= 8.5e+90) || !(x <= 1.65e+95)) {
tmp = x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -35000000000.0: tmp = x / y elif x <= -4.3e-72: tmp = x * (x / y) elif x <= 2.6e-17: tmp = x / (x + 1.0) elif (x <= 8.5e+90) or not (x <= 1.65e+95): tmp = x / y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -35000000000.0) tmp = Float64(x / y); elseif (x <= -4.3e-72) tmp = Float64(x * Float64(x / y)); elseif (x <= 2.6e-17) tmp = Float64(x / Float64(x + 1.0)); elseif ((x <= 8.5e+90) || !(x <= 1.65e+95)) tmp = Float64(x / y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -35000000000.0) tmp = x / y; elseif (x <= -4.3e-72) tmp = x * (x / y); elseif (x <= 2.6e-17) tmp = x / (x + 1.0); elseif ((x <= 8.5e+90) || ~((x <= 1.65e+95))) tmp = x / y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -35000000000.0], N[(x / y), $MachinePrecision], If[LessEqual[x, -4.3e-72], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e-17], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 8.5e+90], N[Not[LessEqual[x, 1.65e+95]], $MachinePrecision]], N[(x / y), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -35000000000:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -4.3 \cdot 10^{-72}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-17}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+90} \lor \neg \left(x \leq 1.65 \cdot 10^{+95}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -3.5e10 or 2.60000000000000003e-17 < x < 8.5000000000000002e90 or 1.6499999999999999e95 < x Initial program 72.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 77.6%
if -3.5e10 < x < -4.2999999999999999e-72Initial program 99.9%
*-commutative99.9%
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.5%
*-inverses99.5%
div-sub99.5%
associate-/r*99.5%
*-commutative99.5%
neg-mul-199.5%
remove-double-neg99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in y around 0 75.3%
distribute-lft-in75.0%
*-rgt-identity75.0%
associate-*r/75.3%
*-rgt-identity75.3%
Simplified75.3%
Taylor expanded in x around 0 67.7%
associate-/r/68.0%
Applied egg-rr68.0%
if -4.2999999999999999e-72 < x < 2.60000000000000003e-17Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 82.7%
if 8.5000000000000002e90 < x < 1.6499999999999999e95Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/r*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
*-inverses100.0%
div-sub100.0%
associate-/r*100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around inf 100.0%
Final simplification79.5%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ x y)
(if (<= x 2.6e-17)
x
(if (or (<= x 5.5e+90) (not (<= x 1.55e+95))) (/ x y) 1.0))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 2.6e-17) {
tmp = x;
} else if ((x <= 5.5e+90) || !(x <= 1.55e+95)) {
tmp = x / y;
} 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 = x / y
else if (x <= 2.6d-17) then
tmp = x
else if ((x <= 5.5d+90) .or. (.not. (x <= 1.55d+95))) then
tmp = x / y
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 = x / y;
} else if (x <= 2.6e-17) {
tmp = x;
} else if ((x <= 5.5e+90) || !(x <= 1.55e+95)) {
tmp = x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 2.6e-17: tmp = x elif (x <= 5.5e+90) or not (x <= 1.55e+95): tmp = x / y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 2.6e-17) tmp = x; elseif ((x <= 5.5e+90) || !(x <= 1.55e+95)) tmp = Float64(x / y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= 2.6e-17) tmp = x; elseif ((x <= 5.5e+90) || ~((x <= 1.55e+95))) tmp = x / y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 2.6e-17], x, If[Or[LessEqual[x, 5.5e+90], N[Not[LessEqual[x, 1.55e+95]], $MachinePrecision]], N[(x / y), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-17}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+90} \lor \neg \left(x \leq 1.55 \cdot 10^{+95}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 2.60000000000000003e-17 < x < 5.49999999999999999e90 or 1.5500000000000001e95 < x Initial program 73.3%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 76.4%
if -1 < x < 2.60000000000000003e-17Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 75.0%
if 5.49999999999999999e90 < x < 1.5500000000000001e95Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/r*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
*-inverses100.0%
div-sub100.0%
associate-/r*100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around inf 100.0%
Final simplification76.2%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ x y)
(if (<= x 26.0)
(* x (+ 1.0 (/ x y)))
(if (or (<= x 8.5e+90) (not (<= x 1.55e+95))) (/ x y) 1.0))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 26.0) {
tmp = x * (1.0 + (x / y));
} else if ((x <= 8.5e+90) || !(x <= 1.55e+95)) {
tmp = x / y;
} 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 = x / y
else if (x <= 26.0d0) then
tmp = x * (1.0d0 + (x / y))
else if ((x <= 8.5d+90) .or. (.not. (x <= 1.55d+95))) then
tmp = x / y
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 = x / y;
} else if (x <= 26.0) {
tmp = x * (1.0 + (x / y));
} else if ((x <= 8.5e+90) || !(x <= 1.55e+95)) {
tmp = x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 26.0: tmp = x * (1.0 + (x / y)) elif (x <= 8.5e+90) or not (x <= 1.55e+95): tmp = x / y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 26.0) tmp = Float64(x * Float64(1.0 + Float64(x / y))); elseif ((x <= 8.5e+90) || !(x <= 1.55e+95)) tmp = Float64(x / y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= 26.0) tmp = x * (1.0 + (x / y)); elseif ((x <= 8.5e+90) || ~((x <= 1.55e+95))) tmp = x / y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 26.0], N[(x * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 8.5e+90], N[Not[LessEqual[x, 1.55e+95]], $MachinePrecision]], N[(x / y), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 26:\\
\;\;\;\;x \cdot \left(1 + \frac{x}{y}\right)\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+90} \lor \neg \left(x \leq 1.55 \cdot 10^{+95}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 26 < x < 8.5000000000000002e90 or 1.5500000000000001e95 < x Initial program 72.7%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 78.0%
if -1 < x < 26Initial program 99.9%
*-commutative99.9%
associate-/l*99.5%
remove-double-neg99.5%
neg-mul-199.5%
*-commutative99.5%
associate-/r*99.5%
+-commutative99.5%
remove-double-neg99.5%
unsub-neg99.5%
div-sub99.4%
*-inverses99.4%
div-sub99.4%
associate-/r*99.4%
*-commutative99.4%
neg-mul-199.4%
remove-double-neg99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 98.2%
associate-/r/98.6%
/-rgt-identity98.6%
+-commutative98.6%
Applied egg-rr98.6%
if 8.5000000000000002e90 < x < 1.5500000000000001e95Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/r*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
*-inverses100.0%
div-sub100.0%
associate-/r*100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around inf 100.0%
Final simplification88.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y (/ y x)))))
(if (<= x -6.4e-16)
t_0
(if (<= x 2.6e-17)
(* x (+ 1.0 (/ x y)))
(if (<= x 8.5e+90) t_0 (if (<= x 1.55e+95) 1.0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (y + (y / x));
double tmp;
if (x <= -6.4e-16) {
tmp = t_0;
} else if (x <= 2.6e-17) {
tmp = x * (1.0 + (x / y));
} else if (x <= 8.5e+90) {
tmp = t_0;
} else if (x <= 1.55e+95) {
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 / (y + (y / x))
if (x <= (-6.4d-16)) then
tmp = t_0
else if (x <= 2.6d-17) then
tmp = x * (1.0d0 + (x / y))
else if (x <= 8.5d+90) then
tmp = t_0
else if (x <= 1.55d+95) 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 / (y + (y / x));
double tmp;
if (x <= -6.4e-16) {
tmp = t_0;
} else if (x <= 2.6e-17) {
tmp = x * (1.0 + (x / y));
} else if (x <= 8.5e+90) {
tmp = t_0;
} else if (x <= 1.55e+95) {
tmp = 1.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (y + (y / x)) tmp = 0 if x <= -6.4e-16: tmp = t_0 elif x <= 2.6e-17: tmp = x * (1.0 + (x / y)) elif x <= 8.5e+90: tmp = t_0 elif x <= 1.55e+95: tmp = 1.0 else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(x / Float64(y + Float64(y / x))) tmp = 0.0 if (x <= -6.4e-16) tmp = t_0; elseif (x <= 2.6e-17) tmp = Float64(x * Float64(1.0 + Float64(x / y))); elseif (x <= 8.5e+90) tmp = t_0; elseif (x <= 1.55e+95) tmp = 1.0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y + (y / x)); tmp = 0.0; if (x <= -6.4e-16) tmp = t_0; elseif (x <= 2.6e-17) tmp = x * (1.0 + (x / y)); elseif (x <= 8.5e+90) tmp = t_0; elseif (x <= 1.55e+95) tmp = 1.0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.4e-16], t$95$0, If[LessEqual[x, 2.6e-17], N[(x * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.5e+90], t$95$0, If[LessEqual[x, 1.55e+95], 1.0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + \frac{y}{x}}\\
\mathbf{if}\;x \leq -6.4 \cdot 10^{-16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-17}:\\
\;\;\;\;x \cdot \left(1 + \frac{x}{y}\right)\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+90}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+95}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -6.40000000000000046e-16 or 2.60000000000000003e-17 < x < 8.5000000000000002e90Initial program 83.6%
*-commutative83.6%
associate-/l*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/r*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub99.9%
*-inverses99.9%
div-sub99.9%
associate-/r*99.9%
*-commutative99.9%
neg-mul-199.9%
remove-double-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 73.9%
distribute-lft-in73.9%
*-rgt-identity73.9%
associate-*r/73.9%
*-rgt-identity73.9%
Simplified73.9%
if -6.40000000000000046e-16 < x < 2.60000000000000003e-17Initial program 99.9%
*-commutative99.9%
associate-/l*99.4%
remove-double-neg99.4%
neg-mul-199.4%
*-commutative99.4%
associate-/r*99.4%
+-commutative99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub99.4%
*-inverses99.4%
div-sub99.4%
associate-/r*99.4%
*-commutative99.4%
neg-mul-199.4%
remove-double-neg99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
associate-/r/99.9%
/-rgt-identity99.9%
+-commutative99.9%
Applied egg-rr99.9%
if 8.5000000000000002e90 < x < 1.5500000000000001e95Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/r*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
*-inverses100.0%
div-sub100.0%
associate-/r*100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around inf 100.0%
if 1.5500000000000001e95 < x Initial program 54.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 91.0%
Final simplification89.2%
(FPCore (x y) :precision binary64 (if (or (<= x -35000.0) (not (<= x 40.0))) (+ (+ 1.0 (/ x y)) (/ -1.0 y)) (+ x (* x (/ (/ x (+ x 1.0)) y)))))
double code(double x, double y) {
double tmp;
if ((x <= -35000.0) || !(x <= 40.0)) {
tmp = (1.0 + (x / y)) + (-1.0 / y);
} else {
tmp = x + (x * ((x / (x + 1.0)) / y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-35000.0d0)) .or. (.not. (x <= 40.0d0))) then
tmp = (1.0d0 + (x / y)) + ((-1.0d0) / y)
else
tmp = x + (x * ((x / (x + 1.0d0)) / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -35000.0) || !(x <= 40.0)) {
tmp = (1.0 + (x / y)) + (-1.0 / y);
} else {
tmp = x + (x * ((x / (x + 1.0)) / y));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -35000.0) or not (x <= 40.0): tmp = (1.0 + (x / y)) + (-1.0 / y) else: tmp = x + (x * ((x / (x + 1.0)) / y)) return tmp
function code(x, y) tmp = 0.0 if ((x <= -35000.0) || !(x <= 40.0)) tmp = Float64(Float64(1.0 + Float64(x / y)) + Float64(-1.0 / y)); else tmp = Float64(x + Float64(x * Float64(Float64(x / Float64(x + 1.0)) / y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -35000.0) || ~((x <= 40.0))) tmp = (1.0 + (x / y)) + (-1.0 / y); else tmp = x + (x * ((x / (x + 1.0)) / y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -35000.0], N[Not[LessEqual[x, 40.0]], $MachinePrecision]], N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -35000 \lor \neg \left(x \leq 40\right):\\
\;\;\;\;\left(1 + \frac{x}{y}\right) + \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \frac{\frac{x}{x + 1}}{y}\\
\end{array}
\end{array}
if x < -35000 or 40 < x Initial program 73.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.4%
if -35000 < x < 40Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
associate-/r/99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
*-commutative99.9%
frac-2neg99.9%
associate-*r/97.6%
Applied egg-rr97.6%
Taylor expanded in x around 0 97.6%
associate-/l*99.8%
frac-2neg99.8%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification99.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ 1.0 (/ x y)))) (if (or (<= x -1.0) (not (<= x 1.25))) (+ t_0 (/ -1.0 y)) (* x t_0))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if ((x <= -1.0) || !(x <= 1.25)) {
tmp = t_0 + (-1.0 / y);
} else {
tmp = x * 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 = 1.0d0 + (x / y)
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.25d0))) then
tmp = t_0 + ((-1.0d0) / y)
else
tmp = x * t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if ((x <= -1.0) || !(x <= 1.25)) {
tmp = t_0 + (-1.0 / y);
} else {
tmp = x * t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if (x <= -1.0) or not (x <= 1.25): tmp = t_0 + (-1.0 / y) else: tmp = x * t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.25)) tmp = Float64(t_0 + Float64(-1.0 / y)); else tmp = Float64(x * t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.25))) tmp = t_0 + (-1.0 / y); else tmp = x * t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.25]], $MachinePrecision]], N[(t$95$0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.25\right):\\
\;\;\;\;t\_0 + \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if x < -1 or 1.25 < x Initial program 73.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.4%
if -1 < x < 1.25Initial program 99.9%
*-commutative99.9%
associate-/l*99.5%
remove-double-neg99.5%
neg-mul-199.5%
*-commutative99.5%
associate-/r*99.5%
+-commutative99.5%
remove-double-neg99.5%
unsub-neg99.5%
div-sub99.4%
*-inverses99.4%
div-sub99.4%
associate-/r*99.4%
*-commutative99.4%
neg-mul-199.4%
remove-double-neg99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 98.2%
associate-/r/98.6%
/-rgt-identity98.6%
+-commutative98.6%
Applied egg-rr98.6%
Final simplification99.0%
(FPCore (x y) :precision binary64 (if (<= x -0.65) 1.0 (if (<= x 2.6e-17) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -0.65) {
tmp = 1.0;
} else if (x <= 2.6e-17) {
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 <= (-0.65d0)) then
tmp = 1.0d0
else if (x <= 2.6d-17) 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 <= -0.65) {
tmp = 1.0;
} else if (x <= 2.6e-17) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.65: tmp = 1.0 elif x <= 2.6e-17: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -0.65) tmp = 1.0; elseif (x <= 2.6e-17) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.65) tmp = 1.0; elseif (x <= 2.6e-17) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.65], 1.0, If[LessEqual[x, 2.6e-17], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.65:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-17}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -0.650000000000000022 or 2.60000000000000003e-17 < x Initial program 74.5%
*-commutative74.5%
associate-/l*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/r*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
*-inverses100.0%
div-sub100.0%
associate-/r*100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 26.3%
Taylor expanded in x around inf 25.7%
if -0.650000000000000022 < x < 2.60000000000000003e-17Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 75.6%
Final simplification49.1%
(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 86.4%
associate-/l*99.9%
Simplified99.9%
Final simplification99.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 86.4%
*-commutative86.4%
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 inf 49.2%
Taylor expanded in x around inf 15.5%
Final simplification15.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 2024027
(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)))