
(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 11 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 (<= y -12000000.0)
(+ x (/ (+ 1.0 (- (/ (+ x -1.0) y) x)) y))
(if (<= y 8400000000.0)
(+ 1.0 (* (/ y (+ y 1.0)) (+ x -1.0)))
(+ x (/ 1.0 y)))))
double code(double x, double y) {
double tmp;
if (y <= -12000000.0) {
tmp = x + ((1.0 + (((x + -1.0) / y) - x)) / y);
} else if (y <= 8400000000.0) {
tmp = 1.0 + ((y / (y + 1.0)) * (x + -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 <= (-12000000.0d0)) then
tmp = x + ((1.0d0 + (((x + (-1.0d0)) / y) - x)) / y)
else if (y <= 8400000000.0d0) then
tmp = 1.0d0 + ((y / (y + 1.0d0)) * (x + (-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 <= -12000000.0) {
tmp = x + ((1.0 + (((x + -1.0) / y) - x)) / y);
} else if (y <= 8400000000.0) {
tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0));
} else {
tmp = x + (1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -12000000.0: tmp = x + ((1.0 + (((x + -1.0) / y) - x)) / y) elif y <= 8400000000.0: tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0)) else: tmp = x + (1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -12000000.0) tmp = Float64(x + Float64(Float64(1.0 + Float64(Float64(Float64(x + -1.0) / y) - x)) / y)); elseif (y <= 8400000000.0) tmp = Float64(1.0 + Float64(Float64(y / Float64(y + 1.0)) * Float64(x + -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 <= -12000000.0) tmp = x + ((1.0 + (((x + -1.0) / y) - x)) / y); elseif (y <= 8400000000.0) tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0)); else tmp = x + (1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -12000000.0], N[(x + N[(N[(1.0 + N[(N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8400000000.0], N[(1.0 + N[(N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -12000000:\\
\;\;\;\;x + \frac{1 + \left(\frac{x + -1}{y} - x\right)}{y}\\
\mathbf{elif}\;y \leq 8400000000:\\
\;\;\;\;1 + \frac{y}{y + 1} \cdot \left(x + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{y}\\
\end{array}
\end{array}
if y < -1.2e7Initial program 27.7%
associate-/l*54.2%
+-commutative54.2%
Simplified54.2%
Taylor expanded in y around -inf 99.9%
Simplified99.9%
if -1.2e7 < y < 8.4e9Initial program 99.9%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
if 8.4e9 < y Initial program 32.4%
associate-/l*50.9%
+-commutative50.9%
Simplified50.9%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
div-sub100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
mul-1-neg100.0%
associate-*r/100.0%
mul-1-neg100.0%
unsub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= y -160000000.0)
(+ x (/ (- 1.0 x) y))
(if (<= y 52000000000.0)
(+ 1.0 (* (/ y (+ y 1.0)) (+ x -1.0)))
(+ x (/ 1.0 y)))))
double code(double x, double y) {
double tmp;
if (y <= -160000000.0) {
tmp = x + ((1.0 - x) / y);
} else if (y <= 52000000000.0) {
tmp = 1.0 + ((y / (y + 1.0)) * (x + -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 <= (-160000000.0d0)) then
tmp = x + ((1.0d0 - x) / y)
else if (y <= 52000000000.0d0) then
tmp = 1.0d0 + ((y / (y + 1.0d0)) * (x + (-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 <= -160000000.0) {
tmp = x + ((1.0 - x) / y);
} else if (y <= 52000000000.0) {
tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0));
} else {
tmp = x + (1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -160000000.0: tmp = x + ((1.0 - x) / y) elif y <= 52000000000.0: tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0)) else: tmp = x + (1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -160000000.0) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); elseif (y <= 52000000000.0) tmp = Float64(1.0 + Float64(Float64(y / Float64(y + 1.0)) * Float64(x + -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 <= -160000000.0) tmp = x + ((1.0 - x) / y); elseif (y <= 52000000000.0) tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0)); else tmp = x + (1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -160000000.0], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 52000000000.0], N[(1.0 + N[(N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -160000000:\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{elif}\;y \leq 52000000000:\\
\;\;\;\;1 + \frac{y}{y + 1} \cdot \left(x + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{y}\\
\end{array}
\end{array}
if y < -1.6e8Initial program 27.1%
associate-/l*54.0%
+-commutative54.0%
Simplified54.0%
Taylor expanded in y around inf 99.7%
associate--l+99.7%
div-sub99.7%
sub-neg99.7%
+-commutative99.7%
neg-sub099.7%
associate-+l-99.7%
neg-sub099.7%
mul-1-neg99.7%
associate-*r/99.7%
mul-1-neg99.7%
unsub-neg99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
if -1.6e8 < y < 5.2e10Initial program 99.7%
associate-/l*99.7%
+-commutative99.7%
Simplified99.7%
if 5.2e10 < y Initial program 32.4%
associate-/l*50.9%
+-commutative50.9%
Simplified50.9%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
div-sub100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
mul-1-neg100.0%
associate-*r/100.0%
mul-1-neg100.0%
unsub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 2.1) (+ 1.0 (* x y)) (if (<= y 1.1e+44) (/ 1.0 y) x))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 2.1) {
tmp = 1.0 + (x * y);
} else if (y <= 1.1e+44) {
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 <= 2.1d0) then
tmp = 1.0d0 + (x * y)
else if (y <= 1.1d+44) 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 <= 2.1) {
tmp = 1.0 + (x * y);
} else if (y <= 1.1e+44) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 2.1: tmp = 1.0 + (x * y) elif y <= 1.1e+44: tmp = 1.0 / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 2.1) tmp = Float64(1.0 + Float64(x * y)); elseif (y <= 1.1e+44) 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 <= 2.1) tmp = 1.0 + (x * y); elseif (y <= 1.1e+44) tmp = 1.0 / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 2.1], N[(1.0 + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+44], N[(1.0 / y), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.1:\\
\;\;\;\;1 + x \cdot y\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 1.09999999999999998e44 < y Initial program 31.7%
associate-/l*56.2%
+-commutative56.2%
Simplified56.2%
Taylor expanded in y around inf 76.0%
if -1 < y < 2.10000000000000009Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 98.4%
Taylor expanded in x around inf 98.0%
neg-mul-198.0%
Simplified98.0%
cancel-sign-sub98.0%
+-commutative98.0%
Applied egg-rr98.0%
if 2.10000000000000009 < y < 1.09999999999999998e44Initial program 39.8%
associate-/l*39.8%
+-commutative39.8%
Simplified39.8%
Taylor expanded in y around inf 88.6%
associate--l+88.6%
div-sub88.6%
sub-neg88.6%
+-commutative88.6%
neg-sub088.6%
associate-+l-88.6%
neg-sub088.6%
mul-1-neg88.6%
associate-*r/88.6%
mul-1-neg88.6%
unsub-neg88.6%
sub-neg88.6%
metadata-eval88.6%
Simplified88.6%
Taylor expanded in x around 0 61.4%
Final simplification86.2%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.75) (- 1.0 y) (if (<= y 2.4e+44) (/ 1.0 y) x))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.75) {
tmp = 1.0 - y;
} else if (y <= 2.4e+44) {
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.75d0) then
tmp = 1.0d0 - y
else if (y <= 2.4d+44) 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.75) {
tmp = 1.0 - y;
} else if (y <= 2.4e+44) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.75: tmp = 1.0 - y elif y <= 2.4e+44: 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.75) tmp = Float64(1.0 - y); elseif (y <= 2.4e+44) 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.75) tmp = 1.0 - y; elseif (y <= 2.4e+44) 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.75], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 2.4e+44], N[(1.0 / y), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.75:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+44}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 2.40000000000000013e44 < y Initial program 31.7%
associate-/l*56.2%
+-commutative56.2%
Simplified56.2%
Taylor expanded in y around inf 76.0%
if -1 < y < 0.75Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 98.4%
Taylor expanded in x around 0 81.4%
if 0.75 < y < 2.40000000000000013e44Initial program 39.8%
associate-/l*39.8%
+-commutative39.8%
Simplified39.8%
Taylor expanded in y around inf 88.6%
associate--l+88.6%
div-sub88.6%
sub-neg88.6%
+-commutative88.6%
neg-sub088.6%
associate-+l-88.6%
neg-sub088.6%
mul-1-neg88.6%
associate-*r/88.6%
mul-1-neg88.6%
unsub-neg88.6%
sub-neg88.6%
metadata-eval88.6%
Simplified88.6%
Taylor expanded in x around 0 61.4%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.82))) (+ x (/ 1.0 y)) (+ 1.0 (* y (+ x -1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.82)) {
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.82d0))) 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.82)) {
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.82): 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.82)) 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.82))) 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.82]], $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.82\right):\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \left(x + -1\right)\\
\end{array}
\end{array}
if y < -1 or 0.819999999999999951 < y Initial program 32.5%
associate-/l*54.5%
+-commutative54.5%
Simplified54.5%
Taylor expanded in y around inf 97.6%
associate--l+97.6%
div-sub97.6%
sub-neg97.6%
+-commutative97.6%
neg-sub097.6%
associate-+l-97.6%
neg-sub097.6%
mul-1-neg97.6%
associate-*r/97.6%
mul-1-neg97.6%
unsub-neg97.6%
sub-neg97.6%
metadata-eval97.6%
Simplified97.6%
Taylor expanded in x around 0 96.8%
if -1 < y < 0.819999999999999951Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 98.4%
Final simplification97.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) (+ x (/ (- 1.0 x) y)) (if (<= y 0.78) (+ 1.0 (* y (+ x -1.0))) (+ x (/ 1.0 y)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x + ((1.0 - x) / y);
} else if (y <= 0.78) {
tmp = 1.0 + (y * (x + -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 <= (-1.0d0)) then
tmp = x + ((1.0d0 - x) / y)
else if (y <= 0.78d0) then
tmp = 1.0d0 + (y * (x + (-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 <= -1.0) {
tmp = x + ((1.0 - x) / y);
} else if (y <= 0.78) {
tmp = 1.0 + (y * (x + -1.0));
} else {
tmp = x + (1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x + ((1.0 - x) / y) elif y <= 0.78: tmp = 1.0 + (y * (x + -1.0)) else: tmp = x + (1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); elseif (y <= 0.78) tmp = Float64(1.0 + Float64(y * Float64(x + -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 <= -1.0) tmp = x + ((1.0 - x) / y); elseif (y <= 0.78) tmp = 1.0 + (y * (x + -1.0)); else tmp = x + (1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.78], N[(1.0 + N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{elif}\;y \leq 0.78:\\
\;\;\;\;1 + y \cdot \left(x + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{y}\\
\end{array}
\end{array}
if y < -1Initial program 30.8%
associate-/l*56.2%
+-commutative56.2%
Simplified56.2%
Taylor expanded in y around inf 97.8%
associate--l+97.8%
div-sub97.8%
sub-neg97.8%
+-commutative97.8%
neg-sub097.8%
associate-+l-97.8%
neg-sub097.8%
mul-1-neg97.8%
associate-*r/97.8%
mul-1-neg97.8%
unsub-neg97.8%
sub-neg97.8%
metadata-eval97.8%
Simplified97.8%
if -1 < y < 0.78000000000000003Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 98.4%
if 0.78000000000000003 < y Initial program 34.6%
associate-/l*52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around inf 97.4%
associate--l+97.4%
div-sub97.4%
sub-neg97.4%
+-commutative97.4%
neg-sub097.4%
associate-+l-97.4%
neg-sub097.4%
mul-1-neg97.4%
associate-*r/97.4%
mul-1-neg97.4%
unsub-neg97.4%
sub-neg97.4%
metadata-eval97.4%
Simplified97.4%
Taylor expanded in x around 0 97.4%
Final simplification98.0%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (+ x (/ 1.0 y)) (+ 1.0 (* x y))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x + (1.0 / y);
} else {
tmp = 1.0 + (x * y);
}
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 + (x * y)
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 + (x * y);
}
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 + (x * y) 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(x * y)); 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 + (x * y); 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[(x * y), $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 + x \cdot y\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 32.5%
associate-/l*54.5%
+-commutative54.5%
Simplified54.5%
Taylor expanded in y around inf 97.6%
associate--l+97.6%
div-sub97.6%
sub-neg97.6%
+-commutative97.6%
neg-sub097.6%
associate-+l-97.6%
neg-sub097.6%
mul-1-neg97.6%
associate-*r/97.6%
mul-1-neg97.6%
unsub-neg97.6%
sub-neg97.6%
metadata-eval97.6%
Simplified97.6%
Taylor expanded in x around 0 96.8%
if -1 < y < 1Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 98.4%
Taylor expanded in x around inf 98.0%
neg-mul-198.0%
Simplified98.0%
cancel-sign-sub98.0%
+-commutative98.0%
Applied egg-rr98.0%
Final simplification97.4%
(FPCore (x y) :precision binary64 (* x (+ (/ y (+ y 1.0)) (/ (/ 1.0 x) (+ y 1.0)))))
double code(double x, double y) {
return x * ((y / (y + 1.0)) + ((1.0 / x) / (y + 1.0)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * ((y / (y + 1.0d0)) + ((1.0d0 / x) / (y + 1.0d0)))
end function
public static double code(double x, double y) {
return x * ((y / (y + 1.0)) + ((1.0 / x) / (y + 1.0)));
}
def code(x, y): return x * ((y / (y + 1.0)) + ((1.0 / x) / (y + 1.0)))
function code(x, y) return Float64(x * Float64(Float64(y / Float64(y + 1.0)) + Float64(Float64(1.0 / x) / Float64(y + 1.0)))) end
function tmp = code(x, y) tmp = x * ((y / (y + 1.0)) + ((1.0 / x) / (y + 1.0))); end
code[x_, y_] := N[(x * N[(N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\frac{y}{y + 1} + \frac{\frac{1}{x}}{y + 1}\right)
\end{array}
Initial program 66.2%
associate-/l*77.2%
+-commutative77.2%
Simplified77.2%
Taylor expanded in x around inf 77.5%
associate--r+77.5%
sub-neg77.5%
cancel-sign-sub-inv77.5%
metadata-eval77.5%
*-lft-identity77.5%
mul-1-neg77.5%
+-commutative77.5%
associate-+l+85.0%
mul-1-neg85.0%
distribute-neg-frac285.0%
distribute-rgt-neg-out85.0%
distribute-neg-in85.0%
metadata-eval85.0%
sub-neg85.0%
Simplified85.0%
frac-add57.6%
div-inv56.7%
*-un-lft-identity56.7%
distribute-lft-out68.6%
associate-*r*66.8%
pow266.8%
Applied egg-rr66.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.62) (- 1.0 y) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.62) {
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.62d0) 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.62) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.62: 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.62) 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.62) 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.62], N[(1.0 - y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.62:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.619999999999999996 < y Initial program 32.5%
associate-/l*54.5%
+-commutative54.5%
Simplified54.5%
Taylor expanded in y around inf 70.9%
if -1 < y < 0.619999999999999996Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 98.4%
Taylor expanded in x around 0 81.4%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 1.1e+25) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 1.1e+25) {
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 <= 1.1d+25) 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 <= 1.1e+25) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 1.1e+25: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 1.1e+25) 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 <= 1.1e+25) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 1.1e+25], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+25}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 1.1e25 < y Initial program 32.2%
associate-/l*55.1%
+-commutative55.1%
Simplified55.1%
Taylor expanded in y around inf 73.6%
if -1 < y < 1.1e25Initial program 97.7%
associate-/l*97.7%
+-commutative97.7%
Simplified97.7%
Taylor expanded in y around 0 78.3%
(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 66.2%
associate-/l*77.2%
+-commutative77.2%
Simplified77.2%
Taylor expanded in y around 0 42.5%
(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 2024112
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:precision binary64
:alt
(! :herbie-platform default (if (< y -36938482788297247/10000000000000) (- (/ 1 y) (- (/ x y) x)) (if (< y 679931050341891/100000) (- 1 (/ (* (- 1 x) y) (+ y 1))) (- (/ 1 y) (- (/ x y) x)))))
(- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))