
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\end{array}
(FPCore (x y) :precision binary64 (if (or (<= y -12500000000.0) (not (<= y 200000.0))) (+ (- x (/ (+ x -1.0) y)) (/ (+ x -1.0) (pow y 2.0))) (+ 1.0 (/ (* y (+ x -1.0)) (+ y 1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -12500000000.0) || !(y <= 200000.0)) {
tmp = (x - ((x + -1.0) / y)) + ((x + -1.0) / pow(y, 2.0));
} else {
tmp = 1.0 + ((y * (x + -1.0)) / (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 ((y <= (-12500000000.0d0)) .or. (.not. (y <= 200000.0d0))) then
tmp = (x - ((x + (-1.0d0)) / y)) + ((x + (-1.0d0)) / (y ** 2.0d0))
else
tmp = 1.0d0 + ((y * (x + (-1.0d0))) / (y + 1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -12500000000.0) || !(y <= 200000.0)) {
tmp = (x - ((x + -1.0) / y)) + ((x + -1.0) / Math.pow(y, 2.0));
} else {
tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -12500000000.0) or not (y <= 200000.0): tmp = (x - ((x + -1.0) / y)) + ((x + -1.0) / math.pow(y, 2.0)) else: tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -12500000000.0) || !(y <= 200000.0)) tmp = Float64(Float64(x - Float64(Float64(x + -1.0) / y)) + Float64(Float64(x + -1.0) / (y ^ 2.0))); else tmp = Float64(1.0 + Float64(Float64(y * Float64(x + -1.0)) / Float64(y + 1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -12500000000.0) || ~((y <= 200000.0))) tmp = (x - ((x + -1.0) / y)) + ((x + -1.0) / (y ^ 2.0)); else tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -12500000000.0], N[Not[LessEqual[y, 200000.0]], $MachinePrecision]], N[(N[(x - N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -12500000000 \lor \neg \left(y \leq 200000\right):\\
\;\;\;\;\left(x - \frac{x + -1}{y}\right) + \frac{x + -1}{{y}^{2}}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{y \cdot \left(x + -1\right)}{y + 1}\\
\end{array}
\end{array}
if y < -1.25e10 or 2e5 < y Initial program 27.2%
associate-*l/55.3%
+-commutative55.3%
Simplified55.3%
Taylor expanded in y around -inf 100.0%
associate-+r+100.0%
associate--l+100.0%
mul-1-neg100.0%
unsub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
div-sub100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
if -1.25e10 < y < 2e5Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= y -145000000.0)
(- x (/ (+ x -1.0) y))
(if (<= y 420000000000.0)
(+ 1.0 (* y (/ (+ x -1.0) (+ y 1.0))))
(- x (/ -1.0 y)))))
double code(double x, double y) {
double tmp;
if (y <= -145000000.0) {
tmp = x - ((x + -1.0) / y);
} else if (y <= 420000000000.0) {
tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
} 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 (y <= (-145000000.0d0)) then
tmp = x - ((x + (-1.0d0)) / y)
else if (y <= 420000000000.0d0) then
tmp = 1.0d0 + (y * ((x + (-1.0d0)) / (y + 1.0d0)))
else
tmp = x - ((-1.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -145000000.0) {
tmp = x - ((x + -1.0) / y);
} else if (y <= 420000000000.0) {
tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
} else {
tmp = x - (-1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -145000000.0: tmp = x - ((x + -1.0) / y) elif y <= 420000000000.0: tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0))) else: tmp = x - (-1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -145000000.0) tmp = Float64(x - Float64(Float64(x + -1.0) / y)); elseif (y <= 420000000000.0) tmp = Float64(1.0 + Float64(y * Float64(Float64(x + -1.0) / Float64(y + 1.0)))); else tmp = Float64(x - Float64(-1.0 / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -145000000.0) tmp = x - ((x + -1.0) / y); elseif (y <= 420000000000.0) tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0))); else tmp = x - (-1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -145000000.0], N[(x - N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 420000000000.0], N[(1.0 + N[(y * N[(N[(x + -1.0), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -145000000:\\
\;\;\;\;x - \frac{x + -1}{y}\\
\mathbf{elif}\;y \leq 420000000000:\\
\;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{-1}{y}\\
\end{array}
\end{array}
if y < -1.45e8Initial program 31.9%
associate-*l/52.1%
+-commutative52.1%
Simplified52.1%
Taylor expanded in y around inf 99.5%
associate--l+99.5%
div-sub99.5%
sub-neg99.5%
+-commutative99.5%
metadata-eval99.5%
distribute-neg-in99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
sub-neg99.5%
unsub-neg99.5%
sub-neg99.5%
metadata-eval99.5%
Simplified99.5%
if -1.45e8 < y < 4.2e11Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
if 4.2e11 < y Initial program 24.1%
associate-*l/58.8%
+-commutative58.8%
Simplified58.8%
Taylor expanded in y around inf 99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
+-commutative99.8%
metadata-eval99.8%
distribute-neg-in99.8%
distribute-neg-frac99.8%
metadata-eval99.8%
sub-neg99.8%
unsub-neg99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (<= y -12500000000.0)
(- x (/ (+ x -1.0) y))
(if (<= y 23500000000.0)
(+ 1.0 (/ (* y (+ x -1.0)) (+ y 1.0)))
(- x (/ -1.0 y)))))
double code(double x, double y) {
double tmp;
if (y <= -12500000000.0) {
tmp = x - ((x + -1.0) / y);
} else if (y <= 23500000000.0) {
tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0));
} 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 (y <= (-12500000000.0d0)) then
tmp = x - ((x + (-1.0d0)) / y)
else if (y <= 23500000000.0d0) then
tmp = 1.0d0 + ((y * (x + (-1.0d0))) / (y + 1.0d0))
else
tmp = x - ((-1.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -12500000000.0) {
tmp = x - ((x + -1.0) / y);
} else if (y <= 23500000000.0) {
tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0));
} else {
tmp = x - (-1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -12500000000.0: tmp = x - ((x + -1.0) / y) elif y <= 23500000000.0: tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)) else: tmp = x - (-1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -12500000000.0) tmp = Float64(x - Float64(Float64(x + -1.0) / y)); elseif (y <= 23500000000.0) tmp = Float64(1.0 + Float64(Float64(y * Float64(x + -1.0)) / Float64(y + 1.0))); else tmp = Float64(x - Float64(-1.0 / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -12500000000.0) tmp = x - ((x + -1.0) / y); elseif (y <= 23500000000.0) tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)); else tmp = x - (-1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -12500000000.0], N[(x - N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 23500000000.0], N[(1.0 + N[(N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -12500000000:\\
\;\;\;\;x - \frac{x + -1}{y}\\
\mathbf{elif}\;y \leq 23500000000:\\
\;\;\;\;1 + \frac{y \cdot \left(x + -1\right)}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{-1}{y}\\
\end{array}
\end{array}
if y < -1.25e10Initial program 30.8%
associate-*l/51.3%
+-commutative51.3%
Simplified51.3%
Taylor expanded in y around inf 99.5%
associate--l+99.5%
div-sub99.5%
sub-neg99.5%
+-commutative99.5%
metadata-eval99.5%
distribute-neg-in99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
sub-neg99.5%
unsub-neg99.5%
sub-neg99.5%
metadata-eval99.5%
Simplified99.5%
if -1.25e10 < y < 2.35e10Initial program 100.0%
if 2.35e10 < y Initial program 24.1%
associate-*l/58.8%
+-commutative58.8%
Simplified58.8%
Taylor expanded in y around inf 99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
+-commutative99.8%
metadata-eval99.8%
distribute-neg-in99.8%
distribute-neg-frac99.8%
metadata-eval99.8%
sub-neg99.8%
unsub-neg99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= y -2.6e+39) x (if (<= y -1.0) (/ 1.0 y) (if (<= y 22.5) (+ 1.0 (* y x)) x))))
double code(double x, double y) {
double tmp;
if (y <= -2.6e+39) {
tmp = x;
} else if (y <= -1.0) {
tmp = 1.0 / y;
} else if (y <= 22.5) {
tmp = 1.0 + (y * x);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2.6d+39)) then
tmp = x
else if (y <= (-1.0d0)) then
tmp = 1.0d0 / y
else if (y <= 22.5d0) then
tmp = 1.0d0 + (y * x)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.6e+39) {
tmp = x;
} else if (y <= -1.0) {
tmp = 1.0 / y;
} else if (y <= 22.5) {
tmp = 1.0 + (y * x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.6e+39: tmp = x elif y <= -1.0: tmp = 1.0 / y elif y <= 22.5: tmp = 1.0 + (y * x) else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -2.6e+39) tmp = x; elseif (y <= -1.0) tmp = Float64(1.0 / y); elseif (y <= 22.5) tmp = Float64(1.0 + Float64(y * x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.6e+39) tmp = x; elseif (y <= -1.0) tmp = 1.0 / y; elseif (y <= 22.5) tmp = 1.0 + (y * x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.6e+39], x, If[LessEqual[y, -1.0], N[(1.0 / y), $MachinePrecision], If[LessEqual[y, 22.5], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{+39}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -1:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{elif}\;y \leq 22.5:\\
\;\;\;\;1 + y \cdot x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -2.6e39 or 22.5 < y Initial program 28.3%
associate-*l/57.9%
+-commutative57.9%
Simplified57.9%
Taylor expanded in y around inf 79.3%
if -2.6e39 < y < -1Initial program 28.8%
associate-*l/41.3%
+-commutative41.3%
Simplified41.3%
Taylor expanded in x around 0 8.7%
Taylor expanded in y around inf 63.0%
if -1 < y < 22.5Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 98.1%
neg-mul-198.1%
distribute-neg-frac98.1%
Simplified98.1%
Taylor expanded in y around 0 96.6%
associate-*r*96.6%
neg-mul-196.6%
Simplified96.6%
cancel-sign-sub96.6%
+-commutative96.6%
Applied egg-rr96.6%
Final simplification87.1%
(FPCore (x y) :precision binary64 (if (<= y -12000.0) (- x (/ (+ x -1.0) y)) (if (<= y 225000000.0) (- 1.0 (* y (/ x (- -1.0 y)))) (- x (/ -1.0 y)))))
double code(double x, double y) {
double tmp;
if (y <= -12000.0) {
tmp = x - ((x + -1.0) / y);
} else if (y <= 225000000.0) {
tmp = 1.0 - (y * (x / (-1.0 - y)));
} 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 (y <= (-12000.0d0)) then
tmp = x - ((x + (-1.0d0)) / y)
else if (y <= 225000000.0d0) then
tmp = 1.0d0 - (y * (x / ((-1.0d0) - y)))
else
tmp = x - ((-1.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -12000.0) {
tmp = x - ((x + -1.0) / y);
} else if (y <= 225000000.0) {
tmp = 1.0 - (y * (x / (-1.0 - y)));
} else {
tmp = x - (-1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -12000.0: tmp = x - ((x + -1.0) / y) elif y <= 225000000.0: tmp = 1.0 - (y * (x / (-1.0 - y))) else: tmp = x - (-1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -12000.0) tmp = Float64(x - Float64(Float64(x + -1.0) / y)); elseif (y <= 225000000.0) tmp = Float64(1.0 - Float64(y * Float64(x / Float64(-1.0 - y)))); else tmp = Float64(x - Float64(-1.0 / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -12000.0) tmp = x - ((x + -1.0) / y); elseif (y <= 225000000.0) tmp = 1.0 - (y * (x / (-1.0 - y))); else tmp = x - (-1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -12000.0], N[(x - N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 225000000.0], N[(1.0 - N[(y * N[(x / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -12000:\\
\;\;\;\;x - \frac{x + -1}{y}\\
\mathbf{elif}\;y \leq 225000000:\\
\;\;\;\;1 - y \cdot \frac{x}{-1 - y}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{-1}{y}\\
\end{array}
\end{array}
if y < -12000Initial program 31.9%
associate-*l/52.1%
+-commutative52.1%
Simplified52.1%
Taylor expanded in y around inf 99.5%
associate--l+99.5%
div-sub99.5%
sub-neg99.5%
+-commutative99.5%
metadata-eval99.5%
distribute-neg-in99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
sub-neg99.5%
unsub-neg99.5%
sub-neg99.5%
metadata-eval99.5%
Simplified99.5%
if -12000 < y < 2.25e8Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 98.1%
neg-mul-198.1%
distribute-neg-frac98.1%
Simplified98.1%
frac-2neg98.1%
remove-double-neg98.1%
associate-*l/98.1%
+-commutative98.1%
distribute-neg-in98.1%
metadata-eval98.1%
Applied egg-rr98.1%
associate-/l*98.0%
associate-/r/98.1%
+-commutative98.1%
unsub-neg98.1%
Simplified98.1%
if 2.25e8 < y Initial program 24.1%
associate-*l/58.8%
+-commutative58.8%
Simplified58.8%
Taylor expanded in y around inf 99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
+-commutative99.8%
metadata-eval99.8%
distribute-neg-in99.8%
distribute-neg-frac99.8%
metadata-eval99.8%
sub-neg99.8%
unsub-neg99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
Final simplification98.9%
(FPCore (x y) :precision binary64 (if (<= y -9.2e+38) x (if (<= y -12500000000.0) (/ 1.0 y) (if (<= y 0.0036) (- 1.0 y) x))))
double code(double x, double y) {
double tmp;
if (y <= -9.2e+38) {
tmp = x;
} else if (y <= -12500000000.0) {
tmp = 1.0 / y;
} else if (y <= 0.0036) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-9.2d+38)) then
tmp = x
else if (y <= (-12500000000.0d0)) then
tmp = 1.0d0 / y
else if (y <= 0.0036d0) then
tmp = 1.0d0 - y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -9.2e+38) {
tmp = x;
} else if (y <= -12500000000.0) {
tmp = 1.0 / y;
} else if (y <= 0.0036) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.2e+38: tmp = x elif y <= -12500000000.0: tmp = 1.0 / y elif y <= 0.0036: tmp = 1.0 - y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -9.2e+38) tmp = x; elseif (y <= -12500000000.0) tmp = Float64(1.0 / y); elseif (y <= 0.0036) tmp = Float64(1.0 - y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -9.2e+38) tmp = x; elseif (y <= -12500000000.0) tmp = 1.0 / y; elseif (y <= 0.0036) tmp = 1.0 - y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -9.2e+38], x, If[LessEqual[y, -12500000000.0], N[(1.0 / y), $MachinePrecision], If[LessEqual[y, 0.0036], N[(1.0 - y), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+38}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -12500000000:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{elif}\;y \leq 0.0036:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -9.2000000000000005e38 or 0.0035999999999999999 < y Initial program 28.9%
associate-*l/58.2%
+-commutative58.2%
Simplified58.2%
Taylor expanded in y around inf 78.8%
if -9.2000000000000005e38 < y < -1.25e10Initial program 23.3%
associate-*l/36.9%
+-commutative36.9%
Simplified36.9%
Taylor expanded in x around 0 9.3%
Taylor expanded in y around inf 67.7%
if -1.25e10 < y < 0.0035999999999999999Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 97.6%
Taylor expanded in x around 0 78.8%
Final simplification78.2%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.8))) (- x (/ -1.0 y)) (+ 1.0 (* y (+ x -1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.8)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + (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 ((y <= (-1.0d0)) .or. (.not. (y <= 0.8d0))) then
tmp = x - ((-1.0d0) / y)
else
tmp = 1.0d0 + (y * (x + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.8)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + (y * (x + -1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 0.8): tmp = x - (-1.0 / y) else: tmp = 1.0 + (y * (x + -1.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.8)) tmp = Float64(x - Float64(-1.0 / y)); else tmp = Float64(1.0 + Float64(y * Float64(x + -1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 0.8))) tmp = x - (-1.0 / y); else tmp = 1.0 + (y * (x + -1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 0.8]], $MachinePrecision]], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 0.8\right):\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \left(x + -1\right)\\
\end{array}
\end{array}
if y < -1 or 0.80000000000000004 < y Initial program 28.3%
associate-*l/56.0%
+-commutative56.0%
Simplified56.0%
Taylor expanded in y around inf 99.2%
associate--l+99.2%
div-sub99.2%
sub-neg99.2%
+-commutative99.2%
metadata-eval99.2%
distribute-neg-in99.2%
distribute-neg-frac99.2%
metadata-eval99.2%
sub-neg99.2%
unsub-neg99.2%
sub-neg99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in x around 0 98.7%
if -1 < y < 0.80000000000000004Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 97.8%
Final simplification98.2%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (- x (/ (+ x -1.0) y)) (+ 1.0 (* y (+ x -1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x - ((x + -1.0) / y);
} else {
tmp = 1.0 + (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 ((y <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = x - ((x + (-1.0d0)) / y)
else
tmp = 1.0d0 + (y * (x + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x - ((x + -1.0) / y);
} else {
tmp = 1.0 + (y * (x + -1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = x - ((x + -1.0) / y) else: tmp = 1.0 + (y * (x + -1.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(x - Float64(Float64(x + -1.0) / y)); else tmp = Float64(1.0 + Float64(y * Float64(x + -1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = x - ((x + -1.0) / y); else tmp = 1.0 + (y * (x + -1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x - N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x - \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \left(x + -1\right)\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 28.3%
associate-*l/56.0%
+-commutative56.0%
Simplified56.0%
Taylor expanded in y around inf 99.2%
associate--l+99.2%
div-sub99.2%
sub-neg99.2%
+-commutative99.2%
metadata-eval99.2%
distribute-neg-in99.2%
distribute-neg-frac99.2%
metadata-eval99.2%
sub-neg99.2%
unsub-neg99.2%
sub-neg99.2%
metadata-eval99.2%
Simplified99.2%
if -1 < y < 1Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 97.8%
Final simplification98.5%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (- x (/ -1.0 y)) (+ 1.0 (* y x))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + (y * x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = x - ((-1.0d0) / y)
else
tmp = 1.0d0 + (y * x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + (y * x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = x - (-1.0 / y) else: tmp = 1.0 + (y * x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(x - Float64(-1.0 / y)); else tmp = Float64(1.0 + Float64(y * x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = x - (-1.0 / y); else tmp = 1.0 + (y * x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot x\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 28.3%
associate-*l/56.0%
+-commutative56.0%
Simplified56.0%
Taylor expanded in y around inf 99.2%
associate--l+99.2%
div-sub99.2%
sub-neg99.2%
+-commutative99.2%
metadata-eval99.2%
distribute-neg-in99.2%
distribute-neg-frac99.2%
metadata-eval99.2%
sub-neg99.2%
unsub-neg99.2%
sub-neg99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in x around 0 98.7%
if -1 < y < 1Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 98.1%
neg-mul-198.1%
distribute-neg-frac98.1%
Simplified98.1%
Taylor expanded in y around 0 96.6%
associate-*r*96.6%
neg-mul-196.6%
Simplified96.6%
cancel-sign-sub96.6%
+-commutative96.6%
Applied egg-rr96.6%
Final simplification97.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.0036) (- 1.0 y) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.0036) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = x
else if (y <= 0.0036d0) then
tmp = 1.0d0 - y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.0036) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.0036: tmp = 1.0 - y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 0.0036) tmp = Float64(1.0 - y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x; elseif (y <= 0.0036) tmp = 1.0 - y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 0.0036], N[(1.0 - y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.0036:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.0035999999999999999 < y Initial program 28.9%
associate-*l/56.4%
+-commutative56.4%
Simplified56.4%
Taylor expanded in y around inf 73.7%
if -1 < y < 0.0035999999999999999Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 98.3%
Taylor expanded in x around 0 79.3%
Final simplification76.5%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.0036) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.0036) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = x
else if (y <= 0.0036d0) then
tmp = 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.0036) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.0036: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 0.0036) tmp = 1.0; else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x; elseif (y <= 0.0036) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 0.0036], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.0036:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.0035999999999999999 < y Initial program 28.9%
associate-*l/56.4%
+-commutative56.4%
Simplified56.4%
Taylor expanded in y around inf 73.7%
if -1 < y < 0.0035999999999999999Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 78.0%
Final simplification75.9%
(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 64.4%
associate-*l/78.2%
+-commutative78.2%
Simplified78.2%
Taylor expanded in y around 0 40.8%
Final simplification40.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (/ 1.0 y) (- (/ x y) x))))
(if (< y -3693.8482788297247)
t_0
(if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) t_0))))
double code(double x, double y) {
double t_0 = (1.0 / y) - ((x / y) - x);
double tmp;
if (y < -3693.8482788297247) {
tmp = t_0;
} else if (y < 6799310503.41891) {
tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
} 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 / y) - ((x / y) - x)
if (y < (-3693.8482788297247d0)) then
tmp = t_0
else if (y < 6799310503.41891d0) then
tmp = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (1.0 / y) - ((x / y) - x);
double tmp;
if (y < -3693.8482788297247) {
tmp = t_0;
} else if (y < 6799310503.41891) {
tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (1.0 / y) - ((x / y) - x) tmp = 0 if y < -3693.8482788297247: tmp = t_0 elif y < 6799310503.41891: tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(1.0 / y) - Float64(Float64(x / y) - x)) tmp = 0.0 if (y < -3693.8482788297247) tmp = t_0; elseif (y < 6799310503.41891) tmp = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (1.0 / y) - ((x / y) - x); tmp = 0.0; if (y < -3693.8482788297247) tmp = t_0; elseif (y < 6799310503.41891) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]}, If[Less[y, -3693.8482788297247], t$95$0, If[Less[y, 6799310503.41891], N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{y} - \left(\frac{x}{y} - x\right)\\
\mathbf{if}\;y < -3693.8482788297247:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y < 6799310503.41891:\\
\;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2024018
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:precision binary64
:herbie-target
(if (< y -3693.8482788297247) (- (/ 1.0 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) (- (/ 1.0 y) (- (/ x y) x))))
(- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))