
(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 13 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 89.4%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= x -1.0)
(+ 1.0 (/ x y))
(if (<= x 1.0)
(+ x (* (* x x) (+ -1.0 (/ 1.0 y))))
(+ 1.0 (/ (+ x -1.0) y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0 + (x / y);
} else if (x <= 1.0) {
tmp = x + ((x * x) * (-1.0 + (1.0 / y)));
} else {
tmp = 1.0 + ((x + -1.0) / 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 = 1.0d0 + (x / y)
else if (x <= 1.0d0) then
tmp = x + ((x * x) * ((-1.0d0) + (1.0d0 / y)))
else
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0 + (x / y);
} else if (x <= 1.0) {
tmp = x + ((x * x) * (-1.0 + (1.0 / y)));
} else {
tmp = 1.0 + ((x + -1.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 + (x / y) elif x <= 1.0: tmp = x + ((x * x) * (-1.0 + (1.0 / y))) else: tmp = 1.0 + ((x + -1.0) / y) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(1.0 + Float64(x / y)); elseif (x <= 1.0) tmp = Float64(x + Float64(Float64(x * x) * Float64(-1.0 + Float64(1.0 / y)))); else tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = 1.0 + (x / y); elseif (x <= 1.0) tmp = x + ((x * x) * (-1.0 + (1.0 / y))); else tmp = 1.0 + ((x + -1.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(x + N[(N[(x * x), $MachinePrecision] * N[(-1.0 + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x + \left(x \cdot x\right) \cdot \left(-1 + \frac{1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\end{array}
\end{array}
if x < -1Initial program 78.5%
clear-num78.5%
associate-/r/78.4%
fma-def78.4%
Applied egg-rr78.4%
Taylor expanded in x around inf 99.4%
+-commutative99.4%
associate-+r-99.4%
+-commutative99.4%
associate-+l-99.4%
div-sub99.4%
Simplified99.4%
Taylor expanded in x around inf 99.4%
neg-mul-199.4%
distribute-neg-frac99.4%
Simplified99.4%
if -1 < x < 1Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 93.3%
unpow293.3%
sub-neg93.3%
metadata-eval93.3%
Simplified93.3%
if 1 < x Initial program 80.2%
clear-num80.1%
associate-/r/80.2%
fma-def80.2%
Applied egg-rr80.2%
Taylor expanded in x around inf 98.9%
+-commutative98.9%
associate-+r-98.9%
+-commutative98.9%
associate-+l-98.9%
div-sub98.9%
Simplified98.9%
Final simplification96.3%
(FPCore (x y)
:precision binary64
(if (<= x -1.45e+75)
(/ x y)
(if (<= x -1.0)
1.0
(if (<= x 1.4e-96) x (if (<= x 1.0) (* x (/ x y)) (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -1.45e+75) {
tmp = x / y;
} else if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 1.4e-96) {
tmp = x;
} else if (x <= 1.0) {
tmp = x * (x / y);
} 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.45d+75)) then
tmp = x / y
else if (x <= (-1.0d0)) then
tmp = 1.0d0
else if (x <= 1.4d-96) then
tmp = x
else if (x <= 1.0d0) then
tmp = x * (x / y)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.45e+75) {
tmp = x / y;
} else if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 1.4e-96) {
tmp = x;
} else if (x <= 1.0) {
tmp = x * (x / y);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.45e+75: tmp = x / y elif x <= -1.0: tmp = 1.0 elif x <= 1.4e-96: tmp = x elif x <= 1.0: tmp = x * (x / y) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.45e+75) tmp = Float64(x / y); elseif (x <= -1.0) tmp = 1.0; elseif (x <= 1.4e-96) tmp = x; elseif (x <= 1.0) tmp = Float64(x * Float64(x / y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.45e+75) tmp = x / y; elseif (x <= -1.0) tmp = 1.0; elseif (x <= 1.4e-96) tmp = x; elseif (x <= 1.0) tmp = x * (x / y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.45e+75], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 1.4e-96], x, If[LessEqual[x, 1.0], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{+75}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-96}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.4499999999999999e75 or 1 < x Initial program 77.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 74.5%
if -1.4499999999999999e75 < x < -1Initial program 100.0%
clear-num100.0%
associate-/r/99.8%
fma-def99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 95.5%
+-commutative95.5%
associate-+r-95.5%
+-commutative95.5%
associate-+l-95.5%
div-sub95.5%
Simplified95.5%
Taylor expanded in y around inf 85.0%
if -1 < x < 1.40000000000000008e-96Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 81.9%
if 1.40000000000000008e-96 < x < 1Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 70.1%
Taylor expanded in x around 0 66.8%
associate-/r/66.7%
Applied egg-rr66.7%
Final simplification77.1%
(FPCore (x y)
:precision binary64
(if (<= x -1.05e+75)
(/ x y)
(if (<= x -1.0)
1.0
(if (<= x 1.35e-95)
(- x (* x x))
(if (<= x 1.0) (* x (/ x y)) (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -1.05e+75) {
tmp = x / y;
} else if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 1.35e-95) {
tmp = x - (x * x);
} else if (x <= 1.0) {
tmp = x * (x / y);
} 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.05d+75)) then
tmp = x / y
else if (x <= (-1.0d0)) then
tmp = 1.0d0
else if (x <= 1.35d-95) then
tmp = x - (x * x)
else if (x <= 1.0d0) then
tmp = x * (x / y)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.05e+75) {
tmp = x / y;
} else if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 1.35e-95) {
tmp = x - (x * x);
} else if (x <= 1.0) {
tmp = x * (x / y);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.05e+75: tmp = x / y elif x <= -1.0: tmp = 1.0 elif x <= 1.35e-95: tmp = x - (x * x) elif x <= 1.0: tmp = x * (x / y) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.05e+75) tmp = Float64(x / y); elseif (x <= -1.0) tmp = 1.0; elseif (x <= 1.35e-95) tmp = Float64(x - Float64(x * x)); elseif (x <= 1.0) tmp = Float64(x * Float64(x / y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.05e+75) tmp = x / y; elseif (x <= -1.0) tmp = 1.0; elseif (x <= 1.35e-95) tmp = x - (x * x); elseif (x <= 1.0) tmp = x * (x / y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.05e+75], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 1.35e-95], N[(x - N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+75}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-95}:\\
\;\;\;\;x - x \cdot x\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.04999999999999999e75 or 1 < x Initial program 77.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 74.5%
if -1.04999999999999999e75 < x < -1Initial program 100.0%
clear-num100.0%
associate-/r/99.8%
fma-def99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 95.5%
+-commutative95.5%
associate-+r-95.5%
+-commutative95.5%
associate-+l-95.5%
div-sub95.5%
Simplified95.5%
Taylor expanded in y around inf 85.0%
if -1 < x < 1.35e-95Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 82.7%
Taylor expanded in x around 0 81.9%
mul-1-neg81.9%
unsub-neg81.9%
unpow281.9%
Simplified81.9%
if 1.35e-95 < x < 1Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 70.1%
Taylor expanded in x around 0 66.8%
associate-/r/66.7%
Applied egg-rr66.7%
Final simplification77.1%
(FPCore (x y)
:precision binary64
(if (<= x -2.85e+26)
(+ 1.0 (/ x y))
(if (<= x 2e-95)
(/ x (+ x 1.0))
(if (<= x 1.0) (/ x (/ y x)) (+ 1.0 (/ (+ x -1.0) y))))))
double code(double x, double y) {
double tmp;
if (x <= -2.85e+26) {
tmp = 1.0 + (x / y);
} else if (x <= 2e-95) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x / (y / x);
} else {
tmp = 1.0 + ((x + -1.0) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-2.85d+26)) then
tmp = 1.0d0 + (x / y)
else if (x <= 2d-95) then
tmp = x / (x + 1.0d0)
else if (x <= 1.0d0) then
tmp = x / (y / x)
else
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.85e+26) {
tmp = 1.0 + (x / y);
} else if (x <= 2e-95) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x / (y / x);
} else {
tmp = 1.0 + ((x + -1.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.85e+26: tmp = 1.0 + (x / y) elif x <= 2e-95: tmp = x / (x + 1.0) elif x <= 1.0: tmp = x / (y / x) else: tmp = 1.0 + ((x + -1.0) / y) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.85e+26) tmp = Float64(1.0 + Float64(x / y)); elseif (x <= 2e-95) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 1.0) tmp = Float64(x / Float64(y / x)); else tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.85e+26) tmp = 1.0 + (x / y); elseif (x <= 2e-95) tmp = x / (x + 1.0); elseif (x <= 1.0) tmp = x / (y / x); else tmp = 1.0 + ((x + -1.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.85e+26], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2e-95], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.85 \cdot 10^{+26}:\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-95}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\end{array}
\end{array}
if x < -2.8500000000000002e26Initial program 77.1%
clear-num77.0%
associate-/r/77.0%
fma-def77.0%
Applied egg-rr77.0%
Taylor expanded in x around inf 100.0%
+-commutative100.0%
associate-+r-100.0%
+-commutative100.0%
associate-+l-100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
neg-mul-1100.0%
distribute-neg-frac100.0%
Simplified100.0%
if -2.8500000000000002e26 < x < 1.99999999999999998e-95Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 83.4%
if 1.99999999999999998e-95 < x < 1Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 70.1%
Taylor expanded in x around 0 66.8%
if 1 < x Initial program 80.2%
clear-num80.1%
associate-/r/80.2%
fma-def80.2%
Applied egg-rr80.2%
Taylor expanded in x around inf 98.9%
+-commutative98.9%
associate-+r-98.9%
+-commutative98.9%
associate-+l-98.9%
div-sub98.9%
Simplified98.9%
Final simplification89.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -2.85e+26)
t_0
(if (<= x 2.5e-97)
(/ x (+ x 1.0))
(if (<= x 6400000.0) (/ x (+ y (/ y x))) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -2.85e+26) {
tmp = t_0;
} else if (x <= 2.5e-97) {
tmp = x / (x + 1.0);
} else if (x <= 6400000.0) {
tmp = x / (y + (y / 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 = 1.0d0 + (x / y)
if (x <= (-2.85d+26)) then
tmp = t_0
else if (x <= 2.5d-97) then
tmp = x / (x + 1.0d0)
else if (x <= 6400000.0d0) then
tmp = x / (y + (y / x))
else
tmp = 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 <= -2.85e+26) {
tmp = t_0;
} else if (x <= 2.5e-97) {
tmp = x / (x + 1.0);
} else if (x <= 6400000.0) {
tmp = x / (y + (y / x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -2.85e+26: tmp = t_0 elif x <= 2.5e-97: tmp = x / (x + 1.0) elif x <= 6400000.0: tmp = x / (y + (y / x)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -2.85e+26) tmp = t_0; elseif (x <= 2.5e-97) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 6400000.0) tmp = Float64(x / Float64(y + Float64(y / x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (x <= -2.85e+26) tmp = t_0; elseif (x <= 2.5e-97) tmp = x / (x + 1.0); elseif (x <= 6400000.0) tmp = x / (y + (y / x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.85e+26], t$95$0, If[LessEqual[x, 2.5e-97], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6400000.0], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -2.85 \cdot 10^{+26}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-97}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 6400000:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.8500000000000002e26 or 6.4e6 < x Initial program 78.6%
clear-num78.5%
associate-/r/78.5%
fma-def78.5%
Applied egg-rr78.5%
Taylor expanded in x around inf 99.9%
+-commutative99.9%
associate-+r-99.9%
+-commutative99.9%
associate-+l-99.9%
div-sub99.9%
Simplified99.9%
Taylor expanded in x around inf 99.9%
neg-mul-199.9%
distribute-neg-frac99.9%
Simplified99.9%
if -2.8500000000000002e26 < x < 2.4999999999999998e-97Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 83.4%
if 2.4999999999999998e-97 < x < 6.4e6Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 71.3%
Taylor expanded in x around 0 71.3%
Final simplification90.3%
(FPCore (x y) :precision binary64 (if (<= x -1.8e+77) (/ x y) (if (<= x 7.2e-96) (/ x (+ x 1.0)) (if (<= x 1.0) (* x (/ x y)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.8e+77) {
tmp = x / y;
} else if (x <= 7.2e-96) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x * (x / y);
} 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.8d+77)) then
tmp = x / y
else if (x <= 7.2d-96) then
tmp = x / (x + 1.0d0)
else if (x <= 1.0d0) then
tmp = x * (x / y)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.8e+77) {
tmp = x / y;
} else if (x <= 7.2e-96) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x * (x / y);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.8e+77: tmp = x / y elif x <= 7.2e-96: tmp = x / (x + 1.0) elif x <= 1.0: tmp = x * (x / y) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.8e+77) tmp = Float64(x / y); elseif (x <= 7.2e-96) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 1.0) tmp = Float64(x * Float64(x / y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.8e+77) tmp = x / y; elseif (x <= 7.2e-96) tmp = x / (x + 1.0); elseif (x <= 1.0) tmp = x * (x / y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.8e+77], N[(x / y), $MachinePrecision], If[LessEqual[x, 7.2e-96], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{+77}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-96}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.7999999999999999e77 or 1 < x Initial program 77.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 74.5%
if -1.7999999999999999e77 < x < 7.20000000000000016e-96Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 83.3%
if 7.20000000000000016e-96 < x < 1Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 70.1%
Taylor expanded in x around 0 66.8%
associate-/r/66.7%
Applied egg-rr66.7%
Final simplification77.6%
(FPCore (x y) :precision binary64 (if (<= x -1.35e+76) (/ x y) (if (<= x 2.3e-95) (/ x (+ x 1.0)) (if (<= x 1.0) (/ x (/ y x)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.35e+76) {
tmp = x / y;
} else if (x <= 2.3e-95) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x / (y / 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.35d+76)) then
tmp = x / y
else if (x <= 2.3d-95) then
tmp = x / (x + 1.0d0)
else if (x <= 1.0d0) then
tmp = x / (y / x)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.35e+76) {
tmp = x / y;
} else if (x <= 2.3e-95) {
tmp = x / (x + 1.0);
} else if (x <= 1.0) {
tmp = x / (y / x);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.35e+76: tmp = x / y elif x <= 2.3e-95: tmp = x / (x + 1.0) elif x <= 1.0: tmp = x / (y / x) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.35e+76) tmp = Float64(x / y); elseif (x <= 2.3e-95) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 1.0) tmp = Float64(x / Float64(y / x)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.35e+76) tmp = x / y; elseif (x <= 2.3e-95) tmp = x / (x + 1.0); elseif (x <= 1.0) tmp = x / (y / x); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.35e+76], N[(x / y), $MachinePrecision], If[LessEqual[x, 2.3e-95], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+76}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-95}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.34999999999999995e76 or 1 < x Initial program 77.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 74.5%
if -1.34999999999999995e76 < x < 2.29999999999999999e-95Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 83.3%
if 2.29999999999999999e-95 < x < 1Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 70.1%
Taylor expanded in x around 0 66.8%
Final simplification77.6%
(FPCore (x y)
:precision binary64
(if (<= x -6.5e+77)
(/ x y)
(if (<= x 1.9e-96)
(/ x (+ x 1.0))
(if (<= x 1.3) (/ x (/ y x)) (/ (+ x -1.0) y)))))
double code(double x, double y) {
double tmp;
if (x <= -6.5e+77) {
tmp = x / y;
} else if (x <= 1.9e-96) {
tmp = x / (x + 1.0);
} else if (x <= 1.3) {
tmp = x / (y / x);
} else {
tmp = (x + -1.0) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-6.5d+77)) then
tmp = x / y
else if (x <= 1.9d-96) then
tmp = x / (x + 1.0d0)
else if (x <= 1.3d0) then
tmp = x / (y / x)
else
tmp = (x + (-1.0d0)) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -6.5e+77) {
tmp = x / y;
} else if (x <= 1.9e-96) {
tmp = x / (x + 1.0);
} else if (x <= 1.3) {
tmp = x / (y / x);
} else {
tmp = (x + -1.0) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -6.5e+77: tmp = x / y elif x <= 1.9e-96: tmp = x / (x + 1.0) elif x <= 1.3: tmp = x / (y / x) else: tmp = (x + -1.0) / y return tmp
function code(x, y) tmp = 0.0 if (x <= -6.5e+77) tmp = Float64(x / y); elseif (x <= 1.9e-96) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 1.3) tmp = Float64(x / Float64(y / x)); else tmp = Float64(Float64(x + -1.0) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -6.5e+77) tmp = x / y; elseif (x <= 1.9e-96) tmp = x / (x + 1.0); elseif (x <= 1.3) tmp = x / (y / x); else tmp = (x + -1.0) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -6.5e+77], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.9e-96], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.3], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{+77}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-96}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 1.3:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + -1}{y}\\
\end{array}
\end{array}
if x < -6.5e77Initial program 75.1%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 77.1%
if -6.5e77 < x < 1.9e-96Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 83.3%
if 1.9e-96 < x < 1.30000000000000004Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 70.1%
Taylor expanded in x around 0 66.8%
if 1.30000000000000004 < x Initial program 80.2%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 98.9%
Taylor expanded in y around 0 72.5%
Final simplification77.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -2.85e+26)
t_0
(if (<= x 2.3e-95)
(/ x (+ x 1.0))
(if (<= x 1.6e-12) (/ x (/ y x)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -2.85e+26) {
tmp = t_0;
} else if (x <= 2.3e-95) {
tmp = x / (x + 1.0);
} else if (x <= 1.6e-12) {
tmp = x / (y / 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 = 1.0d0 + (x / y)
if (x <= (-2.85d+26)) then
tmp = t_0
else if (x <= 2.3d-95) then
tmp = x / (x + 1.0d0)
else if (x <= 1.6d-12) then
tmp = x / (y / x)
else
tmp = 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 <= -2.85e+26) {
tmp = t_0;
} else if (x <= 2.3e-95) {
tmp = x / (x + 1.0);
} else if (x <= 1.6e-12) {
tmp = x / (y / x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -2.85e+26: tmp = t_0 elif x <= 2.3e-95: tmp = x / (x + 1.0) elif x <= 1.6e-12: tmp = x / (y / x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -2.85e+26) tmp = t_0; elseif (x <= 2.3e-95) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 1.6e-12) tmp = Float64(x / Float64(y / x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (x <= -2.85e+26) tmp = t_0; elseif (x <= 2.3e-95) tmp = x / (x + 1.0); elseif (x <= 1.6e-12) tmp = x / (y / x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.85e+26], t$95$0, If[LessEqual[x, 2.3e-95], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e-12], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -2.85 \cdot 10^{+26}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-95}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.8500000000000002e26 or 1.6e-12 < x Initial program 79.1%
clear-num79.0%
associate-/r/79.0%
fma-def79.0%
Applied egg-rr79.0%
Taylor expanded in x around inf 98.0%
+-commutative98.0%
associate-+r-98.0%
+-commutative98.0%
associate-+l-98.0%
div-sub98.0%
Simplified98.0%
Taylor expanded in x around inf 98.0%
neg-mul-198.0%
distribute-neg-frac98.0%
Simplified98.0%
if -2.8500000000000002e26 < x < 2.29999999999999999e-95Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 83.4%
if 2.29999999999999999e-95 < x < 1.6e-12Initial program 99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 71.9%
Taylor expanded in x around 0 71.9%
Final simplification89.8%
(FPCore (x y) :precision binary64 (if (<= x -2.2e+78) (/ x y) (if (<= x -1.0) 1.0 (if (<= x 0.45) x (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -2.2e+78) {
tmp = x / y;
} else if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 0.45) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-2.2d+78)) then
tmp = x / y
else if (x <= (-1.0d0)) then
tmp = 1.0d0
else if (x <= 0.45d0) then
tmp = x
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.2e+78) {
tmp = x / y;
} else if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 0.45) {
tmp = x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.2e+78: tmp = x / y elif x <= -1.0: tmp = 1.0 elif x <= 0.45: tmp = x else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -2.2e+78) tmp = Float64(x / y); elseif (x <= -1.0) tmp = 1.0; elseif (x <= 0.45) tmp = x; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.2e+78) tmp = x / y; elseif (x <= -1.0) tmp = 1.0; elseif (x <= 0.45) tmp = x; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.2e+78], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 0.45], x, N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{+78}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 0.45:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -2.20000000000000014e78 or 0.450000000000000011 < x Initial program 78.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 74.1%
if -2.20000000000000014e78 < x < -1Initial program 100.0%
clear-num100.0%
associate-/r/99.8%
fma-def99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 95.5%
+-commutative95.5%
associate-+r-95.5%
+-commutative95.5%
associate-+l-95.5%
div-sub95.5%
Simplified95.5%
Taylor expanded in y around inf 85.0%
if -1 < x < 0.450000000000000011Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 72.7%
Final simplification73.8%
(FPCore (x y) :precision binary64 (if (<= x -1.0) 1.0 (if (<= x 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 1.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 <= (-1.0d0)) then
tmp = 1.0d0
else if (x <= 1.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 <= -1.0) {
tmp = 1.0;
} else if (x <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 elif x <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = 1.0; elseif (x <= 1.0) 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 <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 79.4%
clear-num79.3%
associate-/r/79.3%
fma-def79.3%
Applied egg-rr79.3%
Taylor expanded in x around inf 99.1%
+-commutative99.1%
associate-+r-99.1%
+-commutative99.1%
associate-+l-99.1%
div-sub99.1%
Simplified99.1%
Taylor expanded in y around inf 30.4%
if -1 < x < 1Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 72.1%
Final simplification50.8%
(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.4%
clear-num89.3%
associate-/r/89.4%
fma-def89.4%
Applied egg-rr89.4%
Taylor expanded in x around inf 51.9%
+-commutative51.9%
associate-+r-51.9%
+-commutative51.9%
associate-+l-51.9%
div-sub51.9%
Simplified51.9%
Taylor expanded in y around inf 17.2%
Final simplification17.2%
(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 2023290
(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)))