
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
(FPCore (x y) :precision binary64 (let* ((t_0 (- 2.0 (+ x y)))) (- (/ x t_0) (/ y t_0))))
double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = 2.0d0 - (x + y)
code = (x / t_0) - (y / t_0)
end function
public static double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
def code(x, y): t_0 = 2.0 - (x + y) return (x / t_0) - (y / t_0)
function code(x, y) t_0 = Float64(2.0 - Float64(x + y)) return Float64(Float64(x / t_0) - Float64(y / t_0)) end
function tmp = code(x, y) t_0 = 2.0 - (x + y); tmp = (x / t_0) - (y / t_0); end
code[x_, y_] := Block[{t$95$0 = N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]}, N[(N[(x / t$95$0), $MachinePrecision] - N[(y / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 - \left(x + y\right)\\
\frac{x}{t_0} - \frac{y}{t_0}
\end{array}
\end{array}
Initial program 99.9%
associate--r+99.9%
Simplified99.9%
div-sub100.0%
associate--l-100.0%
associate--l-100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -7.3e+56)
t_0
(if (<= y -5e-20)
-1.0
(if (<= y -3.8e-42)
(* y -0.5)
(if (<= y 3.4e-116)
-1.0
(if (<= y 2e-85) (* x 0.5) (if (<= y 2.5e+21) -1.0 t_0))))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -7.3e+56) {
tmp = t_0;
} else if (y <= -5e-20) {
tmp = -1.0;
} else if (y <= -3.8e-42) {
tmp = y * -0.5;
} else if (y <= 3.4e-116) {
tmp = -1.0;
} else if (y <= 2e-85) {
tmp = x * 0.5;
} else if (y <= 2.5e+21) {
tmp = -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 - (x / y)
if (y <= (-7.3d+56)) then
tmp = t_0
else if (y <= (-5d-20)) then
tmp = -1.0d0
else if (y <= (-3.8d-42)) then
tmp = y * (-0.5d0)
else if (y <= 3.4d-116) then
tmp = -1.0d0
else if (y <= 2d-85) then
tmp = x * 0.5d0
else if (y <= 2.5d+21) then
tmp = -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 - (x / y);
double tmp;
if (y <= -7.3e+56) {
tmp = t_0;
} else if (y <= -5e-20) {
tmp = -1.0;
} else if (y <= -3.8e-42) {
tmp = y * -0.5;
} else if (y <= 3.4e-116) {
tmp = -1.0;
} else if (y <= 2e-85) {
tmp = x * 0.5;
} else if (y <= 2.5e+21) {
tmp = -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) tmp = 0 if y <= -7.3e+56: tmp = t_0 elif y <= -5e-20: tmp = -1.0 elif y <= -3.8e-42: tmp = y * -0.5 elif y <= 3.4e-116: tmp = -1.0 elif y <= 2e-85: tmp = x * 0.5 elif y <= 2.5e+21: tmp = -1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -7.3e+56) tmp = t_0; elseif (y <= -5e-20) tmp = -1.0; elseif (y <= -3.8e-42) tmp = Float64(y * -0.5); elseif (y <= 3.4e-116) tmp = -1.0; elseif (y <= 2e-85) tmp = Float64(x * 0.5); elseif (y <= 2.5e+21) tmp = -1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -7.3e+56) tmp = t_0; elseif (y <= -5e-20) tmp = -1.0; elseif (y <= -3.8e-42) tmp = y * -0.5; elseif (y <= 3.4e-116) tmp = -1.0; elseif (y <= 2e-85) tmp = x * 0.5; elseif (y <= 2.5e+21) tmp = -1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.3e+56], t$95$0, If[LessEqual[y, -5e-20], -1.0, If[LessEqual[y, -3.8e-42], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 3.4e-116], -1.0, If[LessEqual[y, 2e-85], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 2.5e+21], -1.0, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -7.3 \cdot 10^{+56}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -5 \cdot 10^{-20}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -3.8 \cdot 10^{-42}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-116}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-85}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+21}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -7.3e56 or 2.5e21 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.6%
associate--l-99.6%
Applied egg-rr99.6%
Taylor expanded in y around inf 75.3%
Taylor expanded in y around 0 75.5%
mul-1-neg75.5%
unsub-neg75.5%
Simplified75.5%
if -7.3e56 < y < -4.9999999999999999e-20 or -3.80000000000000017e-42 < y < 3.39999999999999992e-116 or 2e-85 < y < 2.5e21Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 65.9%
if -4.9999999999999999e-20 < y < -3.80000000000000017e-42Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 3.39999999999999992e-116 < y < 2e-85Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 57.7%
Taylor expanded in x around 0 55.6%
*-commutative55.6%
Simplified55.6%
Final simplification70.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (* x -2.0) y))) (t_1 (/ x (- 2.0 x))))
(if (<= y -1.05e+57)
t_0
(if (<= y -2.5e-18)
t_1
(if (<= y -1.8e-41) (* y -0.5) (if (<= y 4.1e+22) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + ((x * -2.0) / y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -1.05e+57) {
tmp = t_0;
} else if (y <= -2.5e-18) {
tmp = t_1;
} else if (y <= -1.8e-41) {
tmp = y * -0.5;
} else if (y <= 4.1e+22) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 + ((x * (-2.0d0)) / y)
t_1 = x / (2.0d0 - x)
if (y <= (-1.05d+57)) then
tmp = t_0
else if (y <= (-2.5d-18)) then
tmp = t_1
else if (y <= (-1.8d-41)) then
tmp = y * (-0.5d0)
else if (y <= 4.1d+22) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + ((x * -2.0) / y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -1.05e+57) {
tmp = t_0;
} else if (y <= -2.5e-18) {
tmp = t_1;
} else if (y <= -1.8e-41) {
tmp = y * -0.5;
} else if (y <= 4.1e+22) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + ((x * -2.0) / y) t_1 = x / (2.0 - x) tmp = 0 if y <= -1.05e+57: tmp = t_0 elif y <= -2.5e-18: tmp = t_1 elif y <= -1.8e-41: tmp = y * -0.5 elif y <= 4.1e+22: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(Float64(x * -2.0) / y)) t_1 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -1.05e+57) tmp = t_0; elseif (y <= -2.5e-18) tmp = t_1; elseif (y <= -1.8e-41) tmp = Float64(y * -0.5); elseif (y <= 4.1e+22) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + ((x * -2.0) / y); t_1 = x / (2.0 - x); tmp = 0.0; if (y <= -1.05e+57) tmp = t_0; elseif (y <= -2.5e-18) tmp = t_1; elseif (y <= -1.8e-41) tmp = y * -0.5; elseif (y <= 4.1e+22) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(x * -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.05e+57], t$95$0, If[LessEqual[y, -2.5e-18], t$95$1, If[LessEqual[y, -1.8e-41], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 4.1e+22], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x \cdot -2}{y}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -1.05 \cdot 10^{+57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.5 \cdot 10^{-18}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -1.8 \cdot 10^{-41}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+22}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.04999999999999995e57 or 4.09999999999999979e22 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 76.1%
associate--l+76.2%
associate-*r/76.2%
associate-*r/76.2%
div-sub76.2%
cancel-sign-sub-inv76.2%
metadata-eval76.2%
*-lft-identity76.2%
+-commutative76.2%
mul-1-neg76.2%
unsub-neg76.2%
Simplified76.2%
Taylor expanded in x around inf 76.2%
*-commutative76.2%
Simplified76.2%
if -1.04999999999999995e57 < y < -2.50000000000000018e-18 or -1.8e-41 < y < 4.09999999999999979e22Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 82.8%
if -2.50000000000000018e-18 < y < -1.8e-41Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification80.4%
(FPCore (x y)
:precision binary64
(if (<= y -3.9e+55)
1.0
(if (<= y -7e-20)
-1.0
(if (<= y -1.85e-41)
(* y -0.5)
(if (<= y 3.4e-116)
-1.0
(if (<= y 2e-85) (* x 0.5) (if (<= y 9.6e+22) -1.0 1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -3.9e+55) {
tmp = 1.0;
} else if (y <= -7e-20) {
tmp = -1.0;
} else if (y <= -1.85e-41) {
tmp = y * -0.5;
} else if (y <= 3.4e-116) {
tmp = -1.0;
} else if (y <= 2e-85) {
tmp = x * 0.5;
} else if (y <= 9.6e+22) {
tmp = -1.0;
} 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 <= (-3.9d+55)) then
tmp = 1.0d0
else if (y <= (-7d-20)) then
tmp = -1.0d0
else if (y <= (-1.85d-41)) then
tmp = y * (-0.5d0)
else if (y <= 3.4d-116) then
tmp = -1.0d0
else if (y <= 2d-85) then
tmp = x * 0.5d0
else if (y <= 9.6d+22) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -3.9e+55) {
tmp = 1.0;
} else if (y <= -7e-20) {
tmp = -1.0;
} else if (y <= -1.85e-41) {
tmp = y * -0.5;
} else if (y <= 3.4e-116) {
tmp = -1.0;
} else if (y <= 2e-85) {
tmp = x * 0.5;
} else if (y <= 9.6e+22) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.9e+55: tmp = 1.0 elif y <= -7e-20: tmp = -1.0 elif y <= -1.85e-41: tmp = y * -0.5 elif y <= 3.4e-116: tmp = -1.0 elif y <= 2e-85: tmp = x * 0.5 elif y <= 9.6e+22: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -3.9e+55) tmp = 1.0; elseif (y <= -7e-20) tmp = -1.0; elseif (y <= -1.85e-41) tmp = Float64(y * -0.5); elseif (y <= 3.4e-116) tmp = -1.0; elseif (y <= 2e-85) tmp = Float64(x * 0.5); elseif (y <= 9.6e+22) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -3.9e+55) tmp = 1.0; elseif (y <= -7e-20) tmp = -1.0; elseif (y <= -1.85e-41) tmp = y * -0.5; elseif (y <= 3.4e-116) tmp = -1.0; elseif (y <= 2e-85) tmp = x * 0.5; elseif (y <= 9.6e+22) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.9e+55], 1.0, If[LessEqual[y, -7e-20], -1.0, If[LessEqual[y, -1.85e-41], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 3.4e-116], -1.0, If[LessEqual[y, 2e-85], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 9.6e+22], -1.0, 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9 \cdot 10^{+55}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -7 \cdot 10^{-20}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -1.85 \cdot 10^{-41}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-116}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-85}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 9.6 \cdot 10^{+22}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.90000000000000027e55 or 9.6e22 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 74.9%
if -3.90000000000000027e55 < y < -7.00000000000000007e-20 or -1.8500000000000001e-41 < y < 3.39999999999999992e-116 or 2e-85 < y < 9.6e22Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 65.9%
if -7.00000000000000007e-20 < y < -1.8500000000000001e-41Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 3.39999999999999992e-116 < y < 2e-85Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 57.7%
Taylor expanded in x around 0 55.6%
*-commutative55.6%
Simplified55.6%
Final simplification70.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ x (- 2.0 x))))
(if (<= y -8.2e+56)
t_0
(if (<= y -1.65e-19)
t_1
(if (<= y -1.85e-41) (* y -0.5) (if (<= y 6.2e+24) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -8.2e+56) {
tmp = t_0;
} else if (y <= -1.65e-19) {
tmp = t_1;
} else if (y <= -1.85e-41) {
tmp = y * -0.5;
} else if (y <= 6.2e+24) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
t_1 = x / (2.0d0 - x)
if (y <= (-8.2d+56)) then
tmp = t_0
else if (y <= (-1.65d-19)) then
tmp = t_1
else if (y <= (-1.85d-41)) then
tmp = y * (-0.5d0)
else if (y <= 6.2d+24) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -8.2e+56) {
tmp = t_0;
} else if (y <= -1.65e-19) {
tmp = t_1;
} else if (y <= -1.85e-41) {
tmp = y * -0.5;
} else if (y <= 6.2e+24) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) t_1 = x / (2.0 - x) tmp = 0 if y <= -8.2e+56: tmp = t_0 elif y <= -1.65e-19: tmp = t_1 elif y <= -1.85e-41: tmp = y * -0.5 elif y <= 6.2e+24: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) t_1 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -8.2e+56) tmp = t_0; elseif (y <= -1.65e-19) tmp = t_1; elseif (y <= -1.85e-41) tmp = Float64(y * -0.5); elseif (y <= 6.2e+24) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); t_1 = x / (2.0 - x); tmp = 0.0; if (y <= -8.2e+56) tmp = t_0; elseif (y <= -1.65e-19) tmp = t_1; elseif (y <= -1.85e-41) tmp = y * -0.5; elseif (y <= 6.2e+24) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8.2e+56], t$95$0, If[LessEqual[y, -1.65e-19], t$95$1, If[LessEqual[y, -1.85e-41], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 6.2e+24], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -8.2 \cdot 10^{+56}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.65 \cdot 10^{-19}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -1.85 \cdot 10^{-41}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+24}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -8.2000000000000007e56 or 6.20000000000000022e24 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.6%
associate--l-99.6%
Applied egg-rr99.6%
Taylor expanded in y around inf 75.3%
Taylor expanded in y around 0 75.5%
mul-1-neg75.5%
unsub-neg75.5%
Simplified75.5%
if -8.2000000000000007e56 < y < -1.6499999999999999e-19 or -1.8500000000000001e-41 < y < 6.20000000000000022e24Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 82.8%
if -1.6499999999999999e-19 < y < -1.8500000000000001e-41Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification80.1%
(FPCore (x y)
:precision binary64
(if (<= y -2e+61)
1.0
(if (<= y 3.3e-116)
-1.0
(if (<= y 2e-85) (* x 0.5) (if (<= y 4e+19) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -2e+61) {
tmp = 1.0;
} else if (y <= 3.3e-116) {
tmp = -1.0;
} else if (y <= 2e-85) {
tmp = x * 0.5;
} else if (y <= 4e+19) {
tmp = -1.0;
} 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 <= (-2d+61)) then
tmp = 1.0d0
else if (y <= 3.3d-116) then
tmp = -1.0d0
else if (y <= 2d-85) then
tmp = x * 0.5d0
else if (y <= 4d+19) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2e+61) {
tmp = 1.0;
} else if (y <= 3.3e-116) {
tmp = -1.0;
} else if (y <= 2e-85) {
tmp = x * 0.5;
} else if (y <= 4e+19) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2e+61: tmp = 1.0 elif y <= 3.3e-116: tmp = -1.0 elif y <= 2e-85: tmp = x * 0.5 elif y <= 4e+19: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -2e+61) tmp = 1.0; elseif (y <= 3.3e-116) tmp = -1.0; elseif (y <= 2e-85) tmp = Float64(x * 0.5); elseif (y <= 4e+19) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2e+61) tmp = 1.0; elseif (y <= 3.3e-116) tmp = -1.0; elseif (y <= 2e-85) tmp = x * 0.5; elseif (y <= 4e+19) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2e+61], 1.0, If[LessEqual[y, 3.3e-116], -1.0, If[LessEqual[y, 2e-85], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 4e+19], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+61}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{-116}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-85}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+19}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.9999999999999999e61 or 4e19 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 74.9%
if -1.9999999999999999e61 < y < 3.30000000000000001e-116 or 2e-85 < y < 4e19Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 61.9%
if 3.30000000000000001e-116 < y < 2e-85Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 57.7%
Taylor expanded in x around 0 55.6%
*-commutative55.6%
Simplified55.6%
Final simplification67.5%
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y -1.85e+59) 1.0 (if (<= y 1e+24) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.85e+59) {
tmp = 1.0;
} else if (y <= 1e+24) {
tmp = -1.0;
} 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.85d+59)) then
tmp = 1.0d0
else if (y <= 1d+24) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.85e+59) {
tmp = 1.0;
} else if (y <= 1e+24) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.85e+59: tmp = 1.0 elif y <= 1e+24: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.85e+59) tmp = 1.0; elseif (y <= 1e+24) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.85e+59) tmp = 1.0; elseif (y <= 1e+24) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.85e+59], 1.0, If[LessEqual[y, 1e+24], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{+59}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 10^{+24}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.84999999999999999e59 or 9.9999999999999998e23 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 74.9%
if -1.84999999999999999e59 < y < 9.9999999999999998e23Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 57.9%
Final simplification65.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 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 41.9%
Final simplification41.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (- 2.0 (+ x y)))) (- (/ x t_0) (/ y t_0))))
double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = 2.0d0 - (x + y)
code = (x / t_0) - (y / t_0)
end function
public static double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
def code(x, y): t_0 = 2.0 - (x + y) return (x / t_0) - (y / t_0)
function code(x, y) t_0 = Float64(2.0 - Float64(x + y)) return Float64(Float64(x / t_0) - Float64(y / t_0)) end
function tmp = code(x, y) t_0 = 2.0 - (x + y); tmp = (x / t_0) - (y / t_0); end
code[x_, y_] := Block[{t$95$0 = N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]}, N[(N[(x / t$95$0), $MachinePrecision] - N[(y / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 - \left(x + y\right)\\
\frac{x}{t_0} - \frac{y}{t_0}
\end{array}
\end{array}
herbie shell --seed 2023173
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:herbie-target
(- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))
(/ (- x y) (- 2.0 (+ x y))))