
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
(FPCore (x y) :precision binary64 (/ x (/ (+ x 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 92.6%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -200000.0)
(/ x y)
(if (<= x 5e-57)
t_0
(if (<= x 6e-27) (/ x (/ y x)) (if (<= x 3e+56) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -200000.0) {
tmp = x / y;
} else if (x <= 5e-57) {
tmp = t_0;
} else if (x <= 6e-27) {
tmp = x / (y / x);
} else if (x <= 3e+56) {
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 <= (-200000.0d0)) then
tmp = x / y
else if (x <= 5d-57) then
tmp = t_0
else if (x <= 6d-27) then
tmp = x / (y / x)
else if (x <= 3d+56) 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 <= -200000.0) {
tmp = x / y;
} else if (x <= 5e-57) {
tmp = t_0;
} else if (x <= 6e-27) {
tmp = x / (y / x);
} else if (x <= 3e+56) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -200000.0: tmp = x / y elif x <= 5e-57: tmp = t_0 elif x <= 6e-27: tmp = x / (y / x) elif x <= 3e+56: 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 <= -200000.0) tmp = Float64(x / y); elseif (x <= 5e-57) tmp = t_0; elseif (x <= 6e-27) tmp = Float64(x / Float64(y / x)); elseif (x <= 3e+56) 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 <= -200000.0) tmp = x / y; elseif (x <= 5e-57) tmp = t_0; elseif (x <= 6e-27) tmp = x / (y / x); elseif (x <= 3e+56) 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, -200000.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 5e-57], t$95$0, If[LessEqual[x, 6e-27], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3e+56], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -200000:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-27}:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+56}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -2e5 or 3.00000000000000006e56 < x Initial program 82.3%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 76.5%
if -2e5 < x < 5.0000000000000002e-57 or 6.0000000000000002e-27 < x < 3.00000000000000006e56Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 78.7%
if 5.0000000000000002e-57 < x < 6.0000000000000002e-27Initial program 99.6%
*-commutative99.6%
associate-/l*99.3%
remove-double-neg99.3%
neg-mul-199.3%
*-commutative99.3%
associate-/r*99.3%
+-commutative99.3%
remove-double-neg99.3%
unsub-neg99.3%
div-sub99.3%
*-inverses99.3%
div-sub99.3%
associate-/r*99.3%
*-commutative99.3%
neg-mul-199.3%
remove-double-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in y around 0 74.1%
distribute-rgt-in74.1%
*-lft-identity74.1%
associate-*l/74.1%
*-lft-identity74.1%
Simplified74.1%
Taylor expanded in x around 0 74.1%
Final simplification77.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -44.0)
(/ (+ x -1.0) y)
(if (<= x 6.2e-57)
t_0
(if (<= x 1.42e-30) (/ x (/ y x)) (if (<= x 3e+56) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -44.0) {
tmp = (x + -1.0) / y;
} else if (x <= 6.2e-57) {
tmp = t_0;
} else if (x <= 1.42e-30) {
tmp = x / (y / x);
} else if (x <= 3e+56) {
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 <= (-44.0d0)) then
tmp = (x + (-1.0d0)) / y
else if (x <= 6.2d-57) then
tmp = t_0
else if (x <= 1.42d-30) then
tmp = x / (y / x)
else if (x <= 3d+56) 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 <= -44.0) {
tmp = (x + -1.0) / y;
} else if (x <= 6.2e-57) {
tmp = t_0;
} else if (x <= 1.42e-30) {
tmp = x / (y / x);
} else if (x <= 3e+56) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -44.0: tmp = (x + -1.0) / y elif x <= 6.2e-57: tmp = t_0 elif x <= 1.42e-30: tmp = x / (y / x) elif x <= 3e+56: 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 <= -44.0) tmp = Float64(Float64(x + -1.0) / y); elseif (x <= 6.2e-57) tmp = t_0; elseif (x <= 1.42e-30) tmp = Float64(x / Float64(y / x)); elseif (x <= 3e+56) 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 <= -44.0) tmp = (x + -1.0) / y; elseif (x <= 6.2e-57) tmp = t_0; elseif (x <= 1.42e-30) tmp = x / (y / x); elseif (x <= 3e+56) 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, -44.0], N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 6.2e-57], t$95$0, If[LessEqual[x, 1.42e-30], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3e+56], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -44:\\
\;\;\;\;\frac{x + -1}{y}\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.42 \cdot 10^{-30}:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+56}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -44Initial program 83.3%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 98.5%
Taylor expanded in y around 0 75.0%
if -44 < x < 6.19999999999999952e-57 or 1.42e-30 < x < 3.00000000000000006e56Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 78.7%
if 6.19999999999999952e-57 < x < 1.42e-30Initial program 99.6%
*-commutative99.6%
associate-/l*99.3%
remove-double-neg99.3%
neg-mul-199.3%
*-commutative99.3%
associate-/r*99.3%
+-commutative99.3%
remove-double-neg99.3%
unsub-neg99.3%
div-sub99.3%
*-inverses99.3%
div-sub99.3%
associate-/r*99.3%
*-commutative99.3%
neg-mul-199.3%
remove-double-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in y around 0 74.1%
distribute-rgt-in74.1%
*-lft-identity74.1%
associate-*l/74.1%
*-lft-identity74.1%
Simplified74.1%
Taylor expanded in x around 0 74.1%
if 3.00000000000000006e56 < x Initial program 81.5%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 79.5%
Final simplification78.0%
(FPCore (x y) :precision binary64 (if (or (<= x -6200000000.0) (not (<= x 380000.0))) (+ 1.0 (/ (+ x -1.0) y)) (+ x (/ x (+ y (/ y x))))))
double code(double x, double y) {
double tmp;
if ((x <= -6200000000.0) || !(x <= 380000.0)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x + (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 <= (-6200000000.0d0)) .or. (.not. (x <= 380000.0d0))) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else
tmp = x + (x / (y + (y / x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -6200000000.0) || !(x <= 380000.0)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x + (x / (y + (y / x)));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -6200000000.0) or not (x <= 380000.0): tmp = 1.0 + ((x + -1.0) / y) else: tmp = x + (x / (y + (y / x))) return tmp
function code(x, y) tmp = 0.0 if ((x <= -6200000000.0) || !(x <= 380000.0)) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); else tmp = Float64(x + Float64(x / Float64(y + Float64(y / x)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -6200000000.0) || ~((x <= 380000.0))) tmp = 1.0 + ((x + -1.0) / y); else tmp = x + (x / (y + (y / x))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -6200000000.0], N[Not[LessEqual[x, 380000.0]], $MachinePrecision]], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6200000000 \lor \neg \left(x \leq 380000\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{x}{y + \frac{y}{x}}\\
\end{array}
\end{array}
if x < -6.2e9 or 3.8e5 < x Initial program 83.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.8%
associate--l+99.8%
+-commutative99.8%
sub-div99.8%
Applied egg-rr99.8%
if -6.2e9 < x < 3.8e5Initial program 99.8%
*-commutative99.8%
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.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 99.6%
+-commutative99.6%
distribute-rgt-in99.6%
*-lft-identity99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in x around 0 98.5%
Final simplification99.1%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 8.5))) (/ (+ x -1.0) y) (+ x (* x (/ x y)))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 8.5)) {
tmp = (x + -1.0) / y;
} else {
tmp = x + (x * (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)) .or. (.not. (x <= 8.5d0))) then
tmp = (x + (-1.0d0)) / y
else
tmp = x + (x * (x / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 8.5)) {
tmp = (x + -1.0) / y;
} else {
tmp = x + (x * (x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 8.5): tmp = (x + -1.0) / y else: tmp = x + (x * (x / y)) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 8.5)) tmp = Float64(Float64(x + -1.0) / y); else tmp = Float64(x + Float64(x * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 8.5))) tmp = (x + -1.0) / y; else tmp = x + (x * (x / y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 8.5]], $MachinePrecision]], N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision], N[(x + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 8.5\right):\\
\;\;\;\;\frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 8.5 < x Initial program 83.6%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.1%
Taylor expanded in y around 0 74.5%
if -1 < x < 8.5Initial program 99.8%
*-commutative99.8%
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.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 99.5%
+-commutative99.5%
distribute-rgt-in99.5%
*-lft-identity99.5%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in x around 0 98.5%
Taylor expanded in x around 0 97.8%
associate-/r/97.7%
Applied egg-rr97.7%
Final simplification87.4%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 7.5))) (/ (+ x -1.0) y) (+ x (/ x (/ y x)))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 7.5)) {
tmp = (x + -1.0) / y;
} else {
tmp = x + (x / (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 <= (-1.0d0)) .or. (.not. (x <= 7.5d0))) then
tmp = (x + (-1.0d0)) / y
else
tmp = x + (x / (y / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 7.5)) {
tmp = (x + -1.0) / y;
} else {
tmp = x + (x / (y / x));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 7.5): tmp = (x + -1.0) / y else: tmp = x + (x / (y / x)) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 7.5)) tmp = Float64(Float64(x + -1.0) / y); else tmp = Float64(x + Float64(x / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 7.5))) tmp = (x + -1.0) / y; else tmp = x + (x / (y / x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 7.5]], $MachinePrecision]], N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision], N[(x + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 7.5\right):\\
\;\;\;\;\frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{x}{\frac{y}{x}}\\
\end{array}
\end{array}
if x < -1 or 7.5 < x Initial program 83.6%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.1%
Taylor expanded in y around 0 74.5%
if -1 < x < 7.5Initial program 99.8%
*-commutative99.8%
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.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 99.5%
+-commutative99.5%
distribute-rgt-in99.5%
*-lft-identity99.5%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in x around 0 98.5%
Taylor expanded in x around 0 97.8%
Final simplification87.4%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.25))) (+ 1.0 (/ (+ x -1.0) y)) (+ x (/ x (/ y x)))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.25)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x + (x / (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 <= (-1.0d0)) .or. (.not. (x <= 1.25d0))) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else
tmp = x + (x / (y / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.25)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x + (x / (y / x));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 1.25): tmp = 1.0 + ((x + -1.0) / y) else: tmp = x + (x / (y / x)) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.25)) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); else tmp = Float64(x + Float64(x / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.25))) tmp = 1.0 + ((x + -1.0) / y); else tmp = x + (x / (y / x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.25]], $MachinePrecision]], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.25\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{x}{\frac{y}{x}}\\
\end{array}
\end{array}
if x < -1 or 1.25 < x Initial program 83.6%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 99.1%
associate--l+99.1%
+-commutative99.1%
sub-div99.1%
Applied egg-rr99.1%
if -1 < x < 1.25Initial program 99.8%
*-commutative99.8%
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.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 99.5%
+-commutative99.5%
distribute-rgt-in99.5%
*-lft-identity99.5%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in x around 0 98.5%
Taylor expanded in x around 0 97.8%
Final simplification98.4%
(FPCore (x y) :precision binary64 (if (or (<= x -90000.0) (not (<= x 1.05e+57))) (/ x y) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -90000.0) || !(x <= 1.05e+57)) {
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 <= (-90000.0d0)) .or. (.not. (x <= 1.05d+57))) 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 <= -90000.0) || !(x <= 1.05e+57)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -90000.0) or not (x <= 1.05e+57): tmp = x / y else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -90000.0) || !(x <= 1.05e+57)) 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 <= -90000.0) || ~((x <= 1.05e+57))) tmp = x / y; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -90000.0], N[Not[LessEqual[x, 1.05e+57]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -90000 \lor \neg \left(x \leq 1.05 \cdot 10^{+57}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -9e4 or 1.04999999999999995e57 < x Initial program 82.3%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 76.5%
if -9e4 < x < 1.04999999999999995e57Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 75.7%
Final simplification76.0%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.32))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 0.32)) {
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 <= 0.32d0))) 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 <= 0.32)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 0.32): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.32)) 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 <= 0.32))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.32]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.32\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 0.320000000000000007 < x Initial program 83.6%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 73.2%
if -1 < x < 0.320000000000000007Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 75.6%
Final simplification74.5%
(FPCore (x y) :precision binary64 (if (<= x -440000.0) 1.0 (if (<= x 3.1e+18) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -440000.0) {
tmp = 1.0;
} else if (x <= 3.1e+18) {
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 <= (-440000.0d0)) then
tmp = 1.0d0
else if (x <= 3.1d+18) 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 <= -440000.0) {
tmp = 1.0;
} else if (x <= 3.1e+18) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -440000.0: tmp = 1.0 elif x <= 3.1e+18: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -440000.0) tmp = 1.0; elseif (x <= 3.1e+18) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -440000.0) tmp = 1.0; elseif (x <= 3.1e+18) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -440000.0], 1.0, If[LessEqual[x, 3.1e+18], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -440000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+18}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -4.4e5 or 3.1e18 < x Initial program 82.8%
*-commutative82.8%
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.8%
Taylor expanded in x around inf 26.6%
if -4.4e5 < x < 3.1e18Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 73.2%
Final simplification53.4%
(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 92.6%
*-commutative92.6%
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 54.0%
Taylor expanded in x around inf 13.3%
Final simplification13.3%
(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 2024020
(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)))