
(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 14 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
(let* ((t_0 (/ (- 1.0 x) y)))
(if (<= y -12200.0)
(+ x (+ (+ t_0 (/ (- 1.0 x) (pow y 3.0))) (/ (+ x -1.0) (pow y 2.0))))
(if (<= y 235000.0)
(fma (/ (+ x -1.0) (+ y 1.0)) y 1.0)
(+ t_0 (+ x (* t_0 (/ -1.0 y))))))))
double code(double x, double y) {
double t_0 = (1.0 - x) / y;
double tmp;
if (y <= -12200.0) {
tmp = x + ((t_0 + ((1.0 - x) / pow(y, 3.0))) + ((x + -1.0) / pow(y, 2.0)));
} else if (y <= 235000.0) {
tmp = fma(((x + -1.0) / (y + 1.0)), y, 1.0);
} else {
tmp = t_0 + (x + (t_0 * (-1.0 / y)));
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(1.0 - x) / y) tmp = 0.0 if (y <= -12200.0) tmp = Float64(x + Float64(Float64(t_0 + Float64(Float64(1.0 - x) / (y ^ 3.0))) + Float64(Float64(x + -1.0) / (y ^ 2.0)))); elseif (y <= 235000.0) tmp = fma(Float64(Float64(x + -1.0) / Float64(y + 1.0)), y, 1.0); else tmp = Float64(t_0 + Float64(x + Float64(t_0 * Float64(-1.0 / y)))); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, -12200.0], N[(x + N[(N[(t$95$0 + N[(N[(1.0 - x), $MachinePrecision] / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 235000.0], N[(N[(N[(x + -1.0), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision], N[(t$95$0 + N[(x + N[(t$95$0 * N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 - x}{y}\\
\mathbf{if}\;y \leq -12200:\\
\;\;\;\;x + \left(\left(t\_0 + \frac{1 - x}{{y}^{3}}\right) + \frac{x + -1}{{y}^{2}}\right)\\
\mathbf{elif}\;y \leq 235000:\\
\;\;\;\;\mathsf{fma}\left(\frac{x + -1}{y + 1}, y, 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(x + t\_0 \cdot \frac{-1}{y}\right)\\
\end{array}
\end{array}
if y < -12200Initial program 26.9%
associate-*l/50.0%
+-commutative50.0%
Simplified50.0%
Taylor expanded in y around -inf 100.0%
associate--l+100.0%
associate-+r+100.0%
associate--l+100.0%
Simplified100.0%
if -12200 < y < 235000Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
associate-/l*99.9%
distribute-neg-frac99.9%
associate-/r/99.9%
fma-def100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
if 235000 < y Initial program 32.5%
associate-*l/54.3%
+-commutative54.3%
Simplified54.3%
Taylor expanded in y around inf 100.0%
associate-+r+100.0%
neg-mul-1100.0%
sub-neg100.0%
associate--l+100.0%
associate-*r/100.0%
neg-mul-1100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
div-sub100.0%
Simplified100.0%
*-un-lft-identity100.0%
unpow2100.0%
times-frac100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- 1.0 x) y)))
(if (or (<= y -400000.0) (not (<= y 235000.0)))
(+ t_0 (+ x (* t_0 (/ -1.0 y))))
(fma (/ (+ x -1.0) (+ y 1.0)) y 1.0))))
double code(double x, double y) {
double t_0 = (1.0 - x) / y;
double tmp;
if ((y <= -400000.0) || !(y <= 235000.0)) {
tmp = t_0 + (x + (t_0 * (-1.0 / y)));
} else {
tmp = fma(((x + -1.0) / (y + 1.0)), y, 1.0);
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(1.0 - x) / y) tmp = 0.0 if ((y <= -400000.0) || !(y <= 235000.0)) tmp = Float64(t_0 + Float64(x + Float64(t_0 * Float64(-1.0 / y)))); else tmp = fma(Float64(Float64(x + -1.0) / Float64(y + 1.0)), y, 1.0); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]}, If[Or[LessEqual[y, -400000.0], N[Not[LessEqual[y, 235000.0]], $MachinePrecision]], N[(t$95$0 + N[(x + N[(t$95$0 * N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + -1.0), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 - x}{y}\\
\mathbf{if}\;y \leq -400000 \lor \neg \left(y \leq 235000\right):\\
\;\;\;\;t\_0 + \left(x + t\_0 \cdot \frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x + -1}{y + 1}, y, 1\right)\\
\end{array}
\end{array}
if y < -4e5 or 235000 < y Initial program 29.5%
associate-*l/52.0%
+-commutative52.0%
Simplified52.0%
Taylor expanded in y around inf 99.9%
associate-+r+99.9%
neg-mul-199.9%
sub-neg99.9%
associate--l+99.9%
associate-*r/99.9%
neg-mul-199.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
div-sub99.9%
Simplified99.9%
*-un-lft-identity99.9%
unpow299.9%
times-frac99.9%
Applied egg-rr99.9%
if -4e5 < y < 235000Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
associate-/l*99.9%
distribute-neg-frac99.9%
associate-/r/99.9%
fma-def100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- 1.0 x) y)))
(if (or (<= y -290000.0) (not (<= y 255000.0)))
(+ t_0 (+ x (* t_0 (/ -1.0 y))))
(+ 1.0 (/ (* y (+ x -1.0)) (+ y 1.0))))))
double code(double x, double y) {
double t_0 = (1.0 - x) / y;
double tmp;
if ((y <= -290000.0) || !(y <= 255000.0)) {
tmp = t_0 + (x + (t_0 * (-1.0 / y)));
} 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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 - x) / y
if ((y <= (-290000.0d0)) .or. (.not. (y <= 255000.0d0))) then
tmp = t_0 + (x + (t_0 * ((-1.0d0) / y)))
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 t_0 = (1.0 - x) / y;
double tmp;
if ((y <= -290000.0) || !(y <= 255000.0)) {
tmp = t_0 + (x + (t_0 * (-1.0 / y)));
} else {
tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0));
}
return tmp;
}
def code(x, y): t_0 = (1.0 - x) / y tmp = 0 if (y <= -290000.0) or not (y <= 255000.0): tmp = t_0 + (x + (t_0 * (-1.0 / y))) else: tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)) return tmp
function code(x, y) t_0 = Float64(Float64(1.0 - x) / y) tmp = 0.0 if ((y <= -290000.0) || !(y <= 255000.0)) tmp = Float64(t_0 + Float64(x + Float64(t_0 * Float64(-1.0 / y)))); 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) t_0 = (1.0 - x) / y; tmp = 0.0; if ((y <= -290000.0) || ~((y <= 255000.0))) tmp = t_0 + (x + (t_0 * (-1.0 / y))); else tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]}, If[Or[LessEqual[y, -290000.0], N[Not[LessEqual[y, 255000.0]], $MachinePrecision]], N[(t$95$0 + N[(x + N[(t$95$0 * N[(-1.0 / y), $MachinePrecision]), $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}
t_0 := \frac{1 - x}{y}\\
\mathbf{if}\;y \leq -290000 \lor \neg \left(y \leq 255000\right):\\
\;\;\;\;t\_0 + \left(x + t\_0 \cdot \frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{y \cdot \left(x + -1\right)}{y + 1}\\
\end{array}
\end{array}
if y < -2.9e5 or 255000 < y Initial program 29.5%
associate-*l/52.0%
+-commutative52.0%
Simplified52.0%
Taylor expanded in y around inf 99.9%
associate-+r+99.9%
neg-mul-199.9%
sub-neg99.9%
associate--l+99.9%
associate-*r/99.9%
neg-mul-199.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
div-sub99.9%
Simplified99.9%
*-un-lft-identity99.9%
unpow299.9%
times-frac99.9%
Applied egg-rr99.9%
if -2.9e5 < y < 255000Initial program 99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= y -130000000.0) (not (<= y 160000000.0))) (+ x (/ (- 1.0 x) y)) (+ 1.0 (* y (/ (+ x -1.0) (+ y 1.0))))))
double code(double x, double y) {
double tmp;
if ((y <= -130000000.0) || !(y <= 160000000.0)) {
tmp = x + ((1.0 - x) / y);
} 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 <= (-130000000.0d0)) .or. (.not. (y <= 160000000.0d0))) then
tmp = x + ((1.0d0 - x) / y)
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 <= -130000000.0) || !(y <= 160000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -130000000.0) or not (y <= 160000000.0): tmp = x + ((1.0 - x) / y) else: tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0))) return tmp
function code(x, y) tmp = 0.0 if ((y <= -130000000.0) || !(y <= 160000000.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(1.0 + Float64(y * Float64(Float64(x + -1.0) / Float64(y + 1.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -130000000.0) || ~((y <= 160000000.0))) tmp = x + ((1.0 - x) / y); else tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -130000000.0], N[Not[LessEqual[y, 160000000.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * N[(N[(x + -1.0), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -130000000 \lor \neg \left(y \leq 160000000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\
\end{array}
\end{array}
if y < -1.3e8 or 1.6e8 < y Initial program 28.7%
associate-*l/51.5%
+-commutative51.5%
Simplified51.5%
Taylor expanded in y around inf 99.9%
associate--l+99.9%
div-sub99.9%
Simplified99.9%
if -1.3e8 < y < 1.6e8Initial program 99.7%
associate-*l/99.7%
+-commutative99.7%
Simplified99.7%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= y -37000000.0) (not (<= y 255000000.0))) (+ x (/ (- 1.0 x) y)) (+ 1.0 (/ (* y (+ x -1.0)) (+ y 1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -37000000.0) || !(y <= 255000000.0)) {
tmp = x + ((1.0 - x) / y);
} 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 <= (-37000000.0d0)) .or. (.not. (y <= 255000000.0d0))) then
tmp = x + ((1.0d0 - x) / y)
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 <= -37000000.0) || !(y <= 255000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -37000000.0) or not (y <= 255000000.0): tmp = x + ((1.0 - x) / y) else: tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -37000000.0) || !(y <= 255000000.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); 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 <= -37000000.0) || ~((y <= 255000000.0))) tmp = x + ((1.0 - x) / y); else tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -37000000.0], N[Not[LessEqual[y, 255000000.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $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 -37000000 \lor \neg \left(y \leq 255000000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{y \cdot \left(x + -1\right)}{y + 1}\\
\end{array}
\end{array}
if y < -3.7e7 or 2.55e8 < y Initial program 28.7%
associate-*l/51.5%
+-commutative51.5%
Simplified51.5%
Taylor expanded in y around inf 99.9%
associate--l+99.9%
div-sub99.9%
Simplified99.9%
if -3.7e7 < y < 2.55e8Initial program 99.7%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= y -3100.0) (not (<= y 700000.0))) (+ x (/ (- 1.0 x) y)) (- 1.0 (* y (/ x (- -1.0 y))))))
double code(double x, double y) {
double tmp;
if ((y <= -3100.0) || !(y <= 700000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 - (y * (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 <= (-3100.0d0)) .or. (.not. (y <= 700000.0d0))) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = 1.0d0 - (y * (x / ((-1.0d0) - y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -3100.0) || !(y <= 700000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 - (y * (x / (-1.0 - y)));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -3100.0) or not (y <= 700000.0): tmp = x + ((1.0 - x) / y) else: tmp = 1.0 - (y * (x / (-1.0 - y))) return tmp
function code(x, y) tmp = 0.0 if ((y <= -3100.0) || !(y <= 700000.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(1.0 - Float64(y * Float64(x / Float64(-1.0 - y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -3100.0) || ~((y <= 700000.0))) tmp = x + ((1.0 - x) / y); else tmp = 1.0 - (y * (x / (-1.0 - y))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -3100.0], N[Not[LessEqual[y, 700000.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(y * N[(x / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3100 \lor \neg \left(y \leq 700000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 - y \cdot \frac{x}{-1 - y}\\
\end{array}
\end{array}
if y < -3100 or 7e5 < y Initial program 29.0%
associate-*l/51.7%
+-commutative51.7%
Simplified51.7%
Taylor expanded in y around inf 99.5%
associate--l+99.5%
div-sub99.5%
Simplified99.5%
if -3100 < y < 7e5Initial program 99.9%
associate-*l/99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 97.9%
neg-mul-197.9%
distribute-neg-frac97.9%
Simplified97.9%
frac-2neg97.9%
remove-double-neg97.9%
associate-*l/97.9%
+-commutative97.9%
distribute-neg-in97.9%
metadata-eval97.9%
Applied egg-rr97.9%
associate-/l*97.9%
associate-/r/97.9%
+-commutative97.9%
unsub-neg97.9%
Simplified97.9%
Final simplification98.7%
(FPCore (x y) :precision binary64 (if (or (<= y -0.007) (not (<= y 1.4e-6))) (* x (/ y (+ y 1.0))) (+ 1.0 (* y x))))
double code(double x, double y) {
double tmp;
if ((y <= -0.007) || !(y <= 1.4e-6)) {
tmp = x * (y / (y + 1.0));
} 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 <= (-0.007d0)) .or. (.not. (y <= 1.4d-6))) then
tmp = x * (y / (y + 1.0d0))
else
tmp = 1.0d0 + (y * x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -0.007) || !(y <= 1.4e-6)) {
tmp = x * (y / (y + 1.0));
} else {
tmp = 1.0 + (y * x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -0.007) or not (y <= 1.4e-6): tmp = x * (y / (y + 1.0)) else: tmp = 1.0 + (y * x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -0.007) || !(y <= 1.4e-6)) tmp = Float64(x * Float64(y / Float64(y + 1.0))); else tmp = Float64(1.0 + Float64(y * x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -0.007) || ~((y <= 1.4e-6))) tmp = x * (y / (y + 1.0)); else tmp = 1.0 + (y * x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -0.007], N[Not[LessEqual[y, 1.4e-6]], $MachinePrecision]], N[(x * N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.007 \lor \neg \left(y \leq 1.4 \cdot 10^{-6}\right):\\
\;\;\;\;x \cdot \frac{y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot x\\
\end{array}
\end{array}
if y < -0.00700000000000000015 or 1.39999999999999994e-6 < y Initial program 32.0%
associate-*l/53.7%
+-commutative53.7%
Simplified53.7%
Taylor expanded in x around inf 56.1%
associate-*r/78.0%
*-commutative78.0%
Simplified78.0%
if -0.00700000000000000015 < y < 1.39999999999999994e-6Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 98.5%
neg-mul-198.5%
distribute-neg-frac98.5%
Simplified98.5%
Taylor expanded in y around 0 98.0%
+-commutative98.0%
Simplified98.0%
Final simplification87.0%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.2))) (+ x (/ (- 1.0 x) y)) (+ 1.0 (* y x))))
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 + (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.2d0))) then
tmp = x + ((1.0d0 - x) / 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.2)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + (y * x);
}
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 + (y * x) 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(y * x)); 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 + (y * x); 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[(y * x), $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 + y \cdot x\\
\end{array}
\end{array}
if y < -1 or 1.19999999999999996 < y Initial program 30.5%
associate-*l/52.7%
+-commutative52.7%
Simplified52.7%
Taylor expanded in y around inf 98.3%
associate--l+98.3%
div-sub98.3%
Simplified98.3%
if -1 < y < 1.19999999999999996Initial program 99.9%
associate-*l/99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 97.9%
neg-mul-197.9%
distribute-neg-frac97.9%
Simplified97.9%
Taylor expanded in y around 0 96.1%
+-commutative96.1%
Simplified96.1%
Final simplification97.3%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.1))) (+ 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.1)) {
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.1d0))) 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.1)) {
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.1): 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.1)) 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.1))) 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.1]], $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.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.1000000000000001 < y Initial program 30.5%
associate-*l/52.7%
+-commutative52.7%
Simplified52.7%
Taylor expanded in y around inf 98.3%
associate--l+98.3%
div-sub98.3%
Simplified98.3%
if -1 < y < 1.1000000000000001Initial program 99.9%
associate-*l/99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 96.8%
Final simplification97.6%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 4.5))) (- x (/ x y)) (+ 1.0 (* y x))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 4.5)) {
tmp = x - (x / 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 <= 4.5d0))) then
tmp = x - (x / 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 <= 4.5)) {
tmp = x - (x / y);
} else {
tmp = 1.0 + (y * x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 4.5): tmp = x - (x / y) else: tmp = 1.0 + (y * x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 4.5)) tmp = Float64(x - Float64(x / 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 <= 4.5))) tmp = x - (x / 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, 4.5]], $MachinePrecision]], N[(x - N[(x / 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 4.5\right):\\
\;\;\;\;x - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot x\\
\end{array}
\end{array}
if y < -1 or 4.5 < y Initial program 30.5%
associate-*l/52.7%
+-commutative52.7%
Simplified52.7%
Taylor expanded in x around inf 55.9%
associate-*r/78.2%
*-commutative78.2%
Simplified78.2%
Taylor expanded in y around inf 77.0%
mul-1-neg77.0%
unsub-neg77.0%
Simplified77.0%
if -1 < y < 4.5Initial program 99.9%
associate-*l/99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 97.9%
neg-mul-197.9%
distribute-neg-frac97.9%
Simplified97.9%
Taylor expanded in y around 0 96.1%
+-commutative96.1%
Simplified96.1%
Final simplification85.8%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 14.0) (+ 1.0 (* y x)) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 14.0) {
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 <= (-1.0d0)) then
tmp = x
else if (y <= 14.0d0) 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 <= -1.0) {
tmp = x;
} else if (y <= 14.0) {
tmp = 1.0 + (y * x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 14.0: tmp = 1.0 + (y * x) else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 14.0) 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 <= -1.0) tmp = x; elseif (y <= 14.0) tmp = 1.0 + (y * x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 14.0], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 14:\\
\;\;\;\;1 + y \cdot x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 14 < y Initial program 30.5%
associate-*l/52.7%
+-commutative52.7%
Simplified52.7%
Taylor expanded in y around inf 76.7%
if -1 < y < 14Initial program 99.9%
associate-*l/99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 97.9%
neg-mul-197.9%
distribute-neg-frac97.9%
Simplified97.9%
Taylor expanded in y around 0 96.1%
+-commutative96.1%
Simplified96.1%
Final simplification85.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.0038) (- 1.0 y) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.0038) {
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.0038d0) 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.0038) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.0038: 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.0038) 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.0038) 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.0038], N[(1.0 - y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.0038:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.00379999999999999999 < y Initial program 31.0%
associate-*l/53.0%
+-commutative53.0%
Simplified53.0%
Taylor expanded in y around inf 76.2%
if -1 < y < 0.00379999999999999999Initial program 100.0%
Taylor expanded in x around 0 79.1%
Taylor expanded in y around 0 77.7%
neg-mul-177.7%
sub-neg77.7%
Simplified77.7%
Final simplification76.9%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 7e-5) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 7e-5) {
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 <= 7d-5) 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 <= 7e-5) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 7e-5: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 7e-5) 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 <= 7e-5) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 7e-5], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-5}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 6.9999999999999994e-5 < y Initial program 31.0%
associate-*l/53.0%
+-commutative53.0%
Simplified53.0%
Taylor expanded in y around inf 76.2%
if -1 < y < 6.9999999999999994e-5Initial program 100.0%
associate-*l/99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 77.0%
Final simplification76.6%
(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 62.5%
associate-*l/74.5%
+-commutative74.5%
Simplified74.5%
Taylor expanded in y around 0 37.1%
Final simplification37.1%
(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 2024027
(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))))