
(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 10 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 (/ (- 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 (<= y -2.7e+35)
1.0
(if (<= y -3.6e-73)
-1.0
(if (<= y -3.9e-103)
(* y -0.5)
(if (<= y -1.05e-243)
-1.0
(if (<= y 1.55e-229)
(* x 0.5)
(if (<= y 7.2e-80)
-1.0
(if (<= y 1e-48) (* y -0.5) (if (<= y 7e+30) -1.0 1.0)))))))))
double code(double x, double y) {
double tmp;
if (y <= -2.7e+35) {
tmp = 1.0;
} else if (y <= -3.6e-73) {
tmp = -1.0;
} else if (y <= -3.9e-103) {
tmp = y * -0.5;
} else if (y <= -1.05e-243) {
tmp = -1.0;
} else if (y <= 1.55e-229) {
tmp = x * 0.5;
} else if (y <= 7.2e-80) {
tmp = -1.0;
} else if (y <= 1e-48) {
tmp = y * -0.5;
} else if (y <= 7e+30) {
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 <= (-2.7d+35)) then
tmp = 1.0d0
else if (y <= (-3.6d-73)) then
tmp = -1.0d0
else if (y <= (-3.9d-103)) then
tmp = y * (-0.5d0)
else if (y <= (-1.05d-243)) then
tmp = -1.0d0
else if (y <= 1.55d-229) then
tmp = x * 0.5d0
else if (y <= 7.2d-80) then
tmp = -1.0d0
else if (y <= 1d-48) then
tmp = y * (-0.5d0)
else if (y <= 7d+30) 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 <= -2.7e+35) {
tmp = 1.0;
} else if (y <= -3.6e-73) {
tmp = -1.0;
} else if (y <= -3.9e-103) {
tmp = y * -0.5;
} else if (y <= -1.05e-243) {
tmp = -1.0;
} else if (y <= 1.55e-229) {
tmp = x * 0.5;
} else if (y <= 7.2e-80) {
tmp = -1.0;
} else if (y <= 1e-48) {
tmp = y * -0.5;
} else if (y <= 7e+30) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.7e+35: tmp = 1.0 elif y <= -3.6e-73: tmp = -1.0 elif y <= -3.9e-103: tmp = y * -0.5 elif y <= -1.05e-243: tmp = -1.0 elif y <= 1.55e-229: tmp = x * 0.5 elif y <= 7.2e-80: tmp = -1.0 elif y <= 1e-48: tmp = y * -0.5 elif y <= 7e+30: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.7e+35) tmp = 1.0; elseif (y <= -3.6e-73) tmp = -1.0; elseif (y <= -3.9e-103) tmp = Float64(y * -0.5); elseif (y <= -1.05e-243) tmp = -1.0; elseif (y <= 1.55e-229) tmp = Float64(x * 0.5); elseif (y <= 7.2e-80) tmp = -1.0; elseif (y <= 1e-48) tmp = Float64(y * -0.5); elseif (y <= 7e+30) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.7e+35) tmp = 1.0; elseif (y <= -3.6e-73) tmp = -1.0; elseif (y <= -3.9e-103) tmp = y * -0.5; elseif (y <= -1.05e-243) tmp = -1.0; elseif (y <= 1.55e-229) tmp = x * 0.5; elseif (y <= 7.2e-80) tmp = -1.0; elseif (y <= 1e-48) tmp = y * -0.5; elseif (y <= 7e+30) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.7e+35], 1.0, If[LessEqual[y, -3.6e-73], -1.0, If[LessEqual[y, -3.9e-103], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -1.05e-243], -1.0, If[LessEqual[y, 1.55e-229], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 7.2e-80], -1.0, If[LessEqual[y, 1e-48], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 7e+30], -1.0, 1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+35}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -3.6 \cdot 10^{-73}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -3.9 \cdot 10^{-103}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -1.05 \cdot 10^{-243}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{-229}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{-80}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 10^{-48}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+30}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.70000000000000003e35 or 7.00000000000000042e30 < y Initial program 100.0%
Taylor expanded in y around inf 81.0%
if -2.70000000000000003e35 < y < -3.5999999999999999e-73 or -3.9000000000000002e-103 < y < -1.05e-243 or 1.55e-229 < y < 7.2e-80 or 9.9999999999999997e-49 < y < 7.00000000000000042e30Initial program 99.9%
Taylor expanded in x around inf 59.3%
if -3.5999999999999999e-73 < y < -3.9000000000000002e-103 or 7.2e-80 < y < 9.9999999999999997e-49Initial program 100.0%
Taylor expanded in x around 0 83.3%
mul-1-neg83.3%
distribute-neg-frac83.3%
Simplified83.3%
Taylor expanded in y around 0 83.3%
*-commutative83.3%
Simplified83.3%
if -1.05e-243 < y < 1.55e-229Initial program 100.0%
Taylor expanded in y around 0 93.1%
Taylor expanded in x around 0 70.1%
*-commutative70.1%
Simplified70.1%
Final simplification72.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ -1.0 (/ y x))))
(if (<= y -2.12e+83)
1.0
(if (<= y -1.12e-72)
t_0
(if (<= y -4.7e-104)
(* y -0.5)
(if (<= y -7.2e-243)
t_0
(if (<= y 9.5e-230)
(* x 0.5)
(if (<= y 2.4e-80)
-1.0
(if (<= y 3.5e-49)
(* y -0.5)
(if (<= y 8e+33) -1.0 1.0))))))))))
double code(double x, double y) {
double t_0 = -1.0 + (y / x);
double tmp;
if (y <= -2.12e+83) {
tmp = 1.0;
} else if (y <= -1.12e-72) {
tmp = t_0;
} else if (y <= -4.7e-104) {
tmp = y * -0.5;
} else if (y <= -7.2e-243) {
tmp = t_0;
} else if (y <= 9.5e-230) {
tmp = x * 0.5;
} else if (y <= 2.4e-80) {
tmp = -1.0;
} else if (y <= 3.5e-49) {
tmp = y * -0.5;
} else if (y <= 8e+33) {
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) :: t_0
real(8) :: tmp
t_0 = (-1.0d0) + (y / x)
if (y <= (-2.12d+83)) then
tmp = 1.0d0
else if (y <= (-1.12d-72)) then
tmp = t_0
else if (y <= (-4.7d-104)) then
tmp = y * (-0.5d0)
else if (y <= (-7.2d-243)) then
tmp = t_0
else if (y <= 9.5d-230) then
tmp = x * 0.5d0
else if (y <= 2.4d-80) then
tmp = -1.0d0
else if (y <= 3.5d-49) then
tmp = y * (-0.5d0)
else if (y <= 8d+33) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = -1.0 + (y / x);
double tmp;
if (y <= -2.12e+83) {
tmp = 1.0;
} else if (y <= -1.12e-72) {
tmp = t_0;
} else if (y <= -4.7e-104) {
tmp = y * -0.5;
} else if (y <= -7.2e-243) {
tmp = t_0;
} else if (y <= 9.5e-230) {
tmp = x * 0.5;
} else if (y <= 2.4e-80) {
tmp = -1.0;
} else if (y <= 3.5e-49) {
tmp = y * -0.5;
} else if (y <= 8e+33) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = -1.0 + (y / x) tmp = 0 if y <= -2.12e+83: tmp = 1.0 elif y <= -1.12e-72: tmp = t_0 elif y <= -4.7e-104: tmp = y * -0.5 elif y <= -7.2e-243: tmp = t_0 elif y <= 9.5e-230: tmp = x * 0.5 elif y <= 2.4e-80: tmp = -1.0 elif y <= 3.5e-49: tmp = y * -0.5 elif y <= 8e+33: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(-1.0 + Float64(y / x)) tmp = 0.0 if (y <= -2.12e+83) tmp = 1.0; elseif (y <= -1.12e-72) tmp = t_0; elseif (y <= -4.7e-104) tmp = Float64(y * -0.5); elseif (y <= -7.2e-243) tmp = t_0; elseif (y <= 9.5e-230) tmp = Float64(x * 0.5); elseif (y <= 2.4e-80) tmp = -1.0; elseif (y <= 3.5e-49) tmp = Float64(y * -0.5); elseif (y <= 8e+33) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = -1.0 + (y / x); tmp = 0.0; if (y <= -2.12e+83) tmp = 1.0; elseif (y <= -1.12e-72) tmp = t_0; elseif (y <= -4.7e-104) tmp = y * -0.5; elseif (y <= -7.2e-243) tmp = t_0; elseif (y <= 9.5e-230) tmp = x * 0.5; elseif (y <= 2.4e-80) tmp = -1.0; elseif (y <= 3.5e-49) tmp = y * -0.5; elseif (y <= 8e+33) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(-1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.12e+83], 1.0, If[LessEqual[y, -1.12e-72], t$95$0, If[LessEqual[y, -4.7e-104], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -7.2e-243], t$95$0, If[LessEqual[y, 9.5e-230], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 2.4e-80], -1.0, If[LessEqual[y, 3.5e-49], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 8e+33], -1.0, 1.0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \frac{y}{x}\\
\mathbf{if}\;y \leq -2.12 \cdot 10^{+83}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.12 \cdot 10^{-72}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -4.7 \cdot 10^{-104}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -7.2 \cdot 10^{-243}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{-230}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-80}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-49}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+33}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.11999999999999991e83 or 7.9999999999999996e33 < y Initial program 100.0%
Taylor expanded in y around inf 82.6%
if -2.11999999999999991e83 < y < -1.12000000000000005e-72 or -4.7e-104 < y < -7.2000000000000003e-243Initial program 100.0%
clear-num99.8%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 59.2%
Taylor expanded in x around 0 59.3%
if -1.12000000000000005e-72 < y < -4.7e-104 or 2.3999999999999999e-80 < y < 3.50000000000000006e-49Initial program 100.0%
Taylor expanded in x around 0 83.3%
mul-1-neg83.3%
distribute-neg-frac83.3%
Simplified83.3%
Taylor expanded in y around 0 83.3%
*-commutative83.3%
Simplified83.3%
if -7.2000000000000003e-243 < y < 9.5000000000000004e-230Initial program 100.0%
Taylor expanded in y around 0 93.1%
Taylor expanded in x around 0 70.1%
*-commutative70.1%
Simplified70.1%
if 9.5000000000000004e-230 < y < 2.3999999999999999e-80 or 3.50000000000000006e-49 < y < 7.9999999999999996e33Initial program 99.9%
Taylor expanded in x around inf 57.7%
Final simplification72.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -6.5e+37)
1.0
(if (<= y -7.4e-72)
t_0
(if (<= y -1.95e-100)
(* y -0.5)
(if (<= y 1.25e-81)
t_0
(if (<= y 1.35e-51) (* y -0.5) (if (<= y 4e+31) -1.0 1.0))))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -6.5e+37) {
tmp = 1.0;
} else if (y <= -7.4e-72) {
tmp = t_0;
} else if (y <= -1.95e-100) {
tmp = y * -0.5;
} else if (y <= 1.25e-81) {
tmp = t_0;
} else if (y <= 1.35e-51) {
tmp = y * -0.5;
} else if (y <= 4e+31) {
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) :: t_0
real(8) :: tmp
t_0 = x / (2.0d0 - x)
if (y <= (-6.5d+37)) then
tmp = 1.0d0
else if (y <= (-7.4d-72)) then
tmp = t_0
else if (y <= (-1.95d-100)) then
tmp = y * (-0.5d0)
else if (y <= 1.25d-81) then
tmp = t_0
else if (y <= 1.35d-51) then
tmp = y * (-0.5d0)
else if (y <= 4d+31) then
tmp = -1.0d0
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 <= -6.5e+37) {
tmp = 1.0;
} else if (y <= -7.4e-72) {
tmp = t_0;
} else if (y <= -1.95e-100) {
tmp = y * -0.5;
} else if (y <= 1.25e-81) {
tmp = t_0;
} else if (y <= 1.35e-51) {
tmp = y * -0.5;
} else if (y <= 4e+31) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -6.5e+37: tmp = 1.0 elif y <= -7.4e-72: tmp = t_0 elif y <= -1.95e-100: tmp = y * -0.5 elif y <= 1.25e-81: tmp = t_0 elif y <= 1.35e-51: tmp = y * -0.5 elif y <= 4e+31: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -6.5e+37) tmp = 1.0; elseif (y <= -7.4e-72) tmp = t_0; elseif (y <= -1.95e-100) tmp = Float64(y * -0.5); elseif (y <= 1.25e-81) tmp = t_0; elseif (y <= 1.35e-51) tmp = Float64(y * -0.5); elseif (y <= 4e+31) tmp = -1.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 <= -6.5e+37) tmp = 1.0; elseif (y <= -7.4e-72) tmp = t_0; elseif (y <= -1.95e-100) tmp = y * -0.5; elseif (y <= 1.25e-81) tmp = t_0; elseif (y <= 1.35e-51) tmp = y * -0.5; elseif (y <= 4e+31) tmp = -1.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, -6.5e+37], 1.0, If[LessEqual[y, -7.4e-72], t$95$0, If[LessEqual[y, -1.95e-100], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.25e-81], t$95$0, If[LessEqual[y, 1.35e-51], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 4e+31], -1.0, 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -6.5 \cdot 10^{+37}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -7.4 \cdot 10^{-72}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.95 \cdot 10^{-100}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-81}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-51}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+31}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -6.4999999999999998e37 or 3.9999999999999999e31 < y Initial program 100.0%
Taylor expanded in y around inf 81.0%
if -6.4999999999999998e37 < y < -7.3999999999999997e-72 or -1.94999999999999989e-100 < y < 1.24999999999999995e-81Initial program 100.0%
Taylor expanded in y around 0 82.1%
if -7.3999999999999997e-72 < y < -1.94999999999999989e-100 or 1.24999999999999995e-81 < y < 1.3499999999999999e-51Initial program 100.0%
Taylor expanded in x around 0 83.3%
mul-1-neg83.3%
distribute-neg-frac83.3%
Simplified83.3%
Taylor expanded in y around 0 83.3%
*-commutative83.3%
Simplified83.3%
if 1.3499999999999999e-51 < y < 3.9999999999999999e31Initial program 99.9%
Taylor expanded in x around inf 65.8%
Final simplification81.0%
(FPCore (x y)
:precision binary64
(if (<= y -6.5e+35)
1.0
(if (or (<= y -2.7e-73) (and (not (<= y -7e-101)) (<= y 1.4e-83)))
(/ x (- 2.0 x))
(/ y (+ y -2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -6.5e+35) {
tmp = 1.0;
} else if ((y <= -2.7e-73) || (!(y <= -7e-101) && (y <= 1.4e-83))) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-6.5d+35)) then
tmp = 1.0d0
else if ((y <= (-2.7d-73)) .or. (.not. (y <= (-7d-101))) .and. (y <= 1.4d-83)) then
tmp = x / (2.0d0 - x)
else
tmp = y / (y + (-2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -6.5e+35) {
tmp = 1.0;
} else if ((y <= -2.7e-73) || (!(y <= -7e-101) && (y <= 1.4e-83))) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6.5e+35: tmp = 1.0 elif (y <= -2.7e-73) or (not (y <= -7e-101) and (y <= 1.4e-83)): tmp = x / (2.0 - x) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -6.5e+35) tmp = 1.0; elseif ((y <= -2.7e-73) || (!(y <= -7e-101) && (y <= 1.4e-83))) tmp = Float64(x / Float64(2.0 - x)); else tmp = Float64(y / Float64(y + -2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -6.5e+35) tmp = 1.0; elseif ((y <= -2.7e-73) || (~((y <= -7e-101)) && (y <= 1.4e-83))) tmp = x / (2.0 - x); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6.5e+35], 1.0, If[Or[LessEqual[y, -2.7e-73], And[N[Not[LessEqual[y, -7e-101]], $MachinePrecision], LessEqual[y, 1.4e-83]]], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+35}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.7 \cdot 10^{-73} \lor \neg \left(y \leq -7 \cdot 10^{-101}\right) \land y \leq 1.4 \cdot 10^{-83}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if y < -6.5000000000000003e35Initial program 99.9%
Taylor expanded in y around inf 81.5%
if -6.5000000000000003e35 < y < -2.69999999999999994e-73 or -6.99999999999999989e-101 < y < 1.4e-83Initial program 100.0%
Taylor expanded in y around 0 82.1%
if -2.69999999999999994e-73 < y < -6.99999999999999989e-101 or 1.4e-83 < y Initial program 100.0%
Taylor expanded in x around 0 76.0%
mul-1-neg76.0%
distribute-neg-frac76.0%
Simplified76.0%
frac-2neg76.0%
div-inv75.9%
remove-double-neg75.9%
sub-neg75.9%
distribute-neg-in75.9%
metadata-eval75.9%
remove-double-neg75.9%
Applied egg-rr75.9%
associate-*r/76.0%
*-rgt-identity76.0%
+-commutative76.0%
Simplified76.0%
Final simplification79.8%
(FPCore (x y)
:precision binary64
(if (<= y -1.08e+35)
(/ (- x y) (- y))
(if (or (<= y -2.2e-73) (and (not (<= y -1.95e-100)) (<= y 8.8e-82)))
(/ x (- 2.0 x))
(/ y (+ y -2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.08e+35) {
tmp = (x - y) / -y;
} else if ((y <= -2.2e-73) || (!(y <= -1.95e-100) && (y <= 8.8e-82))) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.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.08d+35)) then
tmp = (x - y) / -y
else if ((y <= (-2.2d-73)) .or. (.not. (y <= (-1.95d-100))) .and. (y <= 8.8d-82)) then
tmp = x / (2.0d0 - x)
else
tmp = y / (y + (-2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.08e+35) {
tmp = (x - y) / -y;
} else if ((y <= -2.2e-73) || (!(y <= -1.95e-100) && (y <= 8.8e-82))) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.08e+35: tmp = (x - y) / -y elif (y <= -2.2e-73) or (not (y <= -1.95e-100) and (y <= 8.8e-82)): tmp = x / (2.0 - x) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.08e+35) tmp = Float64(Float64(x - y) / Float64(-y)); elseif ((y <= -2.2e-73) || (!(y <= -1.95e-100) && (y <= 8.8e-82))) tmp = Float64(x / Float64(2.0 - x)); else tmp = Float64(y / Float64(y + -2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.08e+35) tmp = (x - y) / -y; elseif ((y <= -2.2e-73) || (~((y <= -1.95e-100)) && (y <= 8.8e-82))) tmp = x / (2.0 - x); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.08e+35], N[(N[(x - y), $MachinePrecision] / (-y)), $MachinePrecision], If[Or[LessEqual[y, -2.2e-73], And[N[Not[LessEqual[y, -1.95e-100]], $MachinePrecision], LessEqual[y, 8.8e-82]]], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.08 \cdot 10^{+35}:\\
\;\;\;\;\frac{x - y}{-y}\\
\mathbf{elif}\;y \leq -2.2 \cdot 10^{-73} \lor \neg \left(y \leq -1.95 \cdot 10^{-100}\right) \land y \leq 8.8 \cdot 10^{-82}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if y < -1.08e35Initial program 99.9%
clear-num99.9%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 81.8%
expm1-log1p-u81.5%
expm1-udef81.5%
*-commutative81.5%
frac-2neg81.5%
metadata-eval81.5%
un-div-inv81.5%
Applied egg-rr81.5%
expm1-def81.5%
expm1-log1p82.0%
Simplified82.0%
if -1.08e35 < y < -2.2e-73 or -1.94999999999999989e-100 < y < 8.79999999999999943e-82Initial program 100.0%
Taylor expanded in y around 0 82.1%
if -2.2e-73 < y < -1.94999999999999989e-100 or 8.79999999999999943e-82 < y Initial program 100.0%
Taylor expanded in x around 0 76.0%
mul-1-neg76.0%
distribute-neg-frac76.0%
Simplified76.0%
frac-2neg76.0%
div-inv75.9%
remove-double-neg75.9%
sub-neg75.9%
distribute-neg-in75.9%
metadata-eval75.9%
remove-double-neg75.9%
Applied egg-rr75.9%
associate-*r/76.0%
*-rgt-identity76.0%
+-commutative76.0%
Simplified76.0%
Final simplification79.9%
(FPCore (x y)
:precision binary64
(if (<= y -2.6e+35)
(- 1.0 (/ (* x 2.0) y))
(if (or (<= y -2.2e-73) (and (not (<= y -1.9e-100)) (<= y 7.2e-80)))
(/ x (- 2.0 x))
(/ y (+ y -2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -2.6e+35) {
tmp = 1.0 - ((x * 2.0) / y);
} else if ((y <= -2.2e-73) || (!(y <= -1.9e-100) && (y <= 7.2e-80))) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2.6d+35)) then
tmp = 1.0d0 - ((x * 2.0d0) / y)
else if ((y <= (-2.2d-73)) .or. (.not. (y <= (-1.9d-100))) .and. (y <= 7.2d-80)) then
tmp = x / (2.0d0 - x)
else
tmp = y / (y + (-2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.6e+35) {
tmp = 1.0 - ((x * 2.0) / y);
} else if ((y <= -2.2e-73) || (!(y <= -1.9e-100) && (y <= 7.2e-80))) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.6e+35: tmp = 1.0 - ((x * 2.0) / y) elif (y <= -2.2e-73) or (not (y <= -1.9e-100) and (y <= 7.2e-80)): tmp = x / (2.0 - x) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.6e+35) tmp = Float64(1.0 - Float64(Float64(x * 2.0) / y)); elseif ((y <= -2.2e-73) || (!(y <= -1.9e-100) && (y <= 7.2e-80))) tmp = Float64(x / Float64(2.0 - x)); else tmp = Float64(y / Float64(y + -2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.6e+35) tmp = 1.0 - ((x * 2.0) / y); elseif ((y <= -2.2e-73) || (~((y <= -1.9e-100)) && (y <= 7.2e-80))) tmp = x / (2.0 - x); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.6e+35], N[(1.0 - N[(N[(x * 2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -2.2e-73], And[N[Not[LessEqual[y, -1.9e-100]], $MachinePrecision], LessEqual[y, 7.2e-80]]], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{+35}:\\
\;\;\;\;1 - \frac{x \cdot 2}{y}\\
\mathbf{elif}\;y \leq -2.2 \cdot 10^{-73} \lor \neg \left(y \leq -1.9 \cdot 10^{-100}\right) \land y \leq 7.2 \cdot 10^{-80}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if y < -2.60000000000000007e35Initial program 99.9%
Taylor expanded in y around inf 82.0%
sub-neg82.0%
mul-1-neg82.0%
unsub-neg82.0%
mul-1-neg82.0%
remove-double-neg82.0%
Simplified82.0%
associate-+l-82.0%
sub-div82.0%
Applied egg-rr82.0%
Taylor expanded in x around inf 82.0%
if -2.60000000000000007e35 < y < -2.2e-73 or -1.89999999999999999e-100 < y < 7.2e-80Initial program 100.0%
Taylor expanded in y around 0 82.1%
if -2.2e-73 < y < -1.89999999999999999e-100 or 7.2e-80 < y Initial program 100.0%
Taylor expanded in x around 0 76.0%
mul-1-neg76.0%
distribute-neg-frac76.0%
Simplified76.0%
frac-2neg76.0%
div-inv75.9%
remove-double-neg75.9%
sub-neg75.9%
distribute-neg-in75.9%
metadata-eval75.9%
remove-double-neg75.9%
Applied egg-rr75.9%
associate-*r/76.0%
*-rgt-identity76.0%
+-commutative76.0%
Simplified76.0%
Final simplification79.9%
(FPCore (x y)
:precision binary64
(if (<= y -5e+37)
1.0
(if (<= y -1.1e-243)
-1.0
(if (<= y 1.5e-229) (* x 0.5) (if (<= y 5e+27) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -5e+37) {
tmp = 1.0;
} else if (y <= -1.1e-243) {
tmp = -1.0;
} else if (y <= 1.5e-229) {
tmp = x * 0.5;
} else if (y <= 5e+27) {
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 <= (-5d+37)) then
tmp = 1.0d0
else if (y <= (-1.1d-243)) then
tmp = -1.0d0
else if (y <= 1.5d-229) then
tmp = x * 0.5d0
else if (y <= 5d+27) 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 <= -5e+37) {
tmp = 1.0;
} else if (y <= -1.1e-243) {
tmp = -1.0;
} else if (y <= 1.5e-229) {
tmp = x * 0.5;
} else if (y <= 5e+27) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5e+37: tmp = 1.0 elif y <= -1.1e-243: tmp = -1.0 elif y <= 1.5e-229: tmp = x * 0.5 elif y <= 5e+27: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5e+37) tmp = 1.0; elseif (y <= -1.1e-243) tmp = -1.0; elseif (y <= 1.5e-229) tmp = Float64(x * 0.5); elseif (y <= 5e+27) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5e+37) tmp = 1.0; elseif (y <= -1.1e-243) tmp = -1.0; elseif (y <= 1.5e-229) tmp = x * 0.5; elseif (y <= 5e+27) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5e+37], 1.0, If[LessEqual[y, -1.1e-243], -1.0, If[LessEqual[y, 1.5e-229], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 5e+27], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+37}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.1 \cdot 10^{-243}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-229}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+27}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.99999999999999989e37 or 4.99999999999999979e27 < y Initial program 100.0%
Taylor expanded in y around inf 81.0%
if -4.99999999999999989e37 < y < -1.1e-243 or 1.50000000000000001e-229 < y < 4.99999999999999979e27Initial program 100.0%
Taylor expanded in x around inf 53.3%
if -1.1e-243 < y < 1.50000000000000001e-229Initial program 100.0%
Taylor expanded in y around 0 93.1%
Taylor expanded in x around 0 70.1%
*-commutative70.1%
Simplified70.1%
Final simplification68.3%
(FPCore (x y) :precision binary64 (if (<= y -2.3e+35) 1.0 (if (<= y 1.75e+30) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -2.3e+35) {
tmp = 1.0;
} else if (y <= 1.75e+30) {
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 <= (-2.3d+35)) then
tmp = 1.0d0
else if (y <= 1.75d+30) 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 <= -2.3e+35) {
tmp = 1.0;
} else if (y <= 1.75e+30) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.3e+35: tmp = 1.0 elif y <= 1.75e+30: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.3e+35) tmp = 1.0; elseif (y <= 1.75e+30) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.3e+35) tmp = 1.0; elseif (y <= 1.75e+30) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.3e+35], 1.0, If[LessEqual[y, 1.75e+30], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{+35}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{+30}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.2999999999999998e35 or 1.75000000000000011e30 < y Initial program 100.0%
Taylor expanded in y around inf 81.0%
if -2.2999999999999998e35 < y < 1.75000000000000011e30Initial program 100.0%
Taylor expanded in x around inf 47.5%
Final simplification63.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 100.0%
Taylor expanded in x around inf 32.8%
Final simplification32.8%
(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 2024021
(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))))