
(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 9 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 -12000.0) (not (<= y 14500.0))) (+ x (/ (- (- (/ (+ (/ (- 1.0 x) y) (+ x -1.0)) y) -1.0) x) y)) (+ 1.0 (* (- 1.0 x) (/ y (- -1.0 y))))))
double code(double x, double y) {
double tmp;
if ((y <= -12000.0) || !(y <= 14500.0)) {
tmp = x + (((((((1.0 - x) / y) + (x + -1.0)) / y) - -1.0) - x) / y);
} else {
tmp = 1.0 + ((1.0 - x) * (y / (-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)) .or. (.not. (y <= 14500.0d0))) then
tmp = x + (((((((1.0d0 - x) / y) + (x + (-1.0d0))) / y) - (-1.0d0)) - x) / y)
else
tmp = 1.0d0 + ((1.0d0 - x) * (y / ((-1.0d0) - y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -12000.0) || !(y <= 14500.0)) {
tmp = x + (((((((1.0 - x) / y) + (x + -1.0)) / y) - -1.0) - x) / y);
} else {
tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -12000.0) or not (y <= 14500.0): tmp = x + (((((((1.0 - x) / y) + (x + -1.0)) / y) - -1.0) - x) / y) else: tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y))) return tmp
function code(x, y) tmp = 0.0 if ((y <= -12000.0) || !(y <= 14500.0)) tmp = Float64(x + Float64(Float64(Float64(Float64(Float64(Float64(Float64(1.0 - x) / y) + Float64(x + -1.0)) / y) - -1.0) - x) / y)); else tmp = Float64(1.0 + Float64(Float64(1.0 - x) * Float64(y / Float64(-1.0 - y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -12000.0) || ~((y <= 14500.0))) tmp = x + (((((((1.0 - x) / y) + (x + -1.0)) / y) - -1.0) - x) / y); else tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -12000.0], N[Not[LessEqual[y, 14500.0]], $MachinePrecision]], N[(x + N[(N[(N[(N[(N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] + N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] - -1.0), $MachinePrecision] - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(1.0 - x), $MachinePrecision] * N[(y / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -12000 \lor \neg \left(y \leq 14500\right):\\
\;\;\;\;x + \frac{\left(\frac{\frac{1 - x}{y} + \left(x + -1\right)}{y} - -1\right) - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(1 - x\right) \cdot \frac{y}{-1 - y}\\
\end{array}
\end{array}
if y < -12000 or 14500 < y Initial program 27.4%
associate-/l*48.5%
remove-double-neg48.5%
remove-double-neg48.5%
+-commutative48.5%
Simplified48.5%
Taylor expanded in y around -inf 100.0%
Simplified100.0%
if -12000 < y < 14500Initial program 99.9%
associate-/l*99.9%
remove-double-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= y -8.2e+24)
(+ x (/ (- 1.0 x) y))
(if (<= y 390000.0)
(+ 1.0 (* (- 1.0 x) (/ y (- -1.0 y))))
(+ x (/ (+ (- 1.0 x) (/ (+ x -1.0) y)) y)))))
double code(double x, double y) {
double tmp;
if (y <= -8.2e+24) {
tmp = x + ((1.0 - x) / y);
} else if (y <= 390000.0) {
tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
} else {
tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-8.2d+24)) then
tmp = x + ((1.0d0 - x) / y)
else if (y <= 390000.0d0) then
tmp = 1.0d0 + ((1.0d0 - x) * (y / ((-1.0d0) - y)))
else
tmp = x + (((1.0d0 - x) + ((x + (-1.0d0)) / y)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -8.2e+24) {
tmp = x + ((1.0 - x) / y);
} else if (y <= 390000.0) {
tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
} else {
tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8.2e+24: tmp = x + ((1.0 - x) / y) elif y <= 390000.0: tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y))) else: tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -8.2e+24) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); elseif (y <= 390000.0) tmp = Float64(1.0 + Float64(Float64(1.0 - x) * Float64(y / Float64(-1.0 - y)))); else tmp = Float64(x + Float64(Float64(Float64(1.0 - x) + Float64(Float64(x + -1.0) / y)) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -8.2e+24) tmp = x + ((1.0 - x) / y); elseif (y <= 390000.0) tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y))); else tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -8.2e+24], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 390000.0], N[(1.0 + N[(N[(1.0 - x), $MachinePrecision] * N[(y / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+24}:\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{elif}\;y \leq 390000:\\
\;\;\;\;1 + \left(1 - x\right) \cdot \frac{y}{-1 - y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\left(1 - x\right) + \frac{x + -1}{y}}{y}\\
\end{array}
\end{array}
if y < -8.2000000000000002e24Initial program 29.3%
associate-/l*52.1%
remove-double-neg52.1%
remove-double-neg52.1%
+-commutative52.1%
Simplified52.1%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
div-sub100.0%
Simplified100.0%
if -8.2000000000000002e24 < y < 3.9e5Initial program 99.9%
associate-/l*99.9%
remove-double-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
Simplified99.9%
if 3.9e5 < y Initial program 21.7%
associate-/l*42.2%
remove-double-neg42.2%
remove-double-neg42.2%
+-commutative42.2%
Simplified42.2%
Taylor expanded in y around inf 99.6%
Simplified99.6%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= y -8.2e+24) (not (<= y 135000000.0))) (+ x (/ (- 1.0 x) y)) (+ 1.0 (* (- 1.0 x) (/ y (- -1.0 y))))))
double code(double x, double y) {
double tmp;
if ((y <= -8.2e+24) || !(y <= 135000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + ((1.0 - x) * (y / (-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 <= (-8.2d+24)) .or. (.not. (y <= 135000000.0d0))) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = 1.0d0 + ((1.0d0 - x) * (y / ((-1.0d0) - y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -8.2e+24) || !(y <= 135000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -8.2e+24) or not (y <= 135000000.0): tmp = x + ((1.0 - x) / y) else: tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y))) return tmp
function code(x, y) tmp = 0.0 if ((y <= -8.2e+24) || !(y <= 135000000.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(1.0 + Float64(Float64(1.0 - x) * Float64(y / Float64(-1.0 - y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -8.2e+24) || ~((y <= 135000000.0))) tmp = x + ((1.0 - x) / y); else tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -8.2e+24], N[Not[LessEqual[y, 135000000.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(1.0 - x), $MachinePrecision] * N[(y / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+24} \lor \neg \left(y \leq 135000000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(1 - x\right) \cdot \frac{y}{-1 - y}\\
\end{array}
\end{array}
if y < -8.2000000000000002e24 or 1.35e8 < y Initial program 25.2%
associate-/l*47.0%
remove-double-neg47.0%
remove-double-neg47.0%
+-commutative47.0%
Simplified47.0%
Taylor expanded in y around inf 99.9%
associate--l+99.9%
div-sub99.9%
Simplified99.9%
if -8.2000000000000002e24 < y < 1.35e8Initial program 99.7%
associate-/l*99.7%
remove-double-neg99.7%
remove-double-neg99.7%
+-commutative99.7%
Simplified99.7%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= y -9200.0) (not (<= y 1750000.0))) (+ x (/ (- 1.0 x) y)) (/ -1.0 (- -1.0 y))))
double code(double x, double y) {
double tmp;
if ((y <= -9200.0) || !(y <= 1750000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = -1.0 / (-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 <= (-9200.0d0)) .or. (.not. (y <= 1750000.0d0))) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = (-1.0d0) / ((-1.0d0) - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -9200.0) || !(y <= 1750000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = -1.0 / (-1.0 - y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -9200.0) or not (y <= 1750000.0): tmp = x + ((1.0 - x) / y) else: tmp = -1.0 / (-1.0 - y) return tmp
function code(x, y) tmp = 0.0 if ((y <= -9200.0) || !(y <= 1750000.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(-1.0 / Float64(-1.0 - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -9200.0) || ~((y <= 1750000.0))) tmp = x + ((1.0 - x) / y); else tmp = -1.0 / (-1.0 - y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -9200.0], N[Not[LessEqual[y, 1750000.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9200 \lor \neg \left(y \leq 1750000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{-1 - y}\\
\end{array}
\end{array}
if y < -9200 or 1.75e6 < y Initial program 27.0%
associate-/l*48.3%
remove-double-neg48.3%
remove-double-neg48.3%
+-commutative48.3%
Simplified48.3%
Taylor expanded in y around inf 99.6%
associate--l+99.6%
div-sub99.6%
Simplified99.6%
if -9200 < y < 1.75e6Initial program 99.7%
associate-/l*99.7%
remove-double-neg99.7%
remove-double-neg99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in x around inf 99.5%
Taylor expanded in x around inf 99.5%
frac-add99.5%
sub-div99.8%
*-un-lft-identity99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
fma-define99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 84.3%
Final simplification91.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 29.0%
associate-/l*49.7%
remove-double-neg49.7%
remove-double-neg49.7%
+-commutative49.7%
Simplified49.7%
Taylor expanded in y around inf 97.5%
associate--l+97.5%
div-sub97.5%
Simplified97.5%
if -1 < y < 1Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 99.4%
Final simplification98.5%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 9.8))) (- x (/ x y)) 1.0))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 9.8)) {
tmp = x - (x / y);
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-1.0d0)) .or. (.not. (y <= 9.8d0))) then
tmp = x - (x / y)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 9.8)) {
tmp = x - (x / y);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 9.8): tmp = x - (x / y) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 9.8)) tmp = Float64(x - Float64(x / y)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 9.8))) tmp = x - (x / y); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 9.8]], $MachinePrecision]], N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 9.8\right):\\
\;\;\;\;x - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 9.8000000000000007 < y Initial program 29.0%
associate-/l*49.7%
remove-double-neg49.7%
remove-double-neg49.7%
+-commutative49.7%
Simplified49.7%
Taylor expanded in x around inf 51.3%
Taylor expanded in y around inf 71.2%
neg-mul-171.2%
unsub-neg71.2%
Simplified71.2%
if -1 < y < 9.8000000000000007Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 84.0%
Final simplification77.7%
(FPCore (x y) :precision binary64 (if (<= y -18000.0) (- x (/ x y)) (if (<= y 7.8e+95) (/ -1.0 (- -1.0 y)) x)))
double code(double x, double y) {
double tmp;
if (y <= -18000.0) {
tmp = x - (x / y);
} else if (y <= 7.8e+95) {
tmp = -1.0 / (-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 <= (-18000.0d0)) then
tmp = x - (x / y)
else if (y <= 7.8d+95) then
tmp = (-1.0d0) / ((-1.0d0) - y)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -18000.0) {
tmp = x - (x / y);
} else if (y <= 7.8e+95) {
tmp = -1.0 / (-1.0 - y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -18000.0: tmp = x - (x / y) elif y <= 7.8e+95: tmp = -1.0 / (-1.0 - y) else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -18000.0) tmp = Float64(x - Float64(x / y)); elseif (y <= 7.8e+95) tmp = Float64(-1.0 / Float64(-1.0 - y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -18000.0) tmp = x - (x / y); elseif (y <= 7.8e+95) tmp = -1.0 / (-1.0 - y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -18000.0], N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.8e+95], N[(-1.0 / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -18000:\\
\;\;\;\;x - \frac{x}{y}\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{+95}:\\
\;\;\;\;\frac{-1}{-1 - y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -18000Initial program 32.6%
associate-/l*54.3%
remove-double-neg54.3%
remove-double-neg54.3%
+-commutative54.3%
Simplified54.3%
Taylor expanded in x around inf 54.9%
Taylor expanded in y around inf 76.1%
neg-mul-176.1%
unsub-neg76.1%
Simplified76.1%
if -18000 < y < 7.7999999999999994e95Initial program 91.6%
associate-/l*91.6%
remove-double-neg91.6%
remove-double-neg91.6%
+-commutative91.6%
Simplified91.6%
Taylor expanded in x around inf 91.5%
Taylor expanded in x around inf 91.5%
frac-add91.3%
sub-div92.0%
*-un-lft-identity92.0%
+-commutative92.0%
associate-+l+92.0%
+-commutative92.0%
fma-define92.0%
Applied egg-rr92.0%
Taylor expanded in x around 0 82.9%
if 7.7999999999999994e95 < y Initial program 17.9%
associate-/l*47.3%
remove-double-neg47.3%
remove-double-neg47.3%
+-commutative47.3%
Simplified47.3%
Taylor expanded in y around inf 85.6%
Final simplification81.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.00033) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.00033) {
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.00033d0) 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.00033) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.00033: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 0.00033) 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.00033) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 0.00033], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.00033:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 3.3e-4 < y Initial program 29.6%
associate-/l*50.0%
remove-double-neg50.0%
remove-double-neg50.0%
+-commutative50.0%
Simplified50.0%
Taylor expanded in y around inf 70.2%
if -1 < y < 3.3e-4Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 84.7%
Final simplification77.5%
(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.8%
associate-/l*75.0%
remove-double-neg75.0%
remove-double-neg75.0%
+-commutative75.0%
Simplified75.0%
Taylor expanded in y around 0 44.2%
Final simplification44.2%
(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 2024053
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:precision binary64
:alt
(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))))