
(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 (if (or (<= x -4e+17) (not (<= x 1e+16))) (+ 1.0 (/ (+ x -1.0) y)) (/ (* x (+ 1.0 (/ x y))) (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -4e+17) || !(x <= 1e+16)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = (x * (1.0 + (x / y))) / (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 <= (-4d+17)) .or. (.not. (x <= 1d+16))) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else
tmp = (x * (1.0d0 + (x / y))) / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -4e+17) || !(x <= 1e+16)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = (x * (1.0 + (x / y))) / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -4e+17) or not (x <= 1e+16): tmp = 1.0 + ((x + -1.0) / y) else: tmp = (x * (1.0 + (x / y))) / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -4e+17) || !(x <= 1e+16)) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); else tmp = Float64(Float64(x * Float64(1.0 + Float64(x / y))) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -4e+17) || ~((x <= 1e+16))) tmp = 1.0 + ((x + -1.0) / y); else tmp = (x * (1.0 + (x / y))) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -4e+17], N[Not[LessEqual[x, 1e+16]], $MachinePrecision]], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+17} \lor \neg \left(x \leq 10^{+16}\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(1 + \frac{x}{y}\right)}{x + 1}\\
\end{array}
\end{array}
if x < -4e17 or 1e16 < x Initial program 76.3%
Taylor expanded in x around inf 100.0%
Taylor expanded in y around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
Simplified100.0%
if -4e17 < x < 1e16Initial program 99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (+ (/ x (+ y (/ y x))) (/ 1.0 (+ 1.0 (/ 1.0 x)))))
double code(double x, double y) {
return (x / (y + (y / x))) + (1.0 / (1.0 + (1.0 / x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / (y + (y / x))) + (1.0d0 / (1.0d0 + (1.0d0 / x)))
end function
public static double code(double x, double y) {
return (x / (y + (y / x))) + (1.0 / (1.0 + (1.0 / x)));
}
def code(x, y): return (x / (y + (y / x))) + (1.0 / (1.0 + (1.0 / x)))
function code(x, y) return Float64(Float64(x / Float64(y + Float64(y / x))) + Float64(1.0 / Float64(1.0 + Float64(1.0 / x)))) end
function tmp = code(x, y) tmp = (x / (y + (y / x))) + (1.0 / (1.0 + (1.0 / x))); end
code[x_, y_] := N[(N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y + \frac{y}{x}} + \frac{1}{1 + \frac{1}{x}}
\end{array}
Initial program 87.8%
*-commutative87.8%
associate-/l*99.8%
remove-double-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/r*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
*-inverses99.8%
div-sub99.8%
associate-/r*99.8%
*-commutative99.8%
neg-mul-199.8%
remove-double-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 99.8%
+-commutative99.8%
distribute-lft-in99.8%
*-rgt-identity99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= x -4.2) (not (<= x 235.0))) (+ 1.0 (/ (+ x -1.0) y)) (+ x (/ x (+ y (/ y x))))))
double code(double x, double y) {
double tmp;
if ((x <= -4.2) || !(x <= 235.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 <= (-4.2d0)) .or. (.not. (x <= 235.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 <= -4.2) || !(x <= 235.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 <= -4.2) or not (x <= 235.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 <= -4.2) || !(x <= 235.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 <= -4.2) || ~((x <= 235.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, -4.2], N[Not[LessEqual[x, 235.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 -4.2 \lor \neg \left(x \leq 235\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{x}{y + \frac{y}{x}}\\
\end{array}
\end{array}
if x < -4.20000000000000018 or 235 < x Initial program 77.8%
Taylor expanded in x around inf 98.7%
Taylor expanded in y around -inf 98.8%
mul-1-neg98.8%
unsub-neg98.8%
neg-mul-198.8%
sub-neg98.8%
Simplified98.8%
if -4.20000000000000018 < x < 235Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
remove-double-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-/r*99.6%
+-commutative99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub99.6%
*-inverses99.6%
div-sub99.6%
associate-/r*99.6%
*-commutative99.6%
neg-mul-199.6%
remove-double-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around 0 99.6%
+-commutative99.6%
distribute-lft-in99.6%
*-rgt-identity99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Taylor expanded in x around 0 99.4%
Final simplification99.0%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ (+ x -1.0) y)
(if (<= x 5e-6)
(+ x (/ x (/ y x)))
(if (<= x 9.5e+82) (/ x (+ x 1.0)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = (x + -1.0) / y;
} else if (x <= 5e-6) {
tmp = x + (x / (y / x));
} else if (x <= 9.5e+82) {
tmp = x / (x + 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 <= (-1.0d0)) then
tmp = (x + (-1.0d0)) / y
else if (x <= 5d-6) then
tmp = x + (x / (y / x))
else if (x <= 9.5d+82) then
tmp = x / (x + 1.0d0)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = (x + -1.0) / y;
} else if (x <= 5e-6) {
tmp = x + (x / (y / x));
} else if (x <= 9.5e+82) {
tmp = x / (x + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = (x + -1.0) / y elif x <= 5e-6: tmp = x + (x / (y / x)) elif x <= 9.5e+82: tmp = x / (x + 1.0) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(x + -1.0) / y); elseif (x <= 5e-6) tmp = Float64(x + Float64(x / Float64(y / x))); elseif (x <= 9.5e+82) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = (x + -1.0) / y; elseif (x <= 5e-6) tmp = x + (x / (y / x)); elseif (x <= 9.5e+82) tmp = x / (x + 1.0); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 5e-6], N[(x + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.5e+82], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x + -1}{y}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-6}:\\
\;\;\;\;x + \frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+82}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1Initial program 76.8%
Taylor expanded in x around inf 98.6%
Taylor expanded in y around 0 75.2%
if -1 < x < 5.00000000000000041e-6Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
remove-double-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-/r*99.6%
+-commutative99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub99.6%
*-inverses99.6%
div-sub99.6%
associate-/r*99.6%
*-commutative99.6%
neg-mul-199.6%
remove-double-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around 0 99.6%
+-commutative99.6%
distribute-lft-in99.6%
*-rgt-identity99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Taylor expanded in x around 0 99.4%
Taylor expanded in x around 0 97.9%
if 5.00000000000000041e-6 < x < 9.50000000000000049e82Initial program 94.2%
Taylor expanded in y around inf 75.6%
+-commutative75.6%
Simplified75.6%
if 9.50000000000000049e82 < x Initial program 74.1%
Taylor expanded in x around inf 76.6%
Final simplification85.8%
(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 77.8%
Taylor expanded in x around inf 98.7%
Taylor expanded in y around -inf 98.8%
mul-1-neg98.8%
unsub-neg98.8%
neg-mul-198.8%
sub-neg98.8%
Simplified98.8%
if -1 < x < 1.25Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
remove-double-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-/r*99.6%
+-commutative99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub99.6%
*-inverses99.6%
div-sub99.6%
associate-/r*99.6%
*-commutative99.6%
neg-mul-199.6%
remove-double-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around 0 99.6%
+-commutative99.6%
distribute-lft-in99.6%
*-rgt-identity99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Taylor expanded in x around 0 99.4%
Taylor expanded in x around 0 97.9%
Final simplification98.4%
(FPCore (x y) :precision binary64 (/ (+ 1.0 (/ x y)) (- (/ 1.0 x) -1.0)))
double code(double x, double y) {
return (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 = (1.0d0 + (x / y)) / ((1.0d0 / x) - (-1.0d0))
end function
public static double code(double x, double y) {
return (1.0 + (x / y)) / ((1.0 / x) - -1.0);
}
def code(x, y): return (1.0 + (x / y)) / ((1.0 / x) - -1.0)
function code(x, y) return Float64(Float64(1.0 + Float64(x / y)) / Float64(Float64(1.0 / x) - -1.0)) end
function tmp = code(x, y) tmp = (1.0 + (x / y)) / ((1.0 / x) - -1.0); end
code[x_, y_] := N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + \frac{x}{y}}{\frac{1}{x} - -1}
\end{array}
Initial program 87.8%
*-commutative87.8%
associate-/l*99.8%
remove-double-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/r*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
*-inverses99.8%
div-sub99.8%
associate-/r*99.8%
*-commutative99.8%
neg-mul-199.8%
remove-double-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x 4.8e-6) x (if (<= x 1.3e+84) 1.0 (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 4.8e-6) {
tmp = x;
} else if (x <= 1.3e+84) {
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) :: tmp
if (x <= (-1.0d0)) then
tmp = x / y
else if (x <= 4.8d-6) then
tmp = x
else if (x <= 1.3d+84) then
tmp = 1.0d0
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 4.8e-6) {
tmp = x;
} else if (x <= 1.3e+84) {
tmp = 1.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 4.8e-6: tmp = x elif x <= 1.3e+84: tmp = 1.0 else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 4.8e-6) tmp = x; elseif (x <= 1.3e+84) tmp = 1.0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= 4.8e-6) tmp = x; elseif (x <= 1.3e+84) tmp = 1.0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 4.8e-6], x, If[LessEqual[x, 1.3e+84], 1.0, N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{-6}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+84}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 1.3000000000000001e84 < x Initial program 75.7%
Taylor expanded in x around inf 75.1%
if -1 < x < 4.7999999999999998e-6Initial program 99.9%
Taylor expanded in x around 0 79.5%
if 4.7999999999999998e-6 < x < 1.3000000000000001e84Initial program 94.6%
Taylor expanded in y around inf 71.4%
+-commutative71.4%
Simplified71.4%
Taylor expanded in x around inf 67.2%
Final simplification76.5%
(FPCore (x y) :precision binary64 (if (or (<= x -245000000.0) (not (<= x 6.5e+82))) (/ x y) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -245000000.0) || !(x <= 6.5e+82)) {
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 <= (-245000000.0d0)) .or. (.not. (x <= 6.5d+82))) 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 <= -245000000.0) || !(x <= 6.5e+82)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -245000000.0) or not (x <= 6.5e+82): tmp = x / y else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -245000000.0) || !(x <= 6.5e+82)) 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 <= -245000000.0) || ~((x <= 6.5e+82))) tmp = x / y; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -245000000.0], N[Not[LessEqual[x, 6.5e+82]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -245000000 \lor \neg \left(x \leq 6.5 \cdot 10^{+82}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -2.45e8 or 6.5000000000000003e82 < x Initial program 75.3%
Taylor expanded in x around inf 76.2%
if -2.45e8 < x < 6.5000000000000003e82Initial program 99.2%
Taylor expanded in y around inf 79.3%
+-commutative79.3%
Simplified79.3%
Final simplification77.8%
(FPCore (x y) :precision binary64 (if (<= x -54000000.0) (/ (+ x -1.0) y) (if (<= x 7.2e+83) (/ x (+ x 1.0)) (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -54000000.0) {
tmp = (x + -1.0) / y;
} else if (x <= 7.2e+83) {
tmp = x / (x + 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 <= (-54000000.0d0)) then
tmp = (x + (-1.0d0)) / y
else if (x <= 7.2d+83) then
tmp = x / (x + 1.0d0)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -54000000.0) {
tmp = (x + -1.0) / y;
} else if (x <= 7.2e+83) {
tmp = x / (x + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -54000000.0: tmp = (x + -1.0) / y elif x <= 7.2e+83: tmp = x / (x + 1.0) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -54000000.0) tmp = Float64(Float64(x + -1.0) / y); elseif (x <= 7.2e+83) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -54000000.0) tmp = (x + -1.0) / y; elseif (x <= 7.2e+83) tmp = x / (x + 1.0); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -54000000.0], N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 7.2e+83], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -54000000:\\
\;\;\;\;\frac{x + -1}{y}\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+83}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -5.4e7Initial program 76.1%
Taylor expanded in x around inf 100.0%
Taylor expanded in y around 0 77.1%
if -5.4e7 < x < 7.1999999999999995e83Initial program 99.2%
Taylor expanded in y around inf 79.3%
+-commutative79.3%
Simplified79.3%
if 7.1999999999999995e83 < x Initial program 74.1%
Taylor expanded in x around inf 76.6%
Final simplification78.1%
(FPCore (x y) :precision binary64 (if (<= x -1.0) 1.0 (if (<= x 4.8e-6) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 4.8e-6) {
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 <= (-1.0d0)) then
tmp = 1.0d0
else if (x <= 4.8d-6) 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 <= -1.0) {
tmp = 1.0;
} else if (x <= 4.8e-6) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 elif x <= 4.8e-6: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = 1.0; elseif (x <= 4.8e-6) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = 1.0; elseif (x <= 4.8e-6) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 4.8e-6], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{-6}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 4.7999999999999998e-6 < x Initial program 78.0%
Taylor expanded in y around inf 31.2%
+-commutative31.2%
Simplified31.2%
Taylor expanded in x around inf 30.0%
if -1 < x < 4.7999999999999998e-6Initial program 99.9%
Taylor expanded in x around 0 79.5%
Final simplification52.2%
(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 87.8%
Taylor expanded in y around inf 53.2%
+-commutative53.2%
Simplified53.2%
Taylor expanded in x around inf 18.1%
Final simplification18.1%
(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 2024010
(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)))