
(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 -3.3e+61)
1.0
(if (<= y -1.8e-35)
-1.0
(if (<= y -3.05e-145)
(* y -0.5)
(if (<= y -7.2e-187)
-1.0
(if (<= y -5.8e-270)
(* x 0.5)
(if (<= y 1.8e-190)
-1.0
(if (<= y 9.2e-148) (* x 0.5) (if (<= y 2.7e+34) -1.0 1.0)))))))))
double code(double x, double y) {
double tmp;
if (y <= -3.3e+61) {
tmp = 1.0;
} else if (y <= -1.8e-35) {
tmp = -1.0;
} else if (y <= -3.05e-145) {
tmp = y * -0.5;
} else if (y <= -7.2e-187) {
tmp = -1.0;
} else if (y <= -5.8e-270) {
tmp = x * 0.5;
} else if (y <= 1.8e-190) {
tmp = -1.0;
} else if (y <= 9.2e-148) {
tmp = x * 0.5;
} else if (y <= 2.7e+34) {
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.3d+61)) then
tmp = 1.0d0
else if (y <= (-1.8d-35)) then
tmp = -1.0d0
else if (y <= (-3.05d-145)) then
tmp = y * (-0.5d0)
else if (y <= (-7.2d-187)) then
tmp = -1.0d0
else if (y <= (-5.8d-270)) then
tmp = x * 0.5d0
else if (y <= 1.8d-190) then
tmp = -1.0d0
else if (y <= 9.2d-148) then
tmp = x * 0.5d0
else if (y <= 2.7d+34) 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.3e+61) {
tmp = 1.0;
} else if (y <= -1.8e-35) {
tmp = -1.0;
} else if (y <= -3.05e-145) {
tmp = y * -0.5;
} else if (y <= -7.2e-187) {
tmp = -1.0;
} else if (y <= -5.8e-270) {
tmp = x * 0.5;
} else if (y <= 1.8e-190) {
tmp = -1.0;
} else if (y <= 9.2e-148) {
tmp = x * 0.5;
} else if (y <= 2.7e+34) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.3e+61: tmp = 1.0 elif y <= -1.8e-35: tmp = -1.0 elif y <= -3.05e-145: tmp = y * -0.5 elif y <= -7.2e-187: tmp = -1.0 elif y <= -5.8e-270: tmp = x * 0.5 elif y <= 1.8e-190: tmp = -1.0 elif y <= 9.2e-148: tmp = x * 0.5 elif y <= 2.7e+34: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -3.3e+61) tmp = 1.0; elseif (y <= -1.8e-35) tmp = -1.0; elseif (y <= -3.05e-145) tmp = Float64(y * -0.5); elseif (y <= -7.2e-187) tmp = -1.0; elseif (y <= -5.8e-270) tmp = Float64(x * 0.5); elseif (y <= 1.8e-190) tmp = -1.0; elseif (y <= 9.2e-148) tmp = Float64(x * 0.5); elseif (y <= 2.7e+34) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -3.3e+61) tmp = 1.0; elseif (y <= -1.8e-35) tmp = -1.0; elseif (y <= -3.05e-145) tmp = y * -0.5; elseif (y <= -7.2e-187) tmp = -1.0; elseif (y <= -5.8e-270) tmp = x * 0.5; elseif (y <= 1.8e-190) tmp = -1.0; elseif (y <= 9.2e-148) tmp = x * 0.5; elseif (y <= 2.7e+34) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.3e+61], 1.0, If[LessEqual[y, -1.8e-35], -1.0, If[LessEqual[y, -3.05e-145], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -7.2e-187], -1.0, If[LessEqual[y, -5.8e-270], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1.8e-190], -1.0, If[LessEqual[y, 9.2e-148], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 2.7e+34], -1.0, 1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{+61}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.8 \cdot 10^{-35}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -3.05 \cdot 10^{-145}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -7.2 \cdot 10^{-187}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -5.8 \cdot 10^{-270}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{-190}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{-148}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+34}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.2999999999999998e61 or 2.7e34 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 87.7%
if -3.2999999999999998e61 < y < -1.80000000000000009e-35 or -3.05e-145 < y < -7.19999999999999989e-187 or -5.79999999999999965e-270 < y < 1.80000000000000003e-190 or 9.1999999999999999e-148 < y < 2.7e34Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 64.7%
if -1.80000000000000009e-35 < y < -3.05e-145Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 63.2%
mul-1-neg63.2%
distribute-neg-frac63.2%
Simplified63.2%
Taylor expanded in y around 0 63.2%
*-commutative63.2%
Simplified63.2%
if -7.19999999999999989e-187 < y < -5.79999999999999965e-270 or 1.80000000000000003e-190 < y < 9.1999999999999999e-148Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 86.6%
Taylor expanded in x around 0 65.1%
*-commutative65.1%
Simplified65.1%
Final simplification74.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (- x y) 0.5)) (t_1 (- 1.0 (/ x y))))
(if (<= y -6.5e+70)
t_1
(if (<= y -2.8e-41)
-1.0
(if (<= y -1.05e-272)
t_0
(if (<= y 1.35e-192)
-1.0
(if (<= y 3.2e-147) t_0 (if (<= y 1.35e+33) -1.0 t_1))))))))
double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double t_1 = 1.0 - (x / y);
double tmp;
if (y <= -6.5e+70) {
tmp = t_1;
} else if (y <= -2.8e-41) {
tmp = -1.0;
} else if (y <= -1.05e-272) {
tmp = t_0;
} else if (y <= 1.35e-192) {
tmp = -1.0;
} else if (y <= 3.2e-147) {
tmp = t_0;
} else if (y <= 1.35e+33) {
tmp = -1.0;
} else {
tmp = t_1;
}
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 = (x - y) * 0.5d0
t_1 = 1.0d0 - (x / y)
if (y <= (-6.5d+70)) then
tmp = t_1
else if (y <= (-2.8d-41)) then
tmp = -1.0d0
else if (y <= (-1.05d-272)) then
tmp = t_0
else if (y <= 1.35d-192) then
tmp = -1.0d0
else if (y <= 3.2d-147) then
tmp = t_0
else if (y <= 1.35d+33) then
tmp = -1.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double t_1 = 1.0 - (x / y);
double tmp;
if (y <= -6.5e+70) {
tmp = t_1;
} else if (y <= -2.8e-41) {
tmp = -1.0;
} else if (y <= -1.05e-272) {
tmp = t_0;
} else if (y <= 1.35e-192) {
tmp = -1.0;
} else if (y <= 3.2e-147) {
tmp = t_0;
} else if (y <= 1.35e+33) {
tmp = -1.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = (x - y) * 0.5 t_1 = 1.0 - (x / y) tmp = 0 if y <= -6.5e+70: tmp = t_1 elif y <= -2.8e-41: tmp = -1.0 elif y <= -1.05e-272: tmp = t_0 elif y <= 1.35e-192: tmp = -1.0 elif y <= 3.2e-147: tmp = t_0 elif y <= 1.35e+33: tmp = -1.0 else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) * 0.5) t_1 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -6.5e+70) tmp = t_1; elseif (y <= -2.8e-41) tmp = -1.0; elseif (y <= -1.05e-272) tmp = t_0; elseif (y <= 1.35e-192) tmp = -1.0; elseif (y <= 3.2e-147) tmp = t_0; elseif (y <= 1.35e+33) tmp = -1.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) * 0.5; t_1 = 1.0 - (x / y); tmp = 0.0; if (y <= -6.5e+70) tmp = t_1; elseif (y <= -2.8e-41) tmp = -1.0; elseif (y <= -1.05e-272) tmp = t_0; elseif (y <= 1.35e-192) tmp = -1.0; elseif (y <= 3.2e-147) tmp = t_0; elseif (y <= 1.35e+33) tmp = -1.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.5e+70], t$95$1, If[LessEqual[y, -2.8e-41], -1.0, If[LessEqual[y, -1.05e-272], t$95$0, If[LessEqual[y, 1.35e-192], -1.0, If[LessEqual[y, 3.2e-147], t$95$0, If[LessEqual[y, 1.35e+33], -1.0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot 0.5\\
t_1 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -6.5 \cdot 10^{+70}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -2.8 \cdot 10^{-41}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -1.05 \cdot 10^{-272}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-192}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{-147}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+33}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -6.49999999999999978e70 or 1.34999999999999996e33 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.7%
associate--l-99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 88.4%
Taylor expanded in y around 0 88.7%
mul-1-neg88.7%
unsub-neg88.7%
Simplified88.7%
if -6.49999999999999978e70 < y < -2.8000000000000002e-41 or -1.04999999999999993e-272 < y < 1.34999999999999996e-192 or 3.19999999999999979e-147 < y < 1.34999999999999996e33Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 64.8%
if -2.8000000000000002e-41 < y < -1.04999999999999993e-272 or 1.34999999999999996e-192 < y < 3.19999999999999979e-147Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.7%
associate-/r/99.9%
associate--l-99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 70.8%
Taylor expanded in y around 0 70.8%
Final simplification76.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (- x y) 0.5)))
(if (<= y -1.9e+61)
1.0
(if (<= y -1.56e-40)
-1.0
(if (<= y -2.05e-271)
t_0
(if (<= y 1.1e-192)
-1.0
(if (<= y 7.6e-148) t_0 (if (<= y 1e+33) -1.0 1.0))))))))
double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double tmp;
if (y <= -1.9e+61) {
tmp = 1.0;
} else if (y <= -1.56e-40) {
tmp = -1.0;
} else if (y <= -2.05e-271) {
tmp = t_0;
} else if (y <= 1.1e-192) {
tmp = -1.0;
} else if (y <= 7.6e-148) {
tmp = t_0;
} else if (y <= 1e+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 = (x - y) * 0.5d0
if (y <= (-1.9d+61)) then
tmp = 1.0d0
else if (y <= (-1.56d-40)) then
tmp = -1.0d0
else if (y <= (-2.05d-271)) then
tmp = t_0
else if (y <= 1.1d-192) then
tmp = -1.0d0
else if (y <= 7.6d-148) then
tmp = t_0
else if (y <= 1d+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 = (x - y) * 0.5;
double tmp;
if (y <= -1.9e+61) {
tmp = 1.0;
} else if (y <= -1.56e-40) {
tmp = -1.0;
} else if (y <= -2.05e-271) {
tmp = t_0;
} else if (y <= 1.1e-192) {
tmp = -1.0;
} else if (y <= 7.6e-148) {
tmp = t_0;
} else if (y <= 1e+33) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = (x - y) * 0.5 tmp = 0 if y <= -1.9e+61: tmp = 1.0 elif y <= -1.56e-40: tmp = -1.0 elif y <= -2.05e-271: tmp = t_0 elif y <= 1.1e-192: tmp = -1.0 elif y <= 7.6e-148: tmp = t_0 elif y <= 1e+33: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) * 0.5) tmp = 0.0 if (y <= -1.9e+61) tmp = 1.0; elseif (y <= -1.56e-40) tmp = -1.0; elseif (y <= -2.05e-271) tmp = t_0; elseif (y <= 1.1e-192) tmp = -1.0; elseif (y <= 7.6e-148) tmp = t_0; elseif (y <= 1e+33) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) * 0.5; tmp = 0.0; if (y <= -1.9e+61) tmp = 1.0; elseif (y <= -1.56e-40) tmp = -1.0; elseif (y <= -2.05e-271) tmp = t_0; elseif (y <= 1.1e-192) tmp = -1.0; elseif (y <= 7.6e-148) tmp = t_0; elseif (y <= 1e+33) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[y, -1.9e+61], 1.0, If[LessEqual[y, -1.56e-40], -1.0, If[LessEqual[y, -2.05e-271], t$95$0, If[LessEqual[y, 1.1e-192], -1.0, If[LessEqual[y, 7.6e-148], t$95$0, If[LessEqual[y, 1e+33], -1.0, 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot 0.5\\
\mathbf{if}\;y \leq -1.9 \cdot 10^{+61}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.56 \cdot 10^{-40}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -2.05 \cdot 10^{-271}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-192}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{-148}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 10^{+33}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.89999999999999998e61 or 9.9999999999999995e32 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 87.7%
if -1.89999999999999998e61 < y < -1.55999999999999996e-40 or -2.0500000000000001e-271 < y < 1.10000000000000003e-192 or 7.60000000000000028e-148 < y < 9.9999999999999995e32Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 65.1%
if -1.55999999999999996e-40 < y < -2.0500000000000001e-271 or 1.10000000000000003e-192 < y < 7.60000000000000028e-148Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.7%
associate-/r/99.9%
associate--l-99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 70.8%
Taylor expanded in y around 0 70.8%
Final simplification75.8%
(FPCore (x y)
:precision binary64
(if (<= y -1e+74)
1.0
(if (<= y -7.2e-187)
-1.0
(if (<= y -1.65e-269)
(* x 0.5)
(if (<= y 4.6e-190)
-1.0
(if (<= y 1.65e-150) (* x 0.5) (if (<= y 5.5e+32) -1.0 1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -1e+74) {
tmp = 1.0;
} else if (y <= -7.2e-187) {
tmp = -1.0;
} else if (y <= -1.65e-269) {
tmp = x * 0.5;
} else if (y <= 4.6e-190) {
tmp = -1.0;
} else if (y <= 1.65e-150) {
tmp = x * 0.5;
} else if (y <= 5.5e+32) {
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 <= (-1d+74)) then
tmp = 1.0d0
else if (y <= (-7.2d-187)) then
tmp = -1.0d0
else if (y <= (-1.65d-269)) then
tmp = x * 0.5d0
else if (y <= 4.6d-190) then
tmp = -1.0d0
else if (y <= 1.65d-150) then
tmp = x * 0.5d0
else if (y <= 5.5d+32) 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 <= -1e+74) {
tmp = 1.0;
} else if (y <= -7.2e-187) {
tmp = -1.0;
} else if (y <= -1.65e-269) {
tmp = x * 0.5;
} else if (y <= 4.6e-190) {
tmp = -1.0;
} else if (y <= 1.65e-150) {
tmp = x * 0.5;
} else if (y <= 5.5e+32) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1e+74: tmp = 1.0 elif y <= -7.2e-187: tmp = -1.0 elif y <= -1.65e-269: tmp = x * 0.5 elif y <= 4.6e-190: tmp = -1.0 elif y <= 1.65e-150: tmp = x * 0.5 elif y <= 5.5e+32: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1e+74) tmp = 1.0; elseif (y <= -7.2e-187) tmp = -1.0; elseif (y <= -1.65e-269) tmp = Float64(x * 0.5); elseif (y <= 4.6e-190) tmp = -1.0; elseif (y <= 1.65e-150) tmp = Float64(x * 0.5); elseif (y <= 5.5e+32) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1e+74) tmp = 1.0; elseif (y <= -7.2e-187) tmp = -1.0; elseif (y <= -1.65e-269) tmp = x * 0.5; elseif (y <= 4.6e-190) tmp = -1.0; elseif (y <= 1.65e-150) tmp = x * 0.5; elseif (y <= 5.5e+32) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1e+74], 1.0, If[LessEqual[y, -7.2e-187], -1.0, If[LessEqual[y, -1.65e-269], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 4.6e-190], -1.0, If[LessEqual[y, 1.65e-150], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 5.5e+32], -1.0, 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+74}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -7.2 \cdot 10^{-187}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -1.65 \cdot 10^{-269}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{-190}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{-150}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{+32}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -9.99999999999999952e73 or 5.49999999999999984e32 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 88.4%
if -9.99999999999999952e73 < y < -7.19999999999999989e-187 or -1.65e-269 < y < 4.59999999999999984e-190 or 1.6500000000000001e-150 < y < 5.49999999999999984e32Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 59.6%
if -7.19999999999999989e-187 < y < -1.65e-269 or 4.59999999999999984e-190 < y < 1.6500000000000001e-150Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 86.6%
Taylor expanded in x around 0 65.1%
*-commutative65.1%
Simplified65.1%
Final simplification72.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ x (- 2.0 x))))
(if (<= y -4.4e+71)
t_0
(if (<= y -2.2e-41)
t_1
(if (<= y -1.75e-146) (* (- x y) 0.5) (if (<= y 2.7e+34) 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 <= -4.4e+71) {
tmp = t_0;
} else if (y <= -2.2e-41) {
tmp = t_1;
} else if (y <= -1.75e-146) {
tmp = (x - y) * 0.5;
} else if (y <= 2.7e+34) {
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 <= (-4.4d+71)) then
tmp = t_0
else if (y <= (-2.2d-41)) then
tmp = t_1
else if (y <= (-1.75d-146)) then
tmp = (x - y) * 0.5d0
else if (y <= 2.7d+34) 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 <= -4.4e+71) {
tmp = t_0;
} else if (y <= -2.2e-41) {
tmp = t_1;
} else if (y <= -1.75e-146) {
tmp = (x - y) * 0.5;
} else if (y <= 2.7e+34) {
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 <= -4.4e+71: tmp = t_0 elif y <= -2.2e-41: tmp = t_1 elif y <= -1.75e-146: tmp = (x - y) * 0.5 elif y <= 2.7e+34: 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 <= -4.4e+71) tmp = t_0; elseif (y <= -2.2e-41) tmp = t_1; elseif (y <= -1.75e-146) tmp = Float64(Float64(x - y) * 0.5); elseif (y <= 2.7e+34) 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 <= -4.4e+71) tmp = t_0; elseif (y <= -2.2e-41) tmp = t_1; elseif (y <= -1.75e-146) tmp = (x - y) * 0.5; elseif (y <= 2.7e+34) 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, -4.4e+71], t$95$0, If[LessEqual[y, -2.2e-41], t$95$1, If[LessEqual[y, -1.75e-146], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[y, 2.7e+34], 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 -4.4 \cdot 10^{+71}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.2 \cdot 10^{-41}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -1.75 \cdot 10^{-146}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+34}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -4.39999999999999989e71 or 2.7e34 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.7%
associate--l-99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 88.4%
Taylor expanded in y around 0 88.7%
mul-1-neg88.7%
unsub-neg88.7%
Simplified88.7%
if -4.39999999999999989e71 < y < -2.2e-41 or -1.7500000000000001e-146 < y < 2.7e34Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 80.1%
if -2.2e-41 < y < -1.7500000000000001e-146Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.8%
associate-/r/100.0%
associate--l-100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 79.1%
Taylor expanded in y around 0 79.1%
Final simplification83.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -7.5e+70)
(/ (- y x) y)
(if (<= y -8.2e-41)
t_0
(if (<= y -3.9e-145)
(* (- x y) 0.5)
(if (<= y 5.7e+32) t_0 (- 1.0 (/ x y))))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -7.5e+70) {
tmp = (y - x) / y;
} else if (y <= -8.2e-41) {
tmp = t_0;
} else if (y <= -3.9e-145) {
tmp = (x - y) * 0.5;
} else if (y <= 5.7e+32) {
tmp = t_0;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x / (2.0d0 - x)
if (y <= (-7.5d+70)) then
tmp = (y - x) / y
else if (y <= (-8.2d-41)) then
tmp = t_0
else if (y <= (-3.9d-145)) then
tmp = (x - y) * 0.5d0
else if (y <= 5.7d+32) then
tmp = t_0
else
tmp = 1.0d0 - (x / y)
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 <= -7.5e+70) {
tmp = (y - x) / y;
} else if (y <= -8.2e-41) {
tmp = t_0;
} else if (y <= -3.9e-145) {
tmp = (x - y) * 0.5;
} else if (y <= 5.7e+32) {
tmp = t_0;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -7.5e+70: tmp = (y - x) / y elif y <= -8.2e-41: tmp = t_0 elif y <= -3.9e-145: tmp = (x - y) * 0.5 elif y <= 5.7e+32: tmp = t_0 else: tmp = 1.0 - (x / y) return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -7.5e+70) tmp = Float64(Float64(y - x) / y); elseif (y <= -8.2e-41) tmp = t_0; elseif (y <= -3.9e-145) tmp = Float64(Float64(x - y) * 0.5); elseif (y <= 5.7e+32) tmp = t_0; else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); tmp = 0.0; if (y <= -7.5e+70) tmp = (y - x) / y; elseif (y <= -8.2e-41) tmp = t_0; elseif (y <= -3.9e-145) tmp = (x - y) * 0.5; elseif (y <= 5.7e+32) tmp = t_0; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.5e+70], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, -8.2e-41], t$95$0, If[LessEqual[y, -3.9e-145], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[y, 5.7e+32], t$95$0, N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -7.5 \cdot 10^{+70}:\\
\;\;\;\;\frac{y - x}{y}\\
\mathbf{elif}\;y \leq -8.2 \cdot 10^{-41}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -3.9 \cdot 10^{-145}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;y \leq 5.7 \cdot 10^{+32}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -7.50000000000000031e70Initial 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 91.8%
*-commutative91.8%
frac-2neg91.8%
metadata-eval91.8%
un-div-inv92.1%
Applied egg-rr92.1%
frac-2neg92.1%
div-inv91.8%
sub-neg91.8%
distribute-neg-in91.8%
neg-mul-191.8%
remove-double-neg91.8%
fma-def91.8%
remove-double-neg91.8%
Applied egg-rr91.8%
associate-*r/92.1%
*-rgt-identity92.1%
fma-udef92.1%
neg-mul-192.1%
+-commutative92.1%
unsub-neg92.1%
Simplified92.1%
if -7.50000000000000031e70 < y < -8.20000000000000028e-41 or -3.90000000000000029e-145 < y < 5.7e32Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 80.1%
if -8.20000000000000028e-41 < y < -3.90000000000000029e-145Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.8%
associate-/r/100.0%
associate--l-100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 79.1%
Taylor expanded in y around 0 79.1%
if 5.7e32 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.7%
associate--l-99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 86.0%
Taylor expanded in y around 0 86.3%
mul-1-neg86.3%
unsub-neg86.3%
Simplified86.3%
Final simplification83.6%
(FPCore (x y) :precision binary64 (if (<= x -9.5e+15) (* (- x y) (/ -1.0 x)) (if (<= x 2.7e+99) (* (- x y) (/ 1.0 (- 2.0 y))) -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -9.5e+15) {
tmp = (x - y) * (-1.0 / x);
} else if (x <= 2.7e+99) {
tmp = (x - y) * (1.0 / (2.0 - y));
} 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 <= (-9.5d+15)) then
tmp = (x - y) * ((-1.0d0) / x)
else if (x <= 2.7d+99) then
tmp = (x - y) * (1.0d0 / (2.0d0 - y))
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -9.5e+15) {
tmp = (x - y) * (-1.0 / x);
} else if (x <= 2.7e+99) {
tmp = (x - y) * (1.0 / (2.0 - y));
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9.5e+15: tmp = (x - y) * (-1.0 / x) elif x <= 2.7e+99: tmp = (x - y) * (1.0 / (2.0 - y)) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -9.5e+15) tmp = Float64(Float64(x - y) * Float64(-1.0 / x)); elseif (x <= 2.7e+99) tmp = Float64(Float64(x - y) * Float64(1.0 / Float64(2.0 - y))); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9.5e+15) tmp = (x - y) * (-1.0 / x); elseif (x <= 2.7e+99) tmp = (x - y) * (1.0 / (2.0 - y)); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9.5e+15], N[(N[(x - y), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.7e+99], N[(N[(x - y), $MachinePrecision] * N[(1.0 / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+15}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{-1}{x}\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+99}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{1}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.5e15Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.9%
associate-/r/99.8%
associate--l-99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 78.0%
if -9.5e15 < x < 2.69999999999999989e99Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.8%
associate-/r/99.8%
associate--l-99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 92.9%
if 2.69999999999999989e99 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 97.2%
Final simplification90.2%
(FPCore (x y) :precision binary64 (if (<= y -1.9e+61) 1.0 (if (<= y 5.2e+32) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.9e+61) {
tmp = 1.0;
} else if (y <= 5.2e+32) {
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.9d+61)) then
tmp = 1.0d0
else if (y <= 5.2d+32) 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.9e+61) {
tmp = 1.0;
} else if (y <= 5.2e+32) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.9e+61: tmp = 1.0 elif y <= 5.2e+32: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.9e+61) tmp = 1.0; elseif (y <= 5.2e+32) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.9e+61) tmp = 1.0; elseif (y <= 5.2e+32) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.9e+61], 1.0, If[LessEqual[y, 5.2e+32], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+61}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{+32}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.89999999999999998e61 or 5.2000000000000004e32 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 87.7%
if -1.89999999999999998e61 < y < 5.2000000000000004e32Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 53.0%
Final simplification67.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%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 35.6%
Final simplification35.6%
(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 2023195
(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))))