
(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 89.8%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= y -1.3e+79)
t_0
(if (<= y -5e+43)
(/ x (+ y (/ y x)))
(if (<= y -6e+22) x (if (<= y 3.5e-74) (* (/ x y) t_0) t_0))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (y <= -1.3e+79) {
tmp = t_0;
} else if (y <= -5e+43) {
tmp = x / (y + (y / x));
} else if (y <= -6e+22) {
tmp = x;
} else if (y <= 3.5e-74) {
tmp = (x / y) * t_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 / (x + 1.0d0)
if (y <= (-1.3d+79)) then
tmp = t_0
else if (y <= (-5d+43)) then
tmp = x / (y + (y / x))
else if (y <= (-6d+22)) then
tmp = x
else if (y <= 3.5d-74) then
tmp = (x / y) * t_0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (y <= -1.3e+79) {
tmp = t_0;
} else if (y <= -5e+43) {
tmp = x / (y + (y / x));
} else if (y <= -6e+22) {
tmp = x;
} else if (y <= 3.5e-74) {
tmp = (x / y) * t_0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if y <= -1.3e+79: tmp = t_0 elif y <= -5e+43: tmp = x / (y + (y / x)) elif y <= -6e+22: tmp = x elif y <= 3.5e-74: tmp = (x / y) * t_0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (y <= -1.3e+79) tmp = t_0; elseif (y <= -5e+43) tmp = Float64(x / Float64(y + Float64(y / x))); elseif (y <= -6e+22) tmp = x; elseif (y <= 3.5e-74) tmp = Float64(Float64(x / y) * t_0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + 1.0); tmp = 0.0; if (y <= -1.3e+79) tmp = t_0; elseif (y <= -5e+43) tmp = x / (y + (y / x)); elseif (y <= -6e+22) tmp = x; elseif (y <= 3.5e-74) tmp = (x / y) * t_0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.3e+79], t$95$0, If[LessEqual[y, -5e+43], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -6e+22], x, If[LessEqual[y, 3.5e-74], N[(N[(x / y), $MachinePrecision] * t$95$0), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;y \leq -1.3 \cdot 10^{+79}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -5 \cdot 10^{+43}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{elif}\;y \leq -6 \cdot 10^{+22}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-74}:\\
\;\;\;\;\frac{x}{y} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.30000000000000007e79 or 3.50000000000000015e-74 < y Initial program 93.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 80.2%
if -1.30000000000000007e79 < y < -5.0000000000000004e43Initial program 57.7%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 59.4%
clear-num59.6%
un-div-inv60.0%
associate-/l*71.0%
+-commutative71.0%
Applied egg-rr71.0%
Taylor expanded in x around inf 71.0%
if -5.0000000000000004e43 < y < -6e22Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
if -6e22 < y < 3.50000000000000015e-74Initial program 88.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 80.6%
clear-num80.6%
un-div-inv80.7%
associate-/l*80.6%
+-commutative80.6%
Applied egg-rr80.6%
*-un-lft-identity80.6%
*-commutative80.6%
times-frac80.7%
clear-num80.7%
Applied egg-rr80.7%
Final simplification80.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= y -3.5e+78)
t_0
(if (<= y -5.6e+50)
(/ x (+ y (/ y x)))
(if (<= y -3.2e+22)
x
(if (<= y 5.8e-74) (/ x (/ (* (+ x 1.0) y) x)) t_0))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (y <= -3.5e+78) {
tmp = t_0;
} else if (y <= -5.6e+50) {
tmp = x / (y + (y / x));
} else if (y <= -3.2e+22) {
tmp = x;
} else if (y <= 5.8e-74) {
tmp = x / (((x + 1.0) * y) / 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 / (x + 1.0d0)
if (y <= (-3.5d+78)) then
tmp = t_0
else if (y <= (-5.6d+50)) then
tmp = x / (y + (y / x))
else if (y <= (-3.2d+22)) then
tmp = x
else if (y <= 5.8d-74) then
tmp = x / (((x + 1.0d0) * y) / x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (y <= -3.5e+78) {
tmp = t_0;
} else if (y <= -5.6e+50) {
tmp = x / (y + (y / x));
} else if (y <= -3.2e+22) {
tmp = x;
} else if (y <= 5.8e-74) {
tmp = x / (((x + 1.0) * y) / x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if y <= -3.5e+78: tmp = t_0 elif y <= -5.6e+50: tmp = x / (y + (y / x)) elif y <= -3.2e+22: tmp = x elif y <= 5.8e-74: tmp = x / (((x + 1.0) * y) / x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (y <= -3.5e+78) tmp = t_0; elseif (y <= -5.6e+50) tmp = Float64(x / Float64(y + Float64(y / x))); elseif (y <= -3.2e+22) tmp = x; elseif (y <= 5.8e-74) tmp = Float64(x / Float64(Float64(Float64(x + 1.0) * y) / x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + 1.0); tmp = 0.0; if (y <= -3.5e+78) tmp = t_0; elseif (y <= -5.6e+50) tmp = x / (y + (y / x)); elseif (y <= -3.2e+22) tmp = x; elseif (y <= 5.8e-74) tmp = x / (((x + 1.0) * y) / x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.5e+78], t$95$0, If[LessEqual[y, -5.6e+50], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -3.2e+22], x, If[LessEqual[y, 5.8e-74], N[(x / N[(N[(N[(x + 1.0), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;y \leq -3.5 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -5.6 \cdot 10^{+50}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{elif}\;y \leq -3.2 \cdot 10^{+22}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{-74}:\\
\;\;\;\;\frac{x}{\frac{\left(x + 1\right) \cdot y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.5000000000000001e78 or 5.8e-74 < y Initial program 93.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 80.2%
if -3.5000000000000001e78 < y < -5.5999999999999996e50Initial program 57.7%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 59.4%
clear-num59.6%
un-div-inv60.0%
associate-/l*71.0%
+-commutative71.0%
Applied egg-rr71.0%
Taylor expanded in x around inf 71.0%
if -5.5999999999999996e50 < y < -3.2e22Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
if -3.2e22 < y < 5.8e-74Initial program 88.0%
associate-/l*99.8%
Simplified99.8%
clear-num99.7%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 80.7%
Final simplification80.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= y -9.5e+77)
t_0
(if (<= y -5e+50)
(/ x (+ y (/ y x)))
(if (<= y -3e+22)
x
(if (<= y 5.7e-74) (/ x (/ (+ y (* x y)) x)) t_0))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (y <= -9.5e+77) {
tmp = t_0;
} else if (y <= -5e+50) {
tmp = x / (y + (y / x));
} else if (y <= -3e+22) {
tmp = x;
} else if (y <= 5.7e-74) {
tmp = x / ((y + (x * y)) / 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 / (x + 1.0d0)
if (y <= (-9.5d+77)) then
tmp = t_0
else if (y <= (-5d+50)) then
tmp = x / (y + (y / x))
else if (y <= (-3d+22)) then
tmp = x
else if (y <= 5.7d-74) then
tmp = x / ((y + (x * y)) / x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (y <= -9.5e+77) {
tmp = t_0;
} else if (y <= -5e+50) {
tmp = x / (y + (y / x));
} else if (y <= -3e+22) {
tmp = x;
} else if (y <= 5.7e-74) {
tmp = x / ((y + (x * y)) / x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if y <= -9.5e+77: tmp = t_0 elif y <= -5e+50: tmp = x / (y + (y / x)) elif y <= -3e+22: tmp = x elif y <= 5.7e-74: tmp = x / ((y + (x * y)) / x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (y <= -9.5e+77) tmp = t_0; elseif (y <= -5e+50) tmp = Float64(x / Float64(y + Float64(y / x))); elseif (y <= -3e+22) tmp = x; elseif (y <= 5.7e-74) tmp = Float64(x / Float64(Float64(y + Float64(x * y)) / x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + 1.0); tmp = 0.0; if (y <= -9.5e+77) tmp = t_0; elseif (y <= -5e+50) tmp = x / (y + (y / x)); elseif (y <= -3e+22) tmp = x; elseif (y <= 5.7e-74) tmp = x / ((y + (x * y)) / x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.5e+77], t$95$0, If[LessEqual[y, -5e+50], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -3e+22], x, If[LessEqual[y, 5.7e-74], N[(x / N[(N[(y + N[(x * y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;y \leq -9.5 \cdot 10^{+77}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -5 \cdot 10^{+50}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{elif}\;y \leq -3 \cdot 10^{+22}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 5.7 \cdot 10^{-74}:\\
\;\;\;\;\frac{x}{\frac{y + x \cdot y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9.4999999999999998e77 or 5.70000000000000025e-74 < y Initial program 93.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 80.2%
if -9.4999999999999998e77 < y < -5e50Initial program 57.7%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 59.4%
clear-num59.6%
un-div-inv60.0%
associate-/l*71.0%
+-commutative71.0%
Applied egg-rr71.0%
Taylor expanded in x around inf 71.0%
if -5e50 < y < -3e22Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
if -3e22 < y < 5.70000000000000025e-74Initial program 88.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 80.6%
clear-num80.6%
un-div-inv80.7%
associate-/l*80.6%
+-commutative80.6%
Applied egg-rr80.6%
Taylor expanded in x around inf 80.7%
Taylor expanded in x around 0 80.7%
Final simplification80.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))) (t_1 (/ x (+ y (/ y x)))))
(if (<= y -9.5e+77)
t_0
(if (<= y -4.5e+45)
t_1
(if (<= y -2.9e+22) x (if (<= y 5.8e-74) t_1 t_0))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double t_1 = x / (y + (y / x));
double tmp;
if (y <= -9.5e+77) {
tmp = t_0;
} else if (y <= -4.5e+45) {
tmp = t_1;
} else if (y <= -2.9e+22) {
tmp = x;
} else if (y <= 5.8e-74) {
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 / (x + 1.0d0)
t_1 = x / (y + (y / x))
if (y <= (-9.5d+77)) then
tmp = t_0
else if (y <= (-4.5d+45)) then
tmp = t_1
else if (y <= (-2.9d+22)) then
tmp = x
else if (y <= 5.8d-74) 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 / (x + 1.0);
double t_1 = x / (y + (y / x));
double tmp;
if (y <= -9.5e+77) {
tmp = t_0;
} else if (y <= -4.5e+45) {
tmp = t_1;
} else if (y <= -2.9e+22) {
tmp = x;
} else if (y <= 5.8e-74) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) t_1 = x / (y + (y / x)) tmp = 0 if y <= -9.5e+77: tmp = t_0 elif y <= -4.5e+45: tmp = t_1 elif y <= -2.9e+22: tmp = x elif y <= 5.8e-74: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(x + 1.0)) t_1 = Float64(x / Float64(y + Float64(y / x))) tmp = 0.0 if (y <= -9.5e+77) tmp = t_0; elseif (y <= -4.5e+45) tmp = t_1; elseif (y <= -2.9e+22) tmp = x; elseif (y <= 5.8e-74) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + 1.0); t_1 = x / (y + (y / x)); tmp = 0.0; if (y <= -9.5e+77) tmp = t_0; elseif (y <= -4.5e+45) tmp = t_1; elseif (y <= -2.9e+22) tmp = x; elseif (y <= 5.8e-74) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.5e+77], t$95$0, If[LessEqual[y, -4.5e+45], t$95$1, If[LessEqual[y, -2.9e+22], x, If[LessEqual[y, 5.8e-74], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := \frac{x}{y + \frac{y}{x}}\\
\mathbf{if}\;y \leq -9.5 \cdot 10^{+77}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -4.5 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -2.9 \cdot 10^{+22}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{-74}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9.4999999999999998e77 or 5.8e-74 < y Initial program 93.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 80.2%
if -9.4999999999999998e77 < y < -4.4999999999999998e45 or -2.9e22 < y < 5.8e-74Initial program 85.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 79.1%
clear-num79.1%
un-div-inv79.2%
associate-/l*80.0%
+-commutative80.0%
Applied egg-rr80.0%
Taylor expanded in x around inf 80.0%
if -4.4999999999999998e45 < y < -2.9e22Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification80.6%
(FPCore (x y) :precision binary64 (if (or (<= x -9.2e+24) (not (<= x 1.1e+16))) (/ x y) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -9.2e+24) || !(x <= 1.1e+16)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-9.2d+24)) .or. (.not. (x <= 1.1d+16))) then
tmp = x / y
else
tmp = x / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -9.2e+24) || !(x <= 1.1e+16)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -9.2e+24) or not (x <= 1.1e+16): tmp = x / y else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -9.2e+24) || !(x <= 1.1e+16)) tmp = Float64(x / y); else tmp = Float64(x / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -9.2e+24) || ~((x <= 1.1e+16))) tmp = x / y; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -9.2e+24], N[Not[LessEqual[x, 1.1e+16]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+24} \lor \neg \left(x \leq 1.1 \cdot 10^{+16}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -9.1999999999999996e24 or 1.1e16 < x Initial program 77.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 77.4%
if -9.1999999999999996e24 < x < 1.1e16Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 76.0%
Final simplification76.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 3.1e+15))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 3.1e+15)) {
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 <= 3.1d+15))) 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 <= 3.1e+15)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 3.1e+15): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 3.1e+15)) 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 <= 3.1e+15))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 3.1e+15]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 3.1 \cdot 10^{+15}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 3.1e15 < x Initial program 79.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 74.4%
if -1 < x < 3.1e15Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 75.0%
Final simplification74.7%
(FPCore (x y) :precision binary64 (if (<= x -175000000.0) 1.0 (if (<= x 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -175000000.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 <= (-175000000.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 <= -175000000.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 <= -175000000.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 <= -175000000.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 <= -175000000.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, -175000000.0], 1.0, If[LessEqual[x, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1.75e8 or 1 < x Initial program 79.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 26.3%
clear-num26.3%
inv-pow26.3%
+-commutative26.3%
Applied egg-rr26.3%
unpow-126.3%
+-commutative26.3%
Simplified26.3%
Taylor expanded in x around inf 26.1%
if -1.75e8 < x < 1Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 75.0%
Final simplification51.3%
(FPCore (x y) :precision binary64 (* x (/ (+ 1.0 (/ x y)) (+ x 1.0))))
double code(double x, double y) {
return x * ((1.0 + (x / y)) / (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)) / (x + 1.0d0))
end function
public static double code(double x, double y) {
return x * ((1.0 + (x / y)) / (x + 1.0));
}
def code(x, y): return x * ((1.0 + (x / y)) / (x + 1.0))
function code(x, y) return Float64(x * Float64(Float64(1.0 + Float64(x / y)) / Float64(x + 1.0))) end
function tmp = code(x, y) tmp = x * ((1.0 + (x / y)) / (x + 1.0)); end
code[x_, y_] := N[(x * N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{1 + \frac{x}{y}}{x + 1}
\end{array}
Initial program 89.8%
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 89.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 52.0%
clear-num51.8%
inv-pow51.8%
+-commutative51.8%
Applied egg-rr51.8%
unpow-151.8%
+-commutative51.8%
Simplified51.8%
Taylor expanded in x around inf 14.5%
Final simplification14.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 2024075
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:alt
(* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0)))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))