
(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 12 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 (+ 1.0 (/ x y))) (+ x 1.0))))
(if (or (<= t_0 -2e+53) (not (<= t_0 5e+15)))
(/ (/ x y) (+ 1.0 (/ 1.0 x)))
t_0)))
double code(double x, double y) {
double t_0 = (x * (1.0 + (x / y))) / (x + 1.0);
double tmp;
if ((t_0 <= -2e+53) || !(t_0 <= 5e+15)) {
tmp = (x / y) / (1.0 + (1.0 / x));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x * (1.0d0 + (x / y))) / (x + 1.0d0)
if ((t_0 <= (-2d+53)) .or. (.not. (t_0 <= 5d+15))) then
tmp = (x / y) / (1.0d0 + (1.0d0 / x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * (1.0 + (x / y))) / (x + 1.0);
double tmp;
if ((t_0 <= -2e+53) || !(t_0 <= 5e+15)) {
tmp = (x / y) / (1.0 + (1.0 / x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x * (1.0 + (x / y))) / (x + 1.0) tmp = 0 if (t_0 <= -2e+53) or not (t_0 <= 5e+15): tmp = (x / y) / (1.0 + (1.0 / x)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(1.0 + Float64(x / y))) / Float64(x + 1.0)) tmp = 0.0 if ((t_0 <= -2e+53) || !(t_0 <= 5e+15)) tmp = Float64(Float64(x / y) / Float64(1.0 + Float64(1.0 / x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x * (1.0 + (x / y))) / (x + 1.0); tmp = 0.0; if ((t_0 <= -2e+53) || ~((t_0 <= 5e+15))) tmp = (x / y) / (1.0 + (1.0 / x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e+53], N[Not[LessEqual[t$95$0, 5e+15]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] / N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(1 + \frac{x}{y}\right)}{x + 1}\\
\mathbf{if}\;t_0 \leq -2 \cdot 10^{+53} \lor \neg \left(t_0 \leq 5 \cdot 10^{+15}\right):\\
\;\;\;\;\frac{\frac{x}{y}}{1 + \frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) 1)) (+.f64 x 1)) < -2e53 or 5e15 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) 1)) (+.f64 x 1)) Initial program 70.6%
*-commutative70.6%
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 0 99.9%
associate-/r*100.0%
Simplified100.0%
if -2e53 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) 1)) (+.f64 x 1)) < 5e15Initial 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 89.0%
*-commutative89.0%
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
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= x -2e+20)
(/ x y)
(if (<= x 3.1e-79)
t_0
(if (<= x 2.3e-6) (* x (/ x y)) (if (<= x 5.5e+101) t_0 (/ x y)))))))
double code(double x, double y) {
double t_0 = x / (x + 1.0);
double tmp;
if (x <= -2e+20) {
tmp = x / y;
} else if (x <= 3.1e-79) {
tmp = t_0;
} else if (x <= 2.3e-6) {
tmp = x * (x / y);
} else if (x <= 5.5e+101) {
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 <= (-2d+20)) then
tmp = x / y
else if (x <= 3.1d-79) then
tmp = t_0
else if (x <= 2.3d-6) then
tmp = x * (x / y)
else if (x <= 5.5d+101) 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 <= -2e+20) {
tmp = x / y;
} else if (x <= 3.1e-79) {
tmp = t_0;
} else if (x <= 2.3e-6) {
tmp = x * (x / y);
} else if (x <= 5.5e+101) {
tmp = t_0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = x / (x + 1.0) tmp = 0 if x <= -2e+20: tmp = x / y elif x <= 3.1e-79: tmp = t_0 elif x <= 2.3e-6: tmp = x * (x / y) elif x <= 5.5e+101: 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 <= -2e+20) tmp = Float64(x / y); elseif (x <= 3.1e-79) tmp = t_0; elseif (x <= 2.3e-6) tmp = Float64(x * Float64(x / y)); elseif (x <= 5.5e+101) 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 <= -2e+20) tmp = x / y; elseif (x <= 3.1e-79) tmp = t_0; elseif (x <= 2.3e-6) tmp = x * (x / y); elseif (x <= 5.5e+101) 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, -2e+20], N[(x / y), $MachinePrecision], If[LessEqual[x, 3.1e-79], t$95$0, If[LessEqual[x, 2.3e-6], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e+101], t$95$0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -2 \cdot 10^{+20}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-79}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-6}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+101}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -2e20 or 5.50000000000000018e101 < x Initial program 72.4%
Taylor expanded in x around inf 82.7%
if -2e20 < x < 3.0999999999999999e-79 or 2.3e-6 < x < 5.50000000000000018e101Initial program 99.3%
Taylor expanded in y around inf 78.3%
+-commutative78.3%
Simplified78.3%
if 3.0999999999999999e-79 < x < 2.3e-6Initial program 99.9%
*-commutative99.9%
associate-/l*99.9%
remove-double-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/r*99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
*-inverses99.9%
div-sub99.9%
associate-/r*99.9%
*-commutative99.9%
neg-mul-199.9%
remove-double-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 64.9%
distribute-lft-in64.8%
*-rgt-identity64.8%
associate-*r/64.8%
*-rgt-identity64.8%
Simplified64.8%
Taylor expanded in x around 0 60.7%
associate-/r/60.8%
Applied egg-rr60.8%
Final simplification78.7%
(FPCore (x y) :precision binary64 (if (or (<= x -78000000000.0) (not (<= x 140000000.0))) (+ 1.0 (/ x y)) (+ x (/ x (+ y (/ y x))))))
double code(double x, double y) {
double tmp;
if ((x <= -78000000000.0) || !(x <= 140000000.0)) {
tmp = 1.0 + (x / 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 <= (-78000000000.0d0)) .or. (.not. (x <= 140000000.0d0))) then
tmp = 1.0d0 + (x / 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 <= -78000000000.0) || !(x <= 140000000.0)) {
tmp = 1.0 + (x / y);
} else {
tmp = x + (x / (y + (y / x)));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -78000000000.0) or not (x <= 140000000.0): tmp = 1.0 + (x / y) else: tmp = x + (x / (y + (y / x))) return tmp
function code(x, y) tmp = 0.0 if ((x <= -78000000000.0) || !(x <= 140000000.0)) tmp = Float64(1.0 + Float64(x / 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 <= -78000000000.0) || ~((x <= 140000000.0))) tmp = 1.0 + (x / y); else tmp = x + (x / (y + (y / x))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -78000000000.0], N[Not[LessEqual[x, 140000000.0]], $MachinePrecision]], N[(1.0 + N[(x / 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 -78000000000 \lor \neg \left(x \leq 140000000\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{x}{y + \frac{y}{x}}\\
\end{array}
\end{array}
if x < -7.8e10 or 1.4e8 < x Initial program 77.6%
*-commutative77.6%
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 x around inf 99.3%
if -7.8e10 < x < 1.4e8Initial program 99.3%
*-commutative99.3%
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 0 99.7%
+-commutative99.7%
distribute-lft-in99.6%
*-rgt-identity99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 98.9%
Final simplification99.1%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ x y)
(if (<= x 3.1e-79)
x
(if (<= x 2900000.0) (* x (/ x y)) (if (<= x 4.2e+101) 1.0 (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 3.1e-79) {
tmp = x;
} else if (x <= 2900000.0) {
tmp = x * (x / y);
} else if (x <= 4.2e+101) {
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 <= 3.1d-79) then
tmp = x
else if (x <= 2900000.0d0) then
tmp = x * (x / y)
else if (x <= 4.2d+101) 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 <= 3.1e-79) {
tmp = x;
} else if (x <= 2900000.0) {
tmp = x * (x / y);
} else if (x <= 4.2e+101) {
tmp = 1.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 3.1e-79: tmp = x elif x <= 2900000.0: tmp = x * (x / y) elif x <= 4.2e+101: 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 <= 3.1e-79) tmp = x; elseif (x <= 2900000.0) tmp = Float64(x * Float64(x / y)); elseif (x <= 4.2e+101) 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 <= 3.1e-79) tmp = x; elseif (x <= 2900000.0) tmp = x * (x / y); elseif (x <= 4.2e+101) 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, 3.1e-79], x, If[LessEqual[x, 2900000.0], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.2e+101], 1.0, N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-79}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2900000:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+101}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 4.2e101 < x Initial program 73.4%
Taylor expanded in x around inf 79.0%
if -1 < x < 3.0999999999999999e-79Initial program 99.9%
Taylor expanded in x around 0 81.4%
if 3.0999999999999999e-79 < x < 2.9e6Initial program 99.9%
*-commutative99.9%
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 66.7%
distribute-lft-in66.7%
*-rgt-identity66.7%
associate-*r/66.7%
*-rgt-identity66.7%
Simplified66.7%
Taylor expanded in x around 0 53.0%
associate-/r/53.1%
Applied egg-rr53.1%
if 2.9e6 < x < 4.2e101Initial program 100.0%
Taylor expanded in y around inf 78.9%
+-commutative78.9%
Simplified78.9%
Taylor expanded in x around inf 77.2%
Final simplification77.5%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(/ x y)
(if (<= x 1.45e-6)
(* x (+ 1.0 (/ x y)))
(if (<= x 4.3e+101) (/ x (+ x 1.0)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 1.45e-6) {
tmp = x * (1.0 + (x / y));
} else if (x <= 4.3e+101) {
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 / y
else if (x <= 1.45d-6) then
tmp = x * (1.0d0 + (x / y))
else if (x <= 4.3d+101) 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 / y;
} else if (x <= 1.45e-6) {
tmp = x * (1.0 + (x / y));
} else if (x <= 4.3e+101) {
tmp = x / (x + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 1.45e-6: tmp = x * (1.0 + (x / y)) elif x <= 4.3e+101: tmp = x / (x + 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 <= 1.45e-6) tmp = Float64(x * Float64(1.0 + Float64(x / y))); elseif (x <= 4.3e+101) 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 / y; elseif (x <= 1.45e-6) tmp = x * (1.0 + (x / y)); elseif (x <= 4.3e+101) tmp = x / (x + 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, 1.45e-6], N[(x * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.3e+101], 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}{y}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-6}:\\
\;\;\;\;x \cdot \left(1 + \frac{x}{y}\right)\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{+101}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 4.3000000000000001e101 < x Initial program 73.4%
Taylor expanded in x around inf 79.0%
if -1 < x < 1.4500000000000001e-6Initial program 99.9%
*-commutative99.9%
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 x around 0 98.2%
associate-/r/98.4%
/-rgt-identity98.4%
+-commutative98.4%
Applied egg-rr98.4%
if 1.4500000000000001e-6 < x < 4.3000000000000001e101Initial program 99.9%
Taylor expanded in y around inf 69.9%
+-commutative69.9%
Simplified69.9%
Final simplification87.9%
(FPCore (x y)
:precision binary64
(if (<= x -4.5e-8)
(/ x (+ y (/ y x)))
(if (<= x 8e-7)
(* x (+ 1.0 (/ x y)))
(if (<= x 8e+101) (/ x (+ x 1.0)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -4.5e-8) {
tmp = x / (y + (y / x));
} else if (x <= 8e-7) {
tmp = x * (1.0 + (x / y));
} else if (x <= 8e+101) {
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 <= (-4.5d-8)) then
tmp = x / (y + (y / x))
else if (x <= 8d-7) then
tmp = x * (1.0d0 + (x / y))
else if (x <= 8d+101) 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 <= -4.5e-8) {
tmp = x / (y + (y / x));
} else if (x <= 8e-7) {
tmp = x * (1.0 + (x / y));
} else if (x <= 8e+101) {
tmp = x / (x + 1.0);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4.5e-8: tmp = x / (y + (y / x)) elif x <= 8e-7: tmp = x * (1.0 + (x / y)) elif x <= 8e+101: tmp = x / (x + 1.0) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -4.5e-8) tmp = Float64(x / Float64(y + Float64(y / x))); elseif (x <= 8e-7) tmp = Float64(x * Float64(1.0 + Float64(x / y))); elseif (x <= 8e+101) 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 <= -4.5e-8) tmp = x / (y + (y / x)); elseif (x <= 8e-7) tmp = x * (1.0 + (x / y)); elseif (x <= 8e+101) tmp = x / (x + 1.0); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4.5e-8], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8e-7], N[(x * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8e+101], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-7}:\\
\;\;\;\;x \cdot \left(1 + \frac{x}{y}\right)\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+101}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -4.49999999999999993e-8Initial program 73.9%
*-commutative73.9%
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 0 76.4%
distribute-lft-in76.4%
*-rgt-identity76.4%
associate-*r/76.4%
*-rgt-identity76.4%
Simplified76.4%
if -4.49999999999999993e-8 < x < 7.9999999999999996e-7Initial program 99.9%
*-commutative99.9%
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 x around 0 99.0%
associate-/r/99.3%
/-rgt-identity99.3%
+-commutative99.3%
Applied egg-rr99.3%
if 7.9999999999999996e-7 < x < 7.9999999999999998e101Initial program 99.9%
Taylor expanded in y around inf 69.9%
+-commutative69.9%
Simplified69.9%
if 7.9999999999999998e101 < x Initial program 74.0%
Taylor expanded in x around inf 83.5%
Final simplification88.5%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ 1.0 (/ x y)))) (if (or (<= x -1.0) (not (<= x 1.0))) t_0 (* x t_0))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
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 = 1.0d0 + (x / y)
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 = 1.0 + (x / y);
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 = 1.0 + (x / y) 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(1.0 + Float64(x / y)) 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 = 1.0 + (x / y); 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[(1.0 + N[(x / y), $MachinePrecision]), $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 := 1 + \frac{x}{y}\\
\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 77.9%
*-commutative77.9%
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 x around inf 97.4%
if -1 < x < 1Initial program 99.9%
*-commutative99.9%
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 x around 0 97.3%
associate-/r/97.5%
/-rgt-identity97.5%
+-commutative97.5%
Applied egg-rr97.5%
Final simplification97.5%
(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 89.0%
*-commutative89.0%
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 2900000.0) x (if (<= x 1.5e+102) 1.0 (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= 2900000.0) {
tmp = x;
} else if (x <= 1.5e+102) {
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 <= 2900000.0d0) then
tmp = x
else if (x <= 1.5d+102) 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 <= 2900000.0) {
tmp = x;
} else if (x <= 1.5e+102) {
tmp = 1.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= 2900000.0: tmp = x elif x <= 1.5e+102: 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 <= 2900000.0) tmp = x; elseif (x <= 1.5e+102) 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 <= 2900000.0) tmp = x; elseif (x <= 1.5e+102) 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, 2900000.0], x, If[LessEqual[x, 1.5e+102], 1.0, N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 2900000:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+102}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 1.4999999999999999e102 < x Initial program 73.4%
Taylor expanded in x around inf 79.0%
if -1 < x < 2.9e6Initial program 99.9%
Taylor expanded in x around 0 73.2%
if 2.9e6 < x < 1.4999999999999999e102Initial program 100.0%
Taylor expanded in y around inf 78.9%
+-commutative78.9%
Simplified78.9%
Taylor expanded in x around inf 77.2%
Final simplification75.8%
(FPCore (x y) :precision binary64 (if (<= x -78000000000.0) 1.0 (if (<= x 2900000.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -78000000000.0) {
tmp = 1.0;
} else if (x <= 2900000.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-78000000000.0d0)) then
tmp = 1.0d0
else if (x <= 2900000.0d0) then
tmp = x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -78000000000.0) {
tmp = 1.0;
} else if (x <= 2900000.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -78000000000.0: tmp = 1.0 elif x <= 2900000.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -78000000000.0) tmp = 1.0; elseif (x <= 2900000.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -78000000000.0) tmp = 1.0; elseif (x <= 2900000.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -78000000000.0], 1.0, If[LessEqual[x, 2900000.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -78000000000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2900000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -7.8e10 or 2.9e6 < x Initial program 77.6%
Taylor expanded in y around inf 29.5%
+-commutative29.5%
Simplified29.5%
Taylor expanded in x around inf 29.0%
if -7.8e10 < x < 2.9e6Initial program 99.3%
Taylor expanded in x around 0 71.6%
Final simplification51.5%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 89.0%
Taylor expanded in y around inf 52.2%
+-commutative52.2%
Simplified52.2%
Taylor expanded in x around inf 15.7%
Final simplification15.7%
(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 2023334
(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)))