
(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
(let* ((t_0 (/ (- 1.0 x) y)))
(if (<= y -13500.0)
(+ x (/ (+ (- 1.0 x) (/ (+ t_0 (+ x -1.0)) y)) y))
(if (<= y 350000.0)
(fma y (/ (+ x -1.0) (+ y 1.0)) 1.0)
(+ x (/ (- 1.0 (+ x t_0)) y))))))
double code(double x, double y) {
double t_0 = (1.0 - x) / y;
double tmp;
if (y <= -13500.0) {
tmp = x + (((1.0 - x) + ((t_0 + (x + -1.0)) / y)) / y);
} else if (y <= 350000.0) {
tmp = fma(y, ((x + -1.0) / (y + 1.0)), 1.0);
} else {
tmp = x + ((1.0 - (x + t_0)) / y);
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(1.0 - x) / y) tmp = 0.0 if (y <= -13500.0) tmp = Float64(x + Float64(Float64(Float64(1.0 - x) + Float64(Float64(t_0 + Float64(x + -1.0)) / y)) / y)); elseif (y <= 350000.0) tmp = fma(y, Float64(Float64(x + -1.0) / Float64(y + 1.0)), 1.0); else tmp = Float64(x + Float64(Float64(1.0 - Float64(x + t_0)) / y)); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, -13500.0], N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] + N[(N[(t$95$0 + N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 350000.0], N[(y * N[(N[(x + -1.0), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(x + N[(N[(1.0 - N[(x + t$95$0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 - x}{y}\\
\mathbf{if}\;y \leq -13500:\\
\;\;\;\;x + \frac{\left(1 - x\right) + \frac{t\_0 + \left(x + -1\right)}{y}}{y}\\
\mathbf{elif}\;y \leq 350000:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x + -1}{y + 1}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1 - \left(x + t\_0\right)}{y}\\
\end{array}
\end{array}
if y < -13500Initial program 39.9%
associate-/l*54.4%
remove-double-neg54.4%
remove-double-neg54.4%
+-commutative54.4%
Simplified54.4%
Taylor expanded in y around -inf 99.9%
Simplified99.9%
if -13500 < y < 3.5e5Initial 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%
if 3.5e5 < y Initial program 32.6%
associate-/l*54.3%
remove-double-neg54.3%
remove-double-neg54.3%
+-commutative54.3%
Simplified54.3%
Taylor expanded in y around inf 100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- 1.0 x) y)))
(if (<= y -14000.0)
(+ x (/ (+ (- 1.0 x) (/ (+ t_0 (+ x -1.0)) y)) y))
(if (<= y 320000.0)
(+ 1.0 (* (/ y (+ y 1.0)) (+ x -1.0)))
(+ x (/ (- 1.0 (+ x t_0)) y))))))
double code(double x, double y) {
double t_0 = (1.0 - x) / y;
double tmp;
if (y <= -14000.0) {
tmp = x + (((1.0 - x) + ((t_0 + (x + -1.0)) / y)) / y);
} else if (y <= 320000.0) {
tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0));
} else {
tmp = x + ((1.0 - (x + t_0)) / 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
if (y <= (-14000.0d0)) then
tmp = x + (((1.0d0 - x) + ((t_0 + (x + (-1.0d0))) / y)) / y)
else if (y <= 320000.0d0) then
tmp = 1.0d0 + ((y / (y + 1.0d0)) * (x + (-1.0d0)))
else
tmp = x + ((1.0d0 - (x + t_0)) / y)
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 <= -14000.0) {
tmp = x + (((1.0 - x) + ((t_0 + (x + -1.0)) / y)) / y);
} else if (y <= 320000.0) {
tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0));
} else {
tmp = x + ((1.0 - (x + t_0)) / y);
}
return tmp;
}
def code(x, y): t_0 = (1.0 - x) / y tmp = 0 if y <= -14000.0: tmp = x + (((1.0 - x) + ((t_0 + (x + -1.0)) / y)) / y) elif y <= 320000.0: tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0)) else: tmp = x + ((1.0 - (x + t_0)) / y) return tmp
function code(x, y) t_0 = Float64(Float64(1.0 - x) / y) tmp = 0.0 if (y <= -14000.0) tmp = Float64(x + Float64(Float64(Float64(1.0 - x) + Float64(Float64(t_0 + Float64(x + -1.0)) / y)) / y)); elseif (y <= 320000.0) tmp = Float64(1.0 + Float64(Float64(y / Float64(y + 1.0)) * Float64(x + -1.0))); else tmp = Float64(x + Float64(Float64(1.0 - Float64(x + t_0)) / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = (1.0 - x) / y; tmp = 0.0; if (y <= -14000.0) tmp = x + (((1.0 - x) + ((t_0 + (x + -1.0)) / y)) / y); elseif (y <= 320000.0) tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0)); else tmp = x + ((1.0 - (x + t_0)) / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, -14000.0], N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] + N[(N[(t$95$0 + N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 320000.0], N[(1.0 + N[(N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(1.0 - N[(x + t$95$0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 - x}{y}\\
\mathbf{if}\;y \leq -14000:\\
\;\;\;\;x + \frac{\left(1 - x\right) + \frac{t\_0 + \left(x + -1\right)}{y}}{y}\\
\mathbf{elif}\;y \leq 320000:\\
\;\;\;\;1 + \frac{y}{y + 1} \cdot \left(x + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1 - \left(x + t\_0\right)}{y}\\
\end{array}
\end{array}
if y < -14000Initial program 39.9%
associate-/l*54.4%
remove-double-neg54.4%
remove-double-neg54.4%
+-commutative54.4%
Simplified54.4%
Taylor expanded in y around -inf 99.9%
Simplified99.9%
if -14000 < y < 3.2e5Initial program 99.9%
associate-/l*99.9%
remove-double-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
Simplified99.9%
if 3.2e5 < y Initial program 32.6%
associate-/l*54.3%
remove-double-neg54.3%
remove-double-neg54.3%
+-commutative54.3%
Simplified54.3%
Taylor expanded in y around inf 100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
x
(if (<= y 0.09)
(- 1.0 y)
(if (<= y 7.2e+71) x (if (<= y 1.1e+145) (/ 1.0 y) x)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.09) {
tmp = 1.0 - y;
} else if (y <= 7.2e+71) {
tmp = x;
} else if (y <= 1.1e+145) {
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.09d0) then
tmp = 1.0d0 - y
else if (y <= 7.2d+71) then
tmp = x
else if (y <= 1.1d+145) 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.09) {
tmp = 1.0 - y;
} else if (y <= 7.2e+71) {
tmp = x;
} else if (y <= 1.1e+145) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.09: tmp = 1.0 - y elif y <= 7.2e+71: tmp = x elif y <= 1.1e+145: 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.09) tmp = Float64(1.0 - y); elseif (y <= 7.2e+71) tmp = x; elseif (y <= 1.1e+145) 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.09) tmp = 1.0 - y; elseif (y <= 7.2e+71) tmp = x; elseif (y <= 1.1e+145) 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.09], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 7.2e+71], x, If[LessEqual[y, 1.1e+145], N[(1.0 / y), $MachinePrecision], x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.09:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{+71}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+145}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.089999999999999997 < y < 7.1999999999999999e71 or 1.10000000000000004e145 < y Initial program 40.0%
associate-/l*59.2%
remove-double-neg59.2%
remove-double-neg59.2%
+-commutative59.2%
Simplified59.2%
Taylor expanded in y around inf 80.3%
if -1 < y < 0.089999999999999997Initial 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.2%
Taylor expanded in x around 0 74.6%
if 7.1999999999999999e71 < y < 1.10000000000000004e145Initial program 18.8%
associate-/l*18.8%
remove-double-neg18.8%
remove-double-neg18.8%
+-commutative18.8%
Simplified18.8%
Taylor expanded in x around inf 19.4%
Taylor expanded in y around -inf 99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 83.0%
(FPCore (x y)
:precision binary64
(if (<= y -2.5e+26)
(- x (/ -1.0 y))
(if (<= y 320000.0)
(+ 1.0 (* (/ y (+ y 1.0)) (+ x -1.0)))
(+ x (/ (- 1.0 (+ x (/ (- 1.0 x) y))) y)))))
double code(double x, double y) {
double tmp;
if (y <= -2.5e+26) {
tmp = x - (-1.0 / y);
} else if (y <= 320000.0) {
tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0));
} else {
tmp = x + ((1.0 - (x + ((1.0 - x) / 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 <= (-2.5d+26)) then
tmp = x - ((-1.0d0) / y)
else if (y <= 320000.0d0) then
tmp = 1.0d0 + ((y / (y + 1.0d0)) * (x + (-1.0d0)))
else
tmp = x + ((1.0d0 - (x + ((1.0d0 - x) / y))) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.5e+26) {
tmp = x - (-1.0 / y);
} else if (y <= 320000.0) {
tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0));
} else {
tmp = x + ((1.0 - (x + ((1.0 - x) / y))) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.5e+26: tmp = x - (-1.0 / y) elif y <= 320000.0: tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0)) else: tmp = x + ((1.0 - (x + ((1.0 - x) / y))) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.5e+26) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 320000.0) tmp = Float64(1.0 + Float64(Float64(y / Float64(y + 1.0)) * Float64(x + -1.0))); else tmp = Float64(x + Float64(Float64(1.0 - Float64(x + Float64(Float64(1.0 - x) / y))) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.5e+26) tmp = x - (-1.0 / y); elseif (y <= 320000.0) tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0)); else tmp = x + ((1.0 - (x + ((1.0 - x) / y))) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.5e+26], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 320000.0], N[(1.0 + N[(N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(1.0 - N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{+26}:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 320000:\\
\;\;\;\;1 + \frac{y}{y + 1} \cdot \left(x + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1 - \left(x + \frac{1 - x}{y}\right)}{y}\\
\end{array}
\end{array}
if y < -2.5e26Initial program 34.8%
associate-/l*50.6%
remove-double-neg50.6%
remove-double-neg50.6%
+-commutative50.6%
Simplified50.6%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
if -2.5e26 < y < 3.2e5Initial program 99.8%
associate-/l*99.8%
remove-double-neg99.8%
remove-double-neg99.8%
+-commutative99.8%
Simplified99.8%
if 3.2e5 < y Initial program 32.6%
associate-/l*54.3%
remove-double-neg54.3%
remove-double-neg54.3%
+-commutative54.3%
Simplified54.3%
Taylor expanded in y around inf 100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= y -2.5e+26)
(- x (/ -1.0 y))
(if (<= y 480000000.0)
(+ 1.0 (* (/ y (+ y 1.0)) (+ x -1.0)))
(+ x (/ (- 1.0 x) y)))))
double code(double x, double y) {
double tmp;
if (y <= -2.5e+26) {
tmp = x - (-1.0 / y);
} else if (y <= 480000000.0) {
tmp = 1.0 + ((y / (y + 1.0)) * (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) :: tmp
if (y <= (-2.5d+26)) then
tmp = x - ((-1.0d0) / y)
else if (y <= 480000000.0d0) then
tmp = 1.0d0 + ((y / (y + 1.0d0)) * (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 tmp;
if (y <= -2.5e+26) {
tmp = x - (-1.0 / y);
} else if (y <= 480000000.0) {
tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0));
} else {
tmp = x + ((1.0 - x) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.5e+26: tmp = x - (-1.0 / y) elif y <= 480000000.0: tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0)) else: tmp = x + ((1.0 - x) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.5e+26) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 480000000.0) tmp = Float64(1.0 + Float64(Float64(y / Float64(y + 1.0)) * Float64(x + -1.0))); else tmp = Float64(x + Float64(Float64(1.0 - x) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.5e+26) tmp = x - (-1.0 / y); elseif (y <= 480000000.0) tmp = 1.0 + ((y / (y + 1.0)) * (x + -1.0)); else tmp = x + ((1.0 - x) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.5e+26], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 480000000.0], N[(1.0 + N[(N[(y / N[(y + 1.0), $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}
\mathbf{if}\;y \leq -2.5 \cdot 10^{+26}:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 480000000:\\
\;\;\;\;1 + \frac{y}{y + 1} \cdot \left(x + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1 - x}{y}\\
\end{array}
\end{array}
if y < -2.5e26Initial program 34.8%
associate-/l*50.6%
remove-double-neg50.6%
remove-double-neg50.6%
+-commutative50.6%
Simplified50.6%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
if -2.5e26 < y < 4.8e8Initial program 99.8%
associate-/l*99.8%
remove-double-neg99.8%
remove-double-neg99.8%
+-commutative99.8%
Simplified99.8%
if 4.8e8 < y Initial program 32.6%
associate-/l*54.3%
remove-double-neg54.3%
remove-double-neg54.3%
+-commutative54.3%
Simplified54.3%
Taylor expanded in y around inf 99.9%
associate--l+99.9%
div-sub99.9%
Simplified99.9%
Final simplification99.9%
(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 37.3%
associate-/l*54.6%
remove-double-neg54.6%
remove-double-neg54.6%
+-commutative54.6%
Simplified54.6%
Taylor expanded in y around inf 98.8%
associate--l+98.8%
div-sub98.8%
Simplified98.8%
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 98.6%
Final simplification98.7%
(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 37.3%
associate-/l*54.6%
remove-double-neg54.6%
remove-double-neg54.6%
+-commutative54.6%
Simplified54.6%
Taylor expanded in y around inf 98.8%
associate--l+98.8%
div-sub98.8%
Simplified98.8%
if -1 < y < 1.19999999999999996Initial 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 98.6%
Taylor expanded in x around inf 98.4%
associate-*r*98.4%
neg-mul-198.4%
*-commutative98.4%
Simplified98.4%
Final simplification98.6%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (- x (/ -1.0 y)) (+ 1.0 (* y x))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x - (-1.0 / 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.0d0))) then
tmp = x - ((-1.0d0) / 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.0)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + (y * x);
}
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 + (y * x) 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(y * x)); 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 + (y * x); 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[(y * x), $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 + y \cdot x\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 37.3%
associate-/l*54.6%
remove-double-neg54.6%
remove-double-neg54.6%
+-commutative54.6%
Simplified54.6%
Taylor expanded in y around inf 98.8%
associate--l+98.8%
div-sub98.8%
Simplified98.8%
Taylor expanded in x around 0 97.7%
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 98.6%
Taylor expanded in x around inf 98.4%
associate-*r*98.4%
neg-mul-198.4%
*-commutative98.4%
Simplified98.4%
Final simplification98.0%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.075))) (- x (/ -1.0 y)) (- 1.0 y)))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.075)) {
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.075d0))) 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.075)) {
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.075): 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.075)) 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.075))) 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.075]], $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.075\right):\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if y < -1 or 0.0749999999999999972 < y Initial program 37.8%
associate-/l*55.0%
remove-double-neg55.0%
remove-double-neg55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in y around inf 98.0%
associate--l+98.0%
div-sub98.0%
Simplified98.0%
Taylor expanded in x around 0 97.1%
if -1 < y < 0.0749999999999999972Initial 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.2%
Taylor expanded in x around 0 74.6%
Final simplification85.7%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.029) (- 1.0 y) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.029) {
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.029d0) 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.029) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.029: 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.029) 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.029) 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.029], N[(1.0 - y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.029:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.0290000000000000015 < y Initial program 37.8%
associate-/l*55.0%
remove-double-neg55.0%
remove-double-neg55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in y around inf 74.0%
if -1 < y < 0.0290000000000000015Initial 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.2%
Taylor expanded in x around 0 74.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.045) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.045) {
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.045d0) 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.045) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.045: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 0.045) 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.045) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 0.045], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.045:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.044999999999999998 < y Initial program 37.8%
associate-/l*55.0%
remove-double-neg55.0%
remove-double-neg55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in y around inf 74.0%
if -1 < y < 0.044999999999999998Initial 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 74.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 69.4%
associate-/l*77.8%
remove-double-neg77.8%
remove-double-neg77.8%
+-commutative77.8%
Simplified77.8%
Taylor expanded in y around 0 39.8%
(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 2024086
(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))))