
(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 10 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) (+ 1.0 y))) (t_1 (/ y (+ 1.0 y))))
(if (<= t_0 0.9995)
(+ 1.0 (* t_1 (+ x -1.0)))
(if (<= t_0 1.0)
(+ x (/ (- 1.0 x) y))
(* x (- (/ 1.0 x) (fma -1.0 t_1 (/ (/ y x) (+ 1.0 y)))))))))
double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (1.0 + y);
double t_1 = y / (1.0 + y);
double tmp;
if (t_0 <= 0.9995) {
tmp = 1.0 + (t_1 * (x + -1.0));
} else if (t_0 <= 1.0) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = x * ((1.0 / x) - fma(-1.0, t_1, ((y / x) / (1.0 + y))));
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(1.0 + y)) t_1 = Float64(y / Float64(1.0 + y)) tmp = 0.0 if (t_0 <= 0.9995) tmp = Float64(1.0 + Float64(t_1 * Float64(x + -1.0))); elseif (t_0 <= 1.0) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(x * Float64(Float64(1.0 / x) - fma(-1.0, t_1, Float64(Float64(y / x) / Float64(1.0 + y))))); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.9995], N[(1.0 + N[(t$95$1 * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(1.0 / x), $MachinePrecision] - N[(-1.0 * t$95$1 + N[(N[(y / x), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{1 + y}\\
t_1 := \frac{y}{1 + y}\\
\mathbf{if}\;t\_0 \leq 0.9995:\\
\;\;\;\;1 + t\_1 \cdot \left(x + -1\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{1}{x} - \mathsf{fma}\left(-1, t\_1, \frac{\frac{y}{x}}{1 + y}\right)\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 0.99950000000000006Initial program 91.9%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
if 0.99950000000000006 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1Initial program 5.0%
associate-/l*5.0%
+-commutative5.0%
Simplified5.0%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
div-sub100.0%
Simplified100.0%
if 1 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) Initial program 70.0%
associate-/l*96.6%
+-commutative96.6%
Simplified96.6%
Taylor expanded in x around inf 97.6%
fma-define97.6%
associate-/r*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (- 1.0 x) y) (+ 1.0 y))) (t_1 (/ y (+ 1.0 y))))
(if (<= t_0 0.9995)
(+ 1.0 (* t_1 (+ x -1.0)))
(if (<= t_0 1.0) (+ x (/ (- 1.0 x) y)) (* x (+ t_1 (/ (- 1.0 t_1) x)))))))
double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (1.0 + y);
double t_1 = y / (1.0 + y);
double tmp;
if (t_0 <= 0.9995) {
tmp = 1.0 + (t_1 * (x + -1.0));
} else if (t_0 <= 1.0) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = x * (t_1 + ((1.0 - t_1) / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((1.0d0 - x) * y) / (1.0d0 + y)
t_1 = y / (1.0d0 + y)
if (t_0 <= 0.9995d0) then
tmp = 1.0d0 + (t_1 * (x + (-1.0d0)))
else if (t_0 <= 1.0d0) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = x * (t_1 + ((1.0d0 - t_1) / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (1.0 + y);
double t_1 = y / (1.0 + y);
double tmp;
if (t_0 <= 0.9995) {
tmp = 1.0 + (t_1 * (x + -1.0));
} else if (t_0 <= 1.0) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = x * (t_1 + ((1.0 - t_1) / x));
}
return tmp;
}
def code(x, y): t_0 = ((1.0 - x) * y) / (1.0 + y) t_1 = y / (1.0 + y) tmp = 0 if t_0 <= 0.9995: tmp = 1.0 + (t_1 * (x + -1.0)) elif t_0 <= 1.0: tmp = x + ((1.0 - x) / y) else: tmp = x * (t_1 + ((1.0 - t_1) / x)) return tmp
function code(x, y) t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(1.0 + y)) t_1 = Float64(y / Float64(1.0 + y)) tmp = 0.0 if (t_0 <= 0.9995) tmp = Float64(1.0 + Float64(t_1 * Float64(x + -1.0))); elseif (t_0 <= 1.0) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(x * Float64(t_1 + Float64(Float64(1.0 - t_1) / x))); end return tmp end
function tmp_2 = code(x, y) t_0 = ((1.0 - x) * y) / (1.0 + y); t_1 = y / (1.0 + y); tmp = 0.0; if (t_0 <= 0.9995) tmp = 1.0 + (t_1 * (x + -1.0)); elseif (t_0 <= 1.0) tmp = x + ((1.0 - x) / y); else tmp = x * (t_1 + ((1.0 - t_1) / x)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.9995], N[(1.0 + N[(t$95$1 * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(t$95$1 + N[(N[(1.0 - t$95$1), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{1 + y}\\
t_1 := \frac{y}{1 + y}\\
\mathbf{if}\;t\_0 \leq 0.9995:\\
\;\;\;\;1 + t\_1 \cdot \left(x + -1\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(t\_1 + \frac{1 - t\_1}{x}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 0.99950000000000006Initial program 91.9%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
if 0.99950000000000006 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1Initial program 5.0%
associate-/l*5.0%
+-commutative5.0%
Simplified5.0%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
div-sub100.0%
Simplified100.0%
if 1 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) Initial program 70.0%
associate-/l*96.6%
+-commutative96.6%
Simplified96.6%
Taylor expanded in x around inf 97.6%
associate--r+97.6%
cancel-sign-sub-inv97.6%
metadata-eval97.6%
*-lft-identity97.6%
+-commutative97.6%
associate-/l/99.9%
associate-+r-99.9%
div-sub99.9%
sub-neg99.9%
distribute-neg-frac299.9%
distribute-neg-in99.9%
metadata-eval99.9%
sub-neg99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (- 1.0 x) y) (+ 1.0 y))))
(if (or (<= t_0 0.9995) (not (<= t_0 1.05)))
(+ 1.0 (* (/ y (+ 1.0 y)) (+ x -1.0)))
(+ x (/ (- 1.0 x) y)))))
double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (1.0 + y);
double tmp;
if ((t_0 <= 0.9995) || !(t_0 <= 1.05)) {
tmp = 1.0 + ((y / (1.0 + y)) * (x + -1.0));
} else {
tmp = x + ((1.0 - x) / y);
}
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) / (1.0d0 + y)
if ((t_0 <= 0.9995d0) .or. (.not. (t_0 <= 1.05d0))) then
tmp = 1.0d0 + ((y / (1.0d0 + y)) * (x + (-1.0d0)))
else
tmp = x + ((1.0d0 - x) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (1.0 + y);
double tmp;
if ((t_0 <= 0.9995) || !(t_0 <= 1.05)) {
tmp = 1.0 + ((y / (1.0 + y)) * (x + -1.0));
} else {
tmp = x + ((1.0 - x) / y);
}
return tmp;
}
def code(x, y): t_0 = ((1.0 - x) * y) / (1.0 + y) tmp = 0 if (t_0 <= 0.9995) or not (t_0 <= 1.05): tmp = 1.0 + ((y / (1.0 + y)) * (x + -1.0)) else: tmp = x + ((1.0 - x) / y) return tmp
function code(x, y) t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(1.0 + y)) tmp = 0.0 if ((t_0 <= 0.9995) || !(t_0 <= 1.05)) tmp = Float64(1.0 + Float64(Float64(y / Float64(1.0 + y)) * Float64(x + -1.0))); else tmp = Float64(x + Float64(Float64(1.0 - x) / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = ((1.0 - x) * y) / (1.0 + y); tmp = 0.0; if ((t_0 <= 0.9995) || ~((t_0 <= 1.05))) tmp = 1.0 + ((y / (1.0 + y)) * (x + -1.0)); else tmp = x + ((1.0 - x) / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, 0.9995], N[Not[LessEqual[t$95$0, 1.05]], $MachinePrecision]], N[(1.0 + N[(N[(y / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{1 + y}\\
\mathbf{if}\;t\_0 \leq 0.9995 \lor \neg \left(t\_0 \leq 1.05\right):\\
\;\;\;\;1 + \frac{y}{1 + y} \cdot \left(x + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1 - x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 0.99950000000000006 or 1.05000000000000004 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) Initial program 87.1%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
if 0.99950000000000006 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1.05000000000000004Initial program 6.8%
associate-/l*6.9%
+-commutative6.9%
Simplified6.9%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
div-sub100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= y -17.0) (not (<= y 58.0))) (+ x (/ (- 1.0 x) y)) (* x (+ (/ y (+ 1.0 y)) (/ 1.0 x)))))
double code(double x, double y) {
double tmp;
if ((y <= -17.0) || !(y <= 58.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = x * ((y / (1.0 + y)) + (1.0 / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-17.0d0)) .or. (.not. (y <= 58.0d0))) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = x * ((y / (1.0d0 + y)) + (1.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -17.0) || !(y <= 58.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = x * ((y / (1.0 + y)) + (1.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -17.0) or not (y <= 58.0): tmp = x + ((1.0 - x) / y) else: tmp = x * ((y / (1.0 + y)) + (1.0 / x)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -17.0) || !(y <= 58.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(x * Float64(Float64(y / Float64(1.0 + y)) + Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -17.0) || ~((y <= 58.0))) tmp = x + ((1.0 - x) / y); else tmp = x * ((y / (1.0 + y)) + (1.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -17.0], N[Not[LessEqual[y, 58.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(y / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -17 \lor \neg \left(y \leq 58\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{y}{1 + y} + \frac{1}{x}\right)\\
\end{array}
\end{array}
if y < -17 or 58 < y Initial program 30.2%
associate-/l*48.2%
+-commutative48.2%
Simplified48.2%
Taylor expanded in y around inf 98.3%
associate--l+98.3%
div-sub98.3%
Simplified98.3%
if -17 < y < 58Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 99.8%
associate--r+99.8%
cancel-sign-sub-inv99.8%
metadata-eval99.8%
*-lft-identity99.8%
+-commutative99.8%
associate-/l/99.8%
associate-+r-99.8%
div-sub99.8%
sub-neg99.8%
distribute-neg-frac299.8%
distribute-neg-in99.8%
metadata-eval99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in y around 0 98.6%
Final simplification98.5%
(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 30.7%
associate-/l*48.6%
+-commutative48.6%
Simplified48.6%
Taylor expanded in y around inf 97.7%
associate--l+97.7%
div-sub97.7%
Simplified97.7%
if -1 < y < 1Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 98.6%
Final simplification98.2%
(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 30.7%
associate-/l*48.6%
+-commutative48.6%
Simplified48.6%
Taylor expanded in y around inf 97.7%
associate--l+97.7%
div-sub97.7%
Simplified97.7%
if -1 < y < 1.19999999999999996Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 99.8%
associate--r+99.8%
cancel-sign-sub-inv99.8%
metadata-eval99.8%
*-lft-identity99.8%
+-commutative99.8%
associate-/l/99.8%
associate-+r-99.8%
div-sub99.8%
sub-neg99.8%
distribute-neg-frac299.8%
distribute-neg-in99.8%
metadata-eval99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in y around 0 98.6%
Taylor expanded in y around 0 98.4%
Final simplification98.1%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 3e+20) (+ 1.0 (* x y)) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 3e+20) {
tmp = 1.0 + (x * 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 <= 3d+20) then
tmp = 1.0d0 + (x * 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 <= 3e+20) {
tmp = 1.0 + (x * y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 3e+20: tmp = 1.0 + (x * y) else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 3e+20) tmp = Float64(1.0 + Float64(x * 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 <= 3e+20) tmp = 1.0 + (x * y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 3e+20], N[(1.0 + N[(x * y), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+20}:\\
\;\;\;\;1 + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 3e20 < y Initial program 29.7%
associate-/l*48.3%
+-commutative48.3%
Simplified48.3%
Taylor expanded in y around inf 76.2%
if -1 < y < 3e20Initial program 98.3%
associate-/l*98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in x around inf 98.1%
associate--r+98.1%
cancel-sign-sub-inv98.1%
metadata-eval98.1%
*-lft-identity98.1%
+-commutative98.1%
associate-/l/98.1%
associate-+r-98.1%
div-sub98.1%
sub-neg98.1%
distribute-neg-frac298.1%
distribute-neg-in98.1%
metadata-eval98.1%
sub-neg98.1%
Simplified98.1%
Taylor expanded in y around 0 96.0%
Taylor expanded in y around 0 95.1%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.9) (- 1.0 y) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.9) {
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.9d0) 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.9) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.9: 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.9) 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.9) 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.9], N[(1.0 - y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.9:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.900000000000000022 < y Initial program 30.7%
associate-/l*48.6%
+-commutative48.6%
Simplified48.6%
Taylor expanded in y around inf 73.6%
if -1 < y < 0.900000000000000022Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 75.0%
Taylor expanded in y around 0 74.0%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 3e+20) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 3e+20) {
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 <= 3d+20) 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 <= 3e+20) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 3e+20: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 3e+20) 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 <= 3e+20) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 3e+20], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+20}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 3e20 < y Initial program 29.7%
associate-/l*48.3%
+-commutative48.3%
Simplified48.3%
Taylor expanded in y around inf 76.2%
if -1 < y < 3e20Initial program 98.3%
associate-/l*98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in y around 0 71.4%
(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.6%
associate-/l*73.7%
+-commutative73.7%
Simplified73.7%
Taylor expanded in y around 0 38.0%
(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 2024088
(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))))