
(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 -300000.0) (not (<= y 340000.0))) (+ x (/ (+ (- 1.0 x) (/ (+ x -1.0) y)) y)) (+ 1.0 (/ (* y (- 1.0 x)) (- -1.0 y)))))
double code(double x, double y) {
double tmp;
if ((y <= -300000.0) || !(y <= 340000.0)) {
tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y);
} else {
tmp = 1.0 + ((y * (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 ((y <= (-300000.0d0)) .or. (.not. (y <= 340000.0d0))) then
tmp = x + (((1.0d0 - x) + ((x + (-1.0d0)) / y)) / y)
else
tmp = 1.0d0 + ((y * (1.0d0 - x)) / ((-1.0d0) - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -300000.0) || !(y <= 340000.0)) {
tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y);
} else {
tmp = 1.0 + ((y * (1.0 - x)) / (-1.0 - y));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -300000.0) or not (y <= 340000.0): tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y) else: tmp = 1.0 + ((y * (1.0 - x)) / (-1.0 - y)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -300000.0) || !(y <= 340000.0)) tmp = Float64(x + Float64(Float64(Float64(1.0 - x) + Float64(Float64(x + -1.0) / y)) / y)); else tmp = Float64(1.0 + Float64(Float64(y * Float64(1.0 - x)) / Float64(-1.0 - y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -300000.0) || ~((y <= 340000.0))) tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y); else tmp = 1.0 + ((y * (1.0 - x)) / (-1.0 - y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -300000.0], N[Not[LessEqual[y, 340000.0]], $MachinePrecision]], N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -300000 \lor \neg \left(y \leq 340000\right):\\
\;\;\;\;x + \frac{\left(1 - x\right) + \frac{x + -1}{y}}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{y \cdot \left(1 - x\right)}{-1 - y}\\
\end{array}
\end{array}
if y < -3e5 or 3.4e5 < y Initial program 29.9%
associate-/l*58.8%
+-commutative58.8%
Simplified58.8%
Taylor expanded in y around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
if -3e5 < y < 3.4e5Initial program 99.8%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= y -85000000.0) (not (<= y 160000000.0))) (+ x (/ (- 1.0 x) y)) (+ 1.0 (/ (* y (- 1.0 x)) (- -1.0 y)))))
double code(double x, double y) {
double tmp;
if ((y <= -85000000.0) || !(y <= 160000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + ((y * (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 ((y <= (-85000000.0d0)) .or. (.not. (y <= 160000000.0d0))) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = 1.0d0 + ((y * (1.0d0 - x)) / ((-1.0d0) - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -85000000.0) || !(y <= 160000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + ((y * (1.0 - x)) / (-1.0 - y));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -85000000.0) or not (y <= 160000000.0): tmp = x + ((1.0 - x) / y) else: tmp = 1.0 + ((y * (1.0 - x)) / (-1.0 - y)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -85000000.0) || !(y <= 160000000.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(1.0 + Float64(Float64(y * Float64(1.0 - x)) / Float64(-1.0 - y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -85000000.0) || ~((y <= 160000000.0))) tmp = x + ((1.0 - x) / y); else tmp = 1.0 + ((y * (1.0 - x)) / (-1.0 - y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -85000000.0], N[Not[LessEqual[y, 160000000.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -85000000 \lor \neg \left(y \leq 160000000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{y \cdot \left(1 - x\right)}{-1 - y}\\
\end{array}
\end{array}
if y < -8.5e7 or 1.6e8 < y Initial program 27.9%
associate-/l*57.6%
+-commutative57.6%
Simplified57.6%
Taylor expanded in y around inf 99.8%
associate--l+99.8%
div-sub99.8%
Simplified99.8%
if -8.5e7 < y < 1.6e8Initial program 99.6%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (or (<= y -160000000.0) (not (<= y 310000000.0))) (+ x (/ (- 1.0 x) y)) (+ 1.0 (* (/ y (+ y 1.0)) (+ x -1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -160000000.0) || !(y <= 310000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-160000000.0d0)) .or. (.not. (y <= 310000000.0d0))) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = 1.0d0 + ((y / (y + 1.0d0)) * (x + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -160000000.0) || !(y <= 310000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -160000000.0) or not (y <= 310000000.0): tmp = x + ((1.0 - x) / y) else: tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -160000000.0) || !(y <= 310000000.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(1.0 + Float64(Float64(y / Float64(y + 1.0)) * Float64(x + -1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -160000000.0) || ~((y <= 310000000.0))) tmp = x + ((1.0 - x) / y); else tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -160000000.0], N[Not[LessEqual[y, 310000000.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -160000000 \lor \neg \left(y \leq 310000000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{y}{y + 1} \cdot \left(x + -1\right)\\
\end{array}
\end{array}
if y < -1.6e8 or 3.1e8 < y Initial program 27.9%
associate-/l*57.6%
+-commutative57.6%
Simplified57.6%
Taylor expanded in y around inf 99.8%
associate--l+99.8%
div-sub99.8%
Simplified99.8%
if -1.6e8 < y < 3.1e8Initial program 99.6%
associate-/l*99.6%
+-commutative99.6%
Simplified99.6%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (+ x (/ (- 1.0 x) y)) (+ 1.0 (* y (+ x -1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x + ((1.0 - x) / 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 + ((1.0d0 - x) / 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 + ((1.0 - x) / 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 + ((1.0 - x) / 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(1.0 - x) / 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 + ((1.0 - x) / 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[(1.0 - x), $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{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \left(x + -1\right)\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 32.4%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in y around inf 96.7%
associate--l+96.7%
div-sub96.7%
Simplified96.7%
if -1 < y < 1Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 99.3%
Final simplification98.0%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.2))) (+ x (/ (- 1.0 x) y)) (+ 1.0 (* x y))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.2)) {
tmp = x + ((1.0 - x) / 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.2d0))) then
tmp = x + ((1.0d0 - x) / 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.2)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 1.2): tmp = x + ((1.0 - x) / y) else: tmp = 1.0 + (x * y) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.2)) tmp = Float64(x + Float64(Float64(1.0 - x) / 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.2))) tmp = x + ((1.0 - x) / 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.2]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / 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.2\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot y\\
\end{array}
\end{array}
if y < -1 or 1.19999999999999996 < y Initial program 32.4%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in y around inf 96.7%
associate--l+96.7%
div-sub96.7%
Simplified96.7%
if -1 < y < 1.19999999999999996Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 99.3%
Taylor expanded in x around inf 99.0%
neg-mul-199.0%
Simplified99.0%
Final simplification97.8%
(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.4%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in y around inf 96.7%
associate--l+96.7%
div-sub96.7%
Simplified96.7%
Taylor expanded in x around 0 95.2%
if -1 < y < 1Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 99.3%
Taylor expanded in x around inf 99.0%
neg-mul-199.0%
Simplified99.0%
Final simplification97.0%
(FPCore (x y) :precision binary64 (if (or (<= y -750000000000.0) (not (<= y 170.0))) (+ x (/ 1.0 y)) (/ 1.0 (+ y 1.0))))
double code(double x, double y) {
double tmp;
if ((y <= -750000000000.0) || !(y <= 170.0)) {
tmp = x + (1.0 / y);
} else {
tmp = 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 <= (-750000000000.0d0)) .or. (.not. (y <= 170.0d0))) then
tmp = x + (1.0d0 / y)
else
tmp = 1.0d0 / (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -750000000000.0) || !(y <= 170.0)) {
tmp = x + (1.0 / y);
} else {
tmp = 1.0 / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -750000000000.0) or not (y <= 170.0): tmp = x + (1.0 / y) else: tmp = 1.0 / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((y <= -750000000000.0) || !(y <= 170.0)) tmp = Float64(x + Float64(1.0 / y)); else tmp = Float64(1.0 / Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -750000000000.0) || ~((y <= 170.0))) tmp = x + (1.0 / y); else tmp = 1.0 / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -750000000000.0], N[Not[LessEqual[y, 170.0]], $MachinePrecision]], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -750000000000 \lor \neg \left(y \leq 170\right):\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y + 1}\\
\end{array}
\end{array}
if y < -7.5e11 or 170 < y Initial program 30.4%
associate-/l*59.2%
+-commutative59.2%
Simplified59.2%
Taylor expanded in y around inf 98.7%
associate--l+98.7%
div-sub98.7%
Simplified98.7%
Taylor expanded in x around 0 97.3%
if -7.5e11 < y < 170Initial program 99.3%
sub-neg99.3%
+-commutative99.3%
*-commutative99.3%
associate-/l*99.3%
distribute-rgt-neg-in99.3%
fma-define99.3%
distribute-frac-neg299.3%
+-commutative99.3%
distribute-neg-in99.3%
metadata-eval99.3%
unsub-neg99.3%
Simplified99.3%
Taylor expanded in x around inf 99.2%
+-commutative99.2%
+-commutative99.2%
associate-+l+99.2%
+-commutative99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
distribute-rgt-neg-out99.2%
distribute-neg-in99.2%
metadata-eval99.2%
sub-neg99.2%
Simplified99.2%
associate-/r*99.1%
frac-add99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
times-frac99.8%
*-rgt-identity99.8%
associate-*r/99.6%
rgt-mult-inverse99.8%
rem-square-sqrt53.4%
associate-*r/53.4%
/-rgt-identity53.4%
rem-square-sqrt99.8%
*-lft-identity99.8%
associate-+l-99.8%
+-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 81.7%
Final simplification89.5%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.125))) (+ x (/ 1.0 y)) (- 1.0 y)))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.125)) {
tmp = x + (1.0 / y);
} else {
tmp = 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)) .or. (.not. (y <= 0.125d0))) then
tmp = x + (1.0d0 / y)
else
tmp = 1.0d0 - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.125)) {
tmp = x + (1.0 / y);
} else {
tmp = 1.0 - y;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 0.125): tmp = x + (1.0 / y) else: tmp = 1.0 - y return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.125)) tmp = Float64(x + Float64(1.0 / y)); else tmp = Float64(1.0 - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 0.125))) tmp = x + (1.0 / y); else tmp = 1.0 - y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 0.125]], $MachinePrecision]], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 0.125\right):\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if y < -1 or 0.125 < y Initial program 32.4%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in y around inf 96.7%
associate--l+96.7%
div-sub96.7%
Simplified96.7%
Taylor expanded in x around 0 95.2%
if -1 < y < 0.125Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 82.6%
+-commutative82.6%
Simplified82.6%
Taylor expanded in y around 0 82.1%
Final simplification88.9%
(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(-1.0 / Float64(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[(-1.0 / N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\frac{y}{y + 1} - \frac{-1}{x \cdot \left(y + 1\right)}\right)
\end{array}
Initial program 65.1%
sub-neg65.1%
+-commutative65.1%
*-commutative65.1%
associate-/l*79.4%
distribute-rgt-neg-in79.4%
fma-define79.4%
distribute-frac-neg279.4%
+-commutative79.4%
distribute-neg-in79.4%
metadata-eval79.4%
unsub-neg79.4%
Simplified79.4%
Taylor expanded in x around inf 79.5%
+-commutative79.5%
+-commutative79.5%
associate-+l+85.9%
+-commutative85.9%
mul-1-neg85.9%
distribute-neg-frac285.9%
distribute-rgt-neg-out85.9%
distribute-neg-in85.9%
metadata-eval85.9%
sub-neg85.9%
Simplified85.9%
associate-/r*82.2%
frac-add83.8%
*-un-lft-identity83.8%
Applied egg-rr83.8%
associate-*r/73.7%
*-rgt-identity73.7%
times-frac89.4%
*-rgt-identity89.4%
associate-*r/87.9%
rgt-mult-inverse89.4%
rem-square-sqrt42.0%
associate-*r/42.0%
/-rgt-identity42.0%
rem-square-sqrt89.4%
*-lft-identity89.4%
associate-+l-99.8%
+-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.235) (- 1.0 y) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.235) {
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.235d0) 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.235) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.235: 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.235) 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.235) 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.235], N[(1.0 - y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.235:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.23499999999999999 < y Initial program 32.4%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in y around inf 72.9%
if -1 < y < 0.23499999999999999Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 82.6%
+-commutative82.6%
Simplified82.6%
Taylor expanded in y around 0 82.1%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 150.0) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 150.0) {
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 <= 150.0d0) 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 <= 150.0) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 150.0: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 150.0) 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 <= 150.0) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 150.0], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 150:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 150 < y Initial program 31.9%
associate-/l*59.9%
+-commutative59.9%
Simplified59.9%
Taylor expanded in y around inf 73.4%
if -1 < y < 150Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
*-commutative99.9%
associate-/l*99.9%
distribute-rgt-neg-in99.9%
fma-define99.9%
distribute-frac-neg299.9%
+-commutative99.9%
distribute-neg-in99.9%
metadata-eval99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 99.8%
associate-*r*99.8%
neg-mul-199.8%
distribute-lft-out99.8%
associate-*r*99.8%
distribute-lft-neg-in99.8%
*-commutative99.8%
neg-mul-199.8%
remove-double-neg99.8%
+-commutative99.8%
mul-1-neg99.8%
sub-neg99.8%
sub-neg99.8%
distribute-frac-neg299.8%
distribute-neg-in99.8%
metadata-eval99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in y around 0 81.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 65.1%
sub-neg65.1%
+-commutative65.1%
*-commutative65.1%
associate-/l*79.4%
distribute-rgt-neg-in79.4%
fma-define79.4%
distribute-frac-neg279.4%
+-commutative79.4%
distribute-neg-in79.4%
metadata-eval79.4%
unsub-neg79.4%
Simplified79.4%
Taylor expanded in x around -inf 88.7%
associate-*r*88.7%
neg-mul-188.7%
distribute-lft-out88.7%
associate-*r*88.7%
distribute-lft-neg-in88.7%
*-commutative88.7%
neg-mul-188.7%
remove-double-neg88.7%
+-commutative88.7%
mul-1-neg88.7%
sub-neg88.7%
sub-neg88.7%
distribute-frac-neg288.7%
distribute-neg-in88.7%
metadata-eval88.7%
sub-neg88.7%
Simplified88.7%
Taylor expanded in y around 0 41.4%
(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 2024148
(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))))