
(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 9 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 y) 1.0))) (if (or (<= x -1.45e+162) (not (<= x 10.0))) t_0 (/ (* x t_0) (+ x 1.0)))))
double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double tmp;
if ((x <= -1.45e+162) || !(x <= 10.0)) {
tmp = t_0;
} else {
tmp = (x * t_0) / (x + 1.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x / y) + 1.0d0
if ((x <= (-1.45d+162)) .or. (.not. (x <= 10.0d0))) then
tmp = t_0
else
tmp = (x * t_0) / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double tmp;
if ((x <= -1.45e+162) || !(x <= 10.0)) {
tmp = t_0;
} else {
tmp = (x * t_0) / (x + 1.0);
}
return tmp;
}
def code(x, y): t_0 = (x / y) + 1.0 tmp = 0 if (x <= -1.45e+162) or not (x <= 10.0): tmp = t_0 else: tmp = (x * t_0) / (x + 1.0) return tmp
function code(x, y) t_0 = Float64(Float64(x / y) + 1.0) tmp = 0.0 if ((x <= -1.45e+162) || !(x <= 10.0)) tmp = t_0; else tmp = Float64(Float64(x * t_0) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) + 1.0; tmp = 0.0; if ((x <= -1.45e+162) || ~((x <= 10.0))) tmp = t_0; else tmp = (x * t_0) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]}, If[Or[LessEqual[x, -1.45e+162], N[Not[LessEqual[x, 10.0]], $MachinePrecision]], t$95$0, N[(N[(x * t$95$0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + 1\\
\mathbf{if}\;x \leq -1.45 \cdot 10^{+162} \lor \neg \left(x \leq 10\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot t_0}{x + 1}\\
\end{array}
\end{array}
if x < -1.45000000000000003e162 or 10 < x Initial program 60.8%
*-commutative60.8%
associate-/l*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
distribute-frac-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
if -1.45000000000000003e162 < x < 10Initial program 99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= x -3.6e+78)
(/ x y)
(if (<= x -1.6e-8)
(/ x (+ x 1.0))
(if (<= x 6.8) (* x (+ (/ x y) 1.0)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -3.6e+78) {
tmp = x / y;
} else if (x <= -1.6e-8) {
tmp = x / (x + 1.0);
} else if (x <= 6.8) {
tmp = x * ((x / y) + 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) :: tmp
if (x <= (-3.6d+78)) then
tmp = x / y
else if (x <= (-1.6d-8)) then
tmp = x / (x + 1.0d0)
else if (x <= 6.8d0) then
tmp = x * ((x / y) + 1.0d0)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.6e+78) {
tmp = x / y;
} else if (x <= -1.6e-8) {
tmp = x / (x + 1.0);
} else if (x <= 6.8) {
tmp = x * ((x / y) + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.6e+78: tmp = x / y elif x <= -1.6e-8: tmp = x / (x + 1.0) elif x <= 6.8: tmp = x * ((x / y) + 1.0) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -3.6e+78) tmp = Float64(x / y); elseif (x <= -1.6e-8) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 6.8) tmp = Float64(x * Float64(Float64(x / y) + 1.0)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.6e+78) tmp = x / y; elseif (x <= -1.6e-8) tmp = x / (x + 1.0); elseif (x <= 6.8) tmp = x * ((x / y) + 1.0); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.6e+78], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.6e-8], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.8], N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{+78}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1.6 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 6.8:\\
\;\;\;\;x \cdot \left(\frac{x}{y} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -3.6000000000000002e78 or 6.79999999999999982 < x Initial program 67.7%
Taylor expanded in x around inf 79.4%
if -3.6000000000000002e78 < x < -1.6000000000000001e-8Initial program 99.9%
Taylor expanded in y around inf 69.9%
+-commutative69.9%
Simplified69.9%
if -1.6000000000000001e-8 < x < 6.79999999999999982Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
+-commutative99.7%
remove-double-neg99.7%
unsub-neg99.7%
div-sub99.7%
distribute-frac-neg99.7%
*-inverses99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 97.2%
associate-/r/97.4%
/-rgt-identity97.4%
Applied egg-rr97.4%
Final simplification87.8%
(FPCore (x y)
:precision binary64
(if (<= x -8.5e+77)
(/ x y)
(if (<= x -6.2e-8)
(/ x (+ x 1.0))
(if (<= x 5e-9) (* x (+ (/ x y) 1.0)) (/ x (+ y (/ y x)))))))
double code(double x, double y) {
double tmp;
if (x <= -8.5e+77) {
tmp = x / y;
} else if (x <= -6.2e-8) {
tmp = x / (x + 1.0);
} else if (x <= 5e-9) {
tmp = x * ((x / y) + 1.0);
} else {
tmp = x / (y + (y / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-8.5d+77)) then
tmp = x / y
else if (x <= (-6.2d-8)) then
tmp = x / (x + 1.0d0)
else if (x <= 5d-9) then
tmp = x * ((x / y) + 1.0d0)
else
tmp = x / (y + (y / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -8.5e+77) {
tmp = x / y;
} else if (x <= -6.2e-8) {
tmp = x / (x + 1.0);
} else if (x <= 5e-9) {
tmp = x * ((x / y) + 1.0);
} else {
tmp = x / (y + (y / x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8.5e+77: tmp = x / y elif x <= -6.2e-8: tmp = x / (x + 1.0) elif x <= 5e-9: tmp = x * ((x / y) + 1.0) else: tmp = x / (y + (y / x)) return tmp
function code(x, y) tmp = 0.0 if (x <= -8.5e+77) tmp = Float64(x / y); elseif (x <= -6.2e-8) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 5e-9) tmp = Float64(x * Float64(Float64(x / y) + 1.0)); else tmp = Float64(x / Float64(y + Float64(y / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -8.5e+77) tmp = x / y; elseif (x <= -6.2e-8) tmp = x / (x + 1.0); elseif (x <= 5e-9) tmp = x * ((x / y) + 1.0); else tmp = x / (y + (y / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8.5e+77], N[(x / y), $MachinePrecision], If[LessEqual[x, -6.2e-8], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e-9], N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{+77}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -6.2 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-9}:\\
\;\;\;\;x \cdot \left(\frac{x}{y} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\end{array}
\end{array}
if x < -8.50000000000000018e77Initial program 66.5%
Taylor expanded in x around inf 78.1%
if -8.50000000000000018e77 < x < -6.2e-8Initial program 99.9%
Taylor expanded in y around inf 69.9%
+-commutative69.9%
Simplified69.9%
if -6.2e-8 < x < 5.0000000000000001e-9Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
+-commutative99.7%
remove-double-neg99.7%
unsub-neg99.7%
div-sub99.7%
distribute-frac-neg99.7%
*-inverses99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
associate-/r/99.9%
/-rgt-identity99.9%
Applied egg-rr99.9%
if 5.0000000000000001e-9 < x Initial program 71.5%
*-commutative71.5%
associate-/l*99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub100.0%
distribute-frac-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 80.5%
distribute-lft-in80.5%
*-rgt-identity80.5%
associate-*r/80.5%
*-rgt-identity80.5%
Simplified80.5%
Final simplification88.7%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ (/ x y) 1.0))) (if (or (<= x -1.0) (not (<= x 1.0))) t_0 (* x t_0))))
double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = t_0;
} 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 = (x / y) + 1.0d0
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = t_0
else
tmp = x * t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x / y) + 1.0;
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = t_0;
} else {
tmp = x * t_0;
}
return tmp;
}
def code(x, y): t_0 = (x / y) + 1.0 tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = t_0 else: tmp = x * t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x / y) + 1.0) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = t_0; else tmp = Float64(x * t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) + 1.0; tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = t_0; else tmp = x * t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]}, If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], t$95$0, N[(x * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + 1\\
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot t_0\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 72.1%
*-commutative72.1%
associate-/l*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
distribute-frac-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 98.8%
if -1 < x < 1Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
+-commutative99.7%
remove-double-neg99.7%
unsub-neg99.7%
div-sub99.7%
distribute-frac-neg99.7%
*-inverses99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 96.2%
associate-/r/96.3%
/-rgt-identity96.3%
Applied egg-rr96.3%
Final simplification97.5%
(FPCore (x y) :precision binary64 (/ (+ (/ x y) 1.0) (- (/ 1.0 x) -1.0)))
double code(double x, double y) {
return ((x / y) + 1.0) / ((1.0 / x) - -1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / y) + 1.0d0) / ((1.0d0 / x) - (-1.0d0))
end function
public static double code(double x, double y) {
return ((x / y) + 1.0) / ((1.0 / x) - -1.0);
}
def code(x, y): return ((x / y) + 1.0) / ((1.0 / x) - -1.0)
function code(x, y) return Float64(Float64(Float64(x / y) + 1.0) / Float64(Float64(1.0 / x) - -1.0)) end
function tmp = code(x, y) tmp = ((x / y) + 1.0) / ((1.0 / x) - -1.0); end
code[x_, y_] := N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[(1.0 / x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{x}{y} + 1}{\frac{1}{x} - -1}
\end{array}
Initial program 86.5%
*-commutative86.5%
associate-/l*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
distribute-frac-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= x -3e+78) (/ x y) (if (<= x -2000000000.0) 1.0 (if (<= x 4.8) x (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -3e+78) {
tmp = x / y;
} else if (x <= -2000000000.0) {
tmp = 1.0;
} else if (x <= 4.8) {
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 <= (-3d+78)) then
tmp = x / y
else if (x <= (-2000000000.0d0)) then
tmp = 1.0d0
else if (x <= 4.8d0) 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 <= -3e+78) {
tmp = x / y;
} else if (x <= -2000000000.0) {
tmp = 1.0;
} else if (x <= 4.8) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3e+78: tmp = x / y elif x <= -2000000000.0: tmp = 1.0 elif x <= 4.8: tmp = x else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -3e+78) tmp = Float64(x / y); elseif (x <= -2000000000.0) tmp = 1.0; elseif (x <= 4.8) tmp = x; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3e+78) tmp = x / y; elseif (x <= -2000000000.0) tmp = 1.0; elseif (x <= 4.8) tmp = x; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3e+78], N[(x / y), $MachinePrecision], If[LessEqual[x, -2000000000.0], 1.0, If[LessEqual[x, 4.8], x, N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{+78}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -2000000000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.8:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -2.99999999999999982e78 or 4.79999999999999982 < x Initial program 67.7%
Taylor expanded in x around inf 79.4%
if -2.99999999999999982e78 < x < -2e9Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
distribute-frac-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
metadata-eval100.0%
sub-neg100.0%
inv-pow100.0%
inv-pow100.0%
pow-prod-up100.0%
metadata-eval100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 75.1%
Taylor expanded in x around inf 75.1%
if -2e9 < x < 4.79999999999999982Initial program 99.9%
Taylor expanded in x around 0 72.6%
Final simplification75.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.6e+78) (not (<= x 7.0))) (/ x y) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.6e+78) || !(x <= 7.0)) {
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 <= (-1.6d+78)) .or. (.not. (x <= 7.0d0))) 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 <= -1.6e+78) || !(x <= 7.0)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.6e+78) or not (x <= 7.0): tmp = x / y else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.6e+78) || !(x <= 7.0)) 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 <= -1.6e+78) || ~((x <= 7.0))) tmp = x / y; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.6e+78], N[Not[LessEqual[x, 7.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+78} \lor \neg \left(x \leq 7\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -1.59999999999999997e78 or 7 < x Initial program 67.7%
Taylor expanded in x around inf 79.4%
if -1.59999999999999997e78 < x < 7Initial program 99.9%
Taylor expanded in y around inf 74.8%
+-commutative74.8%
Simplified74.8%
Final simplification76.7%
(FPCore (x y) :precision binary64 (if (<= x -2000000000.0) 1.0 (if (<= x 4.8e+52) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -2000000000.0) {
tmp = 1.0;
} else if (x <= 4.8e+52) {
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 <= (-2000000000.0d0)) then
tmp = 1.0d0
else if (x <= 4.8d+52) 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 <= -2000000000.0) {
tmp = 1.0;
} else if (x <= 4.8e+52) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2000000000.0: tmp = 1.0 elif x <= 4.8e+52: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2000000000.0) tmp = 1.0; elseif (x <= 4.8e+52) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2000000000.0) tmp = 1.0; elseif (x <= 4.8e+52) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2000000000.0], 1.0, If[LessEqual[x, 4.8e+52], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2000000000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{+52}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -2e9 or 4.8e52 < x Initial program 71.0%
*-commutative71.0%
associate-/l*100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
distribute-frac-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
metadata-eval100.0%
sub-neg100.0%
inv-pow100.0%
inv-pow100.0%
pow-prod-up100.0%
metadata-eval100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 26.3%
Taylor expanded in x around inf 26.3%
if -2e9 < x < 4.8e52Initial program 99.9%
Taylor expanded in x around 0 71.2%
Final simplification50.3%
(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.5%
*-commutative86.5%
associate-/l*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
distribute-frac-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
flip--76.2%
metadata-eval76.2%
sub-neg76.2%
inv-pow76.2%
inv-pow76.2%
pow-prod-up76.1%
metadata-eval76.1%
metadata-eval76.1%
Applied egg-rr76.1%
Taylor expanded in y around inf 31.4%
Taylor expanded in x around inf 14.4%
Final simplification14.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 2023320
(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)))