
(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 100.0%
associate--r+100.0%
Simplified100.0%
div-sub100.0%
associate--l-100.0%
associate--l-100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= y -9.2e+51)
1.0
(if (<= y -5.4e-233)
-1.0
(if (<= y 1.3e-229)
(* x 0.5)
(if (<= y 350000000.0)
-1.0
(if (<= y 1.8e+81)
(+ 1.0 (/ 2.0 y))
(if (<= y 6.2e+123) -1.0 1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -9.2e+51) {
tmp = 1.0;
} else if (y <= -5.4e-233) {
tmp = -1.0;
} else if (y <= 1.3e-229) {
tmp = x * 0.5;
} else if (y <= 350000000.0) {
tmp = -1.0;
} else if (y <= 1.8e+81) {
tmp = 1.0 + (2.0 / y);
} else if (y <= 6.2e+123) {
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 <= (-9.2d+51)) then
tmp = 1.0d0
else if (y <= (-5.4d-233)) then
tmp = -1.0d0
else if (y <= 1.3d-229) then
tmp = x * 0.5d0
else if (y <= 350000000.0d0) then
tmp = -1.0d0
else if (y <= 1.8d+81) then
tmp = 1.0d0 + (2.0d0 / y)
else if (y <= 6.2d+123) 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 <= -9.2e+51) {
tmp = 1.0;
} else if (y <= -5.4e-233) {
tmp = -1.0;
} else if (y <= 1.3e-229) {
tmp = x * 0.5;
} else if (y <= 350000000.0) {
tmp = -1.0;
} else if (y <= 1.8e+81) {
tmp = 1.0 + (2.0 / y);
} else if (y <= 6.2e+123) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.2e+51: tmp = 1.0 elif y <= -5.4e-233: tmp = -1.0 elif y <= 1.3e-229: tmp = x * 0.5 elif y <= 350000000.0: tmp = -1.0 elif y <= 1.8e+81: tmp = 1.0 + (2.0 / y) elif y <= 6.2e+123: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -9.2e+51) tmp = 1.0; elseif (y <= -5.4e-233) tmp = -1.0; elseif (y <= 1.3e-229) tmp = Float64(x * 0.5); elseif (y <= 350000000.0) tmp = -1.0; elseif (y <= 1.8e+81) tmp = Float64(1.0 + Float64(2.0 / y)); elseif (y <= 6.2e+123) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -9.2e+51) tmp = 1.0; elseif (y <= -5.4e-233) tmp = -1.0; elseif (y <= 1.3e-229) tmp = x * 0.5; elseif (y <= 350000000.0) tmp = -1.0; elseif (y <= 1.8e+81) tmp = 1.0 + (2.0 / y); elseif (y <= 6.2e+123) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -9.2e+51], 1.0, If[LessEqual[y, -5.4e-233], -1.0, If[LessEqual[y, 1.3e-229], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 350000000.0], -1.0, If[LessEqual[y, 1.8e+81], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.2e+123], -1.0, 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+51}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -5.4 \cdot 10^{-233}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-229}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 350000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+81}:\\
\;\;\;\;1 + \frac{2}{y}\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+123}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -9.2000000000000002e51 or 6.20000000000000013e123 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 88.6%
if -9.2000000000000002e51 < y < -5.3999999999999999e-233 or 1.3000000000000001e-229 < y < 3.5e8 or 1.80000000000000003e81 < y < 6.20000000000000013e123Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 55.2%
if -5.3999999999999999e-233 < y < 1.3000000000000001e-229Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 91.0%
Taylor expanded in x around 0 61.5%
*-commutative61.5%
Simplified61.5%
if 3.5e8 < y < 1.80000000000000003e81Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 68.6%
associate--l+68.6%
associate-*r/68.6%
associate-*r/68.6%
div-sub68.6%
cancel-sign-sub-inv68.6%
metadata-eval68.6%
*-lft-identity68.6%
+-commutative68.6%
mul-1-neg68.6%
unsub-neg68.6%
Simplified68.6%
Taylor expanded in x around 0 66.6%
Final simplification69.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- y) (- 2.0 y))) (t_1 (/ x (- 2.0 x))))
(if (<= y -2.75e-33)
t_0
(if (<= y 1.1e-73)
t_1
(if (<= y 1.8e+81)
t_0
(if (<= y 6.2e+123) t_1 (+ 1.0 (/ (* x -2.0) y))))))))
double code(double x, double y) {
double t_0 = -y / (2.0 - y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -2.75e-33) {
tmp = t_0;
} else if (y <= 1.1e-73) {
tmp = t_1;
} else if (y <= 1.8e+81) {
tmp = t_0;
} else if (y <= 6.2e+123) {
tmp = t_1;
} else {
tmp = 1.0 + ((x * -2.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) :: t_1
real(8) :: tmp
t_0 = -y / (2.0d0 - y)
t_1 = x / (2.0d0 - x)
if (y <= (-2.75d-33)) then
tmp = t_0
else if (y <= 1.1d-73) then
tmp = t_1
else if (y <= 1.8d+81) then
tmp = t_0
else if (y <= 6.2d+123) then
tmp = t_1
else
tmp = 1.0d0 + ((x * (-2.0d0)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = -y / (2.0 - y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -2.75e-33) {
tmp = t_0;
} else if (y <= 1.1e-73) {
tmp = t_1;
} else if (y <= 1.8e+81) {
tmp = t_0;
} else if (y <= 6.2e+123) {
tmp = t_1;
} else {
tmp = 1.0 + ((x * -2.0) / y);
}
return tmp;
}
def code(x, y): t_0 = -y / (2.0 - y) t_1 = x / (2.0 - x) tmp = 0 if y <= -2.75e-33: tmp = t_0 elif y <= 1.1e-73: tmp = t_1 elif y <= 1.8e+81: tmp = t_0 elif y <= 6.2e+123: tmp = t_1 else: tmp = 1.0 + ((x * -2.0) / y) return tmp
function code(x, y) t_0 = Float64(Float64(-y) / Float64(2.0 - y)) t_1 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -2.75e-33) tmp = t_0; elseif (y <= 1.1e-73) tmp = t_1; elseif (y <= 1.8e+81) tmp = t_0; elseif (y <= 6.2e+123) tmp = t_1; else tmp = Float64(1.0 + Float64(Float64(x * -2.0) / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = -y / (2.0 - y); t_1 = x / (2.0 - x); tmp = 0.0; if (y <= -2.75e-33) tmp = t_0; elseif (y <= 1.1e-73) tmp = t_1; elseif (y <= 1.8e+81) tmp = t_0; elseif (y <= 6.2e+123) tmp = t_1; else tmp = 1.0 + ((x * -2.0) / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[((-y) / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.75e-33], t$95$0, If[LessEqual[y, 1.1e-73], t$95$1, If[LessEqual[y, 1.8e+81], t$95$0, If[LessEqual[y, 6.2e+123], t$95$1, N[(1.0 + N[(N[(x * -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-y}{2 - y}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -2.75 \cdot 10^{-33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-73}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+81}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+123}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x \cdot -2}{y}\\
\end{array}
\end{array}
if y < -2.75e-33 or 1.1e-73 < y < 1.80000000000000003e81Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 77.8%
mul-1-neg77.8%
distribute-neg-frac77.8%
Simplified77.8%
if -2.75e-33 < y < 1.1e-73 or 1.80000000000000003e81 < y < 6.20000000000000013e123Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 84.7%
if 6.20000000000000013e123 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 86.5%
associate--l+86.5%
associate-*r/86.5%
associate-*r/86.5%
div-sub86.5%
cancel-sign-sub-inv86.5%
metadata-eval86.5%
*-lft-identity86.5%
+-commutative86.5%
mul-1-neg86.5%
unsub-neg86.5%
Simplified86.5%
Taylor expanded in x around inf 86.5%
*-commutative86.5%
Simplified86.5%
Final simplification82.0%
(FPCore (x y)
:precision binary64
(if (<= y -9.2e+51)
1.0
(if (<= y -3.1e-230)
-1.0
(if (<= y 5.1e-225)
(* x 0.5)
(if (<= y 225000000000.0)
-1.0
(if (<= y 1.32e+81) 1.0 (if (<= y 6.2e+123) -1.0 1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -9.2e+51) {
tmp = 1.0;
} else if (y <= -3.1e-230) {
tmp = -1.0;
} else if (y <= 5.1e-225) {
tmp = x * 0.5;
} else if (y <= 225000000000.0) {
tmp = -1.0;
} else if (y <= 1.32e+81) {
tmp = 1.0;
} else if (y <= 6.2e+123) {
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 <= (-9.2d+51)) then
tmp = 1.0d0
else if (y <= (-3.1d-230)) then
tmp = -1.0d0
else if (y <= 5.1d-225) then
tmp = x * 0.5d0
else if (y <= 225000000000.0d0) then
tmp = -1.0d0
else if (y <= 1.32d+81) then
tmp = 1.0d0
else if (y <= 6.2d+123) 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 <= -9.2e+51) {
tmp = 1.0;
} else if (y <= -3.1e-230) {
tmp = -1.0;
} else if (y <= 5.1e-225) {
tmp = x * 0.5;
} else if (y <= 225000000000.0) {
tmp = -1.0;
} else if (y <= 1.32e+81) {
tmp = 1.0;
} else if (y <= 6.2e+123) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.2e+51: tmp = 1.0 elif y <= -3.1e-230: tmp = -1.0 elif y <= 5.1e-225: tmp = x * 0.5 elif y <= 225000000000.0: tmp = -1.0 elif y <= 1.32e+81: tmp = 1.0 elif y <= 6.2e+123: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -9.2e+51) tmp = 1.0; elseif (y <= -3.1e-230) tmp = -1.0; elseif (y <= 5.1e-225) tmp = Float64(x * 0.5); elseif (y <= 225000000000.0) tmp = -1.0; elseif (y <= 1.32e+81) tmp = 1.0; elseif (y <= 6.2e+123) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -9.2e+51) tmp = 1.0; elseif (y <= -3.1e-230) tmp = -1.0; elseif (y <= 5.1e-225) tmp = x * 0.5; elseif (y <= 225000000000.0) tmp = -1.0; elseif (y <= 1.32e+81) tmp = 1.0; elseif (y <= 6.2e+123) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -9.2e+51], 1.0, If[LessEqual[y, -3.1e-230], -1.0, If[LessEqual[y, 5.1e-225], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 225000000000.0], -1.0, If[LessEqual[y, 1.32e+81], 1.0, If[LessEqual[y, 6.2e+123], -1.0, 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+51}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -3.1 \cdot 10^{-230}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{-225}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 225000000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.32 \cdot 10^{+81}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+123}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -9.2000000000000002e51 or 2.25e11 < y < 1.31999999999999996e81 or 6.20000000000000013e123 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 85.5%
if -9.2000000000000002e51 < y < -3.1e-230 or 5.0999999999999999e-225 < y < 2.25e11 or 1.31999999999999996e81 < y < 6.20000000000000013e123Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 55.2%
if -3.1e-230 < y < 5.0999999999999999e-225Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 91.0%
Taylor expanded in x around 0 61.5%
*-commutative61.5%
Simplified61.5%
Final simplification69.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -1.75e+52)
1.0
(if (<= y 4300000000.0)
t_0
(if (<= y 1.8e+81) (+ 1.0 (/ 2.0 y)) (if (<= y 6.2e+123) t_0 1.0))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -1.75e+52) {
tmp = 1.0;
} else if (y <= 4300000000.0) {
tmp = t_0;
} else if (y <= 1.8e+81) {
tmp = 1.0 + (2.0 / y);
} else if (y <= 6.2e+123) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = x / (2.0d0 - x)
if (y <= (-1.75d+52)) then
tmp = 1.0d0
else if (y <= 4300000000.0d0) then
tmp = t_0
else if (y <= 1.8d+81) then
tmp = 1.0d0 + (2.0d0 / y)
else if (y <= 6.2d+123) then
tmp = t_0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -1.75e+52) {
tmp = 1.0;
} else if (y <= 4300000000.0) {
tmp = t_0;
} else if (y <= 1.8e+81) {
tmp = 1.0 + (2.0 / y);
} else if (y <= 6.2e+123) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -1.75e+52: tmp = 1.0 elif y <= 4300000000.0: tmp = t_0 elif y <= 1.8e+81: tmp = 1.0 + (2.0 / y) elif y <= 6.2e+123: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -1.75e+52) tmp = 1.0; elseif (y <= 4300000000.0) tmp = t_0; elseif (y <= 1.8e+81) tmp = Float64(1.0 + Float64(2.0 / y)); elseif (y <= 6.2e+123) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); tmp = 0.0; if (y <= -1.75e+52) tmp = 1.0; elseif (y <= 4300000000.0) tmp = t_0; elseif (y <= 1.8e+81) tmp = 1.0 + (2.0 / y); elseif (y <= 6.2e+123) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.75e+52], 1.0, If[LessEqual[y, 4300000000.0], t$95$0, If[LessEqual[y, 1.8e+81], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.2e+123], t$95$0, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -1.75 \cdot 10^{+52}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4300000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+81}:\\
\;\;\;\;1 + \frac{2}{y}\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+123}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.75e52 or 6.20000000000000013e123 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 88.6%
if -1.75e52 < y < 4.3e9 or 1.80000000000000003e81 < y < 6.20000000000000013e123Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 75.0%
if 4.3e9 < y < 1.80000000000000003e81Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 68.6%
associate--l+68.6%
associate-*r/68.6%
associate-*r/68.6%
div-sub68.6%
cancel-sign-sub-inv68.6%
metadata-eval68.6%
*-lft-identity68.6%
+-commutative68.6%
mul-1-neg68.6%
unsub-neg68.6%
Simplified68.6%
Taylor expanded in x around 0 66.6%
Final simplification79.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- y) (- 2.0 y))) (t_1 (/ x (- 2.0 x))))
(if (<= y -6.5e-33)
t_0
(if (<= y 2.5e-74)
t_1
(if (<= y 8.8e+80) t_0 (if (<= y 6.2e+123) t_1 1.0))))))
double code(double x, double y) {
double t_0 = -y / (2.0 - y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -6.5e-33) {
tmp = t_0;
} else if (y <= 2.5e-74) {
tmp = t_1;
} else if (y <= 8.8e+80) {
tmp = t_0;
} else if (y <= 6.2e+123) {
tmp = t_1;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = -y / (2.0d0 - y)
t_1 = x / (2.0d0 - x)
if (y <= (-6.5d-33)) then
tmp = t_0
else if (y <= 2.5d-74) then
tmp = t_1
else if (y <= 8.8d+80) then
tmp = t_0
else if (y <= 6.2d+123) then
tmp = t_1
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = -y / (2.0 - y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -6.5e-33) {
tmp = t_0;
} else if (y <= 2.5e-74) {
tmp = t_1;
} else if (y <= 8.8e+80) {
tmp = t_0;
} else if (y <= 6.2e+123) {
tmp = t_1;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = -y / (2.0 - y) t_1 = x / (2.0 - x) tmp = 0 if y <= -6.5e-33: tmp = t_0 elif y <= 2.5e-74: tmp = t_1 elif y <= 8.8e+80: tmp = t_0 elif y <= 6.2e+123: tmp = t_1 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(Float64(-y) / Float64(2.0 - y)) t_1 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -6.5e-33) tmp = t_0; elseif (y <= 2.5e-74) tmp = t_1; elseif (y <= 8.8e+80) tmp = t_0; elseif (y <= 6.2e+123) tmp = t_1; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = -y / (2.0 - y); t_1 = x / (2.0 - x); tmp = 0.0; if (y <= -6.5e-33) tmp = t_0; elseif (y <= 2.5e-74) tmp = t_1; elseif (y <= 8.8e+80) tmp = t_0; elseif (y <= 6.2e+123) tmp = t_1; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[((-y) / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.5e-33], t$95$0, If[LessEqual[y, 2.5e-74], t$95$1, If[LessEqual[y, 8.8e+80], t$95$0, If[LessEqual[y, 6.2e+123], t$95$1, 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-y}{2 - y}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -6.5 \cdot 10^{-33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-74}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 8.8 \cdot 10^{+80}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+123}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -6.4999999999999993e-33 or 2.49999999999999999e-74 < y < 8.80000000000000011e80Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 77.8%
mul-1-neg77.8%
distribute-neg-frac77.8%
Simplified77.8%
if -6.4999999999999993e-33 < y < 2.49999999999999999e-74 or 8.80000000000000011e80 < y < 6.20000000000000013e123Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 84.7%
if 6.20000000000000013e123 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 84.0%
Final simplification81.6%
(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 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= x -0.004) -1.0 (if (<= x 4e+37) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -0.004) {
tmp = -1.0;
} else if (x <= 4e+37) {
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 (x <= (-0.004d0)) then
tmp = -1.0d0
else if (x <= 4d+37) 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 (x <= -0.004) {
tmp = -1.0;
} else if (x <= 4e+37) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.004: tmp = -1.0 elif x <= 4e+37: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -0.004) tmp = -1.0; elseif (x <= 4e+37) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.004) tmp = -1.0; elseif (x <= 4e+37) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.004], -1.0, If[LessEqual[x, 4e+37], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.004:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+37}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -0.0040000000000000001 or 3.99999999999999982e37 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 74.0%
if -0.0040000000000000001 < x < 3.99999999999999982e37Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 54.4%
Final simplification62.7%
(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 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 33.5%
Final simplification33.5%
(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 2023202
(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))))