
(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 -1.16e+16) (not (<= x 2e+15))) (+ 1.0 (/ (+ x -1.0) y)) (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.16e+16) || !(x <= 2e+15)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = (x * ((x / y) + 1.0)) / (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.16d+16)) .or. (.not. (x <= 2d+15))) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else
tmp = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.16e+16) || !(x <= 2e+15)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = (x * ((x / y) + 1.0)) / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.16e+16) or not (x <= 2e+15): tmp = 1.0 + ((x + -1.0) / y) else: tmp = (x * ((x / y) + 1.0)) / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.16e+16) || !(x <= 2e+15)) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); else tmp = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.16e+16) || ~((x <= 2e+15))) tmp = 1.0 + ((x + -1.0) / y); else tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.16e+16], N[Not[LessEqual[x, 2e+15]], $MachinePrecision]], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.16 \cdot 10^{+16} \lor \neg \left(x \leq 2 \cdot 10^{+15}\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
\end{array}
\end{array}
if x < -1.16e16 or 2e15 < x Initial program 74.1%
*-commutative74.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 y around 0 100.0%
Taylor expanded in x around inf 100.0%
associate--l+100.0%
div-sub100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
if -1.16e16 < x < 2e15Initial program 99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -310000000000.0)
(/ x y)
(if (<= x -5.5e-12)
t_0
(if (<= x 0.0095)
(* x (+ (/ x y) 1.0))
(if (<= x 4e+119) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -310000000000.0) {
tmp = x / y;
} else if (x <= -5.5e-12) {
tmp = t_0;
} else if (x <= 0.0095) {
tmp = x * ((x / y) + 1.0);
} else if (x <= 4e+119) {
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 <= (-310000000000.0d0)) then
tmp = x / y
else if (x <= (-5.5d-12)) then
tmp = t_0
else if (x <= 0.0095d0) then
tmp = x * ((x / y) + 1.0d0)
else if (x <= 4d+119) 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 <= -310000000000.0) {
tmp = x / y;
} else if (x <= -5.5e-12) {
tmp = t_0;
} else if (x <= 0.0095) {
tmp = x * ((x / y) + 1.0);
} else if (x <= 4e+119) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -310000000000.0: tmp = x / y elif x <= -5.5e-12: tmp = t_0 elif x <= 0.0095: tmp = x * ((x / y) + 1.0) elif x <= 4e+119: 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 <= -310000000000.0) tmp = Float64(x / y); elseif (x <= -5.5e-12) tmp = t_0; elseif (x <= 0.0095) tmp = Float64(x * Float64(Float64(x / y) + 1.0)); elseif (x <= 4e+119) 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 <= -310000000000.0) tmp = x / y; elseif (x <= -5.5e-12) tmp = t_0; elseif (x <= 0.0095) tmp = x * ((x / y) + 1.0); elseif (x <= 4e+119) 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, -310000000000.0], N[(x / y), $MachinePrecision], If[LessEqual[x, -5.5e-12], t$95$0, If[LessEqual[x, 0.0095], N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4e+119], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -310000000000:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -5.5 \cdot 10^{-12}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.0095:\\
\;\;\;\;x \cdot \left(\frac{x}{y} + 1\right)\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+119}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -3.1e11 or 3.99999999999999978e119 < x Initial program 70.7%
Taylor expanded in x around inf 83.0%
if -3.1e11 < x < -5.5000000000000004e-12 or 0.00949999999999999976 < x < 3.99999999999999978e119Initial program 96.1%
Taylor expanded in y around inf 83.4%
+-commutative83.4%
Simplified83.4%
if -5.5000000000000004e-12 < x < 0.00949999999999999976Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
+-commutative99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub99.6%
distribute-frac-neg99.6%
*-inverses99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around 0 98.3%
associate-/r/98.6%
/-rgt-identity98.6%
+-commutative98.6%
Applied egg-rr98.6%
Final simplification90.8%
(FPCore (x y) :precision binary64 (if (or (<= x -38.0) (not (<= x 80000.0))) (+ 1.0 (/ (+ x -1.0) y)) (+ x (/ x (+ y (/ y x))))))
double code(double x, double y) {
double tmp;
if ((x <= -38.0) || !(x <= 80000.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 <= (-38.0d0)) .or. (.not. (x <= 80000.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 <= -38.0) || !(x <= 80000.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 <= -38.0) or not (x <= 80000.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 <= -38.0) || !(x <= 80000.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 <= -38.0) || ~((x <= 80000.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, -38.0], N[Not[LessEqual[x, 80000.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 -38 \lor \neg \left(x \leq 80000\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{x}{y + \frac{y}{x}}\\
\end{array}
\end{array}
if x < -38 or 8e4 < x Initial program 75.3%
*-commutative75.3%
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 y around 0 100.0%
Taylor expanded in x around inf 98.4%
associate--l+98.4%
div-sub98.4%
sub-neg98.4%
metadata-eval98.4%
Simplified98.4%
if -38 < x < 8e4Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
+-commutative99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub99.6%
distribute-frac-neg99.6%
*-inverses99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around 0 99.6%
frac-2neg99.6%
add-log-exp72.3%
neg-log72.3%
distribute-lft-in72.3%
div-inv72.3%
exp-sum46.2%
*-rgt-identity46.2%
exp-sum72.3%
neg-log72.3%
add-log-exp99.7%
clear-num99.6%
frac-2neg99.6%
inv-pow99.6%
Applied egg-rr99.6%
unpow-199.6%
Simplified99.6%
Taylor expanded in x around 0 98.7%
Taylor expanded in y around 0 98.6%
distribute-lft-in98.7%
*-rgt-identity98.7%
associate-*r/98.8%
*-rgt-identity98.8%
Simplified98.8%
Final simplification98.6%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x 9.2e-16) x (if (<= x 4e+119) (+ 1.0 (/ -1.0 x)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 9.2e-16) {
tmp = x;
} else if (x <= 4e+119) {
tmp = 1.0 + (-1.0 / 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 <= (-1.0d0)) then
tmp = x / y
else if (x <= 9.2d-16) then
tmp = x
else if (x <= 4d+119) then
tmp = 1.0d0 + ((-1.0d0) / x)
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 <= 9.2e-16) {
tmp = x;
} else if (x <= 4e+119) {
tmp = 1.0 + (-1.0 / x);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 9.2e-16: tmp = x elif x <= 4e+119: tmp = 1.0 + (-1.0 / x) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= 9.2e-16) tmp = x; elseif (x <= 4e+119) tmp = Float64(1.0 + Float64(-1.0 / x)); 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 <= 9.2e-16) tmp = x; elseif (x <= 4e+119) tmp = 1.0 + (-1.0 / x); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 9.2e-16], x, If[LessEqual[x, 4e+119], N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 9.2 \cdot 10^{-16}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+119}:\\
\;\;\;\;1 + \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 3.99999999999999978e119 < x Initial program 71.8%
Taylor expanded in x around inf 80.0%
if -1 < x < 9.1999999999999996e-16Initial program 99.9%
Taylor expanded in x around 0 72.1%
if 9.1999999999999996e-16 < x < 3.99999999999999978e119Initial program 95.7%
Taylor expanded in x around inf 86.4%
associate--r+86.4%
Simplified86.4%
Taylor expanded in x around 0 68.7%
Taylor expanded in y around inf 68.6%
Final simplification75.1%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.2))) (+ 1.0 (/ (+ x -1.0) y)) (* x (+ (/ x y) 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.2)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x * ((x / y) + 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)) .or. (.not. (x <= 1.2d0))) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else
tmp = x * ((x / y) + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.2)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x * ((x / y) + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 1.2): tmp = 1.0 + ((x + -1.0) / y) else: tmp = x * ((x / y) + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.2)) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); else tmp = Float64(x * Float64(Float64(x / y) + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.2))) tmp = 1.0 + ((x + -1.0) / y); else tmp = x * ((x / y) + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.2]], $MachinePrecision]], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.2\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{x}{y} + 1\right)\\
\end{array}
\end{array}
if x < -1 or 1.19999999999999996 < x Initial program 75.3%
*-commutative75.3%
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 y around 0 100.0%
Taylor expanded in x around inf 98.4%
associate--l+98.4%
div-sub98.4%
sub-neg98.4%
metadata-eval98.4%
Simplified98.4%
if -1 < x < 1.19999999999999996Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
+-commutative99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub99.6%
distribute-frac-neg99.6%
*-inverses99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around 0 97.6%
associate-/r/97.9%
/-rgt-identity97.9%
+-commutative97.9%
Applied egg-rr97.9%
Final simplification98.1%
(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 75.3%
*-commutative75.3%
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 y around 0 100.0%
Taylor expanded in x around inf 98.4%
associate--l+98.4%
div-sub98.4%
sub-neg98.4%
metadata-eval98.4%
Simplified98.4%
if -1 < x < 1.25Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
+-commutative99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub99.6%
distribute-frac-neg99.6%
*-inverses99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around 0 97.6%
associate-/r/97.9%
/-rgt-identity97.9%
+-commutative97.9%
Applied egg-rr97.9%
*-commutative97.9%
+-commutative97.9%
distribute-rgt-in97.9%
*-un-lft-identity97.9%
Applied egg-rr97.9%
associate-*l/89.5%
associate-/l*98.0%
Applied egg-rr98.0%
Final simplification98.2%
(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 87.8%
*-commutative87.8%
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 -1.0) (/ x y) (if (<= x 0.0078) x (if (<= x 4.4e+119) 1.0 (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 0.0078) {
tmp = x;
} else if (x <= 4.4e+119) {
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 <= 0.0078d0) then
tmp = x
else if (x <= 4.4d+119) 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 <= 0.0078) {
tmp = x;
} else if (x <= 4.4e+119) {
tmp = 1.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 0.0078: tmp = x elif x <= 4.4e+119: 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 <= 0.0078) tmp = x; elseif (x <= 4.4e+119) 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 <= 0.0078) tmp = x; elseif (x <= 4.4e+119) 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, 0.0078], x, If[LessEqual[x, 4.4e+119], 1.0, N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 0.0078:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+119}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 4.4000000000000003e119 < x Initial program 71.8%
Taylor expanded in x around inf 80.0%
if -1 < x < 0.0077999999999999996Initial program 99.9%
Taylor expanded in x around 0 71.0%
if 0.0077999999999999996 < x < 4.4000000000000003e119Initial program 95.2%
Taylor expanded in y around inf 76.2%
+-commutative76.2%
Simplified76.2%
Taylor expanded in x around inf 73.4%
Final simplification75.0%
(FPCore (x y) :precision binary64 (if (or (<= x -460000000000.0) (not (<= x 4e+119))) (/ x y) (/ x (+ x 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -460000000000.0) || !(x <= 4e+119)) {
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 <= (-460000000000.0d0)) .or. (.not. (x <= 4d+119))) 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 <= -460000000000.0) || !(x <= 4e+119)) {
tmp = x / y;
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -460000000000.0) or not (x <= 4e+119): tmp = x / y else: tmp = x / (x + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -460000000000.0) || !(x <= 4e+119)) 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 <= -460000000000.0) || ~((x <= 4e+119))) tmp = x / y; else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -460000000000.0], N[Not[LessEqual[x, 4e+119]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -460000000000 \lor \neg \left(x \leq 4 \cdot 10^{+119}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -4.6e11 or 3.99999999999999978e119 < x Initial program 70.7%
Taylor expanded in x around inf 83.0%
if -4.6e11 < x < 3.99999999999999978e119Initial program 99.3%
Taylor expanded in y around inf 72.8%
+-commutative72.8%
Simplified72.8%
Final simplification76.9%
(FPCore (x y) :precision binary64 (if (<= x -1.0) 1.0 (if (<= x 0.0078) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 0.0078) {
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 <= 0.0078d0) 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 <= 0.0078) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 elif x <= 0.0078: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = 1.0; elseif (x <= 0.0078) 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 <= 0.0078) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 0.0078], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 0.0078:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 0.0077999999999999996 < x Initial program 75.5%
Taylor expanded in y around inf 28.0%
+-commutative28.0%
Simplified28.0%
Taylor expanded in x around inf 26.6%
if -1 < x < 0.0077999999999999996Initial program 99.9%
Taylor expanded in x around 0 71.0%
Final simplification49.0%
(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 50.0%
+-commutative50.0%
Simplified50.0%
Taylor expanded in x around inf 15.0%
Final simplification15.0%
(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 2023310
(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)))