
(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 7 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
(let* ((t_0 (/ y (+ y -2.0))) (t_1 (- -1.0 (/ (- (- 2.0 y) y) x))))
(if (<= y -3.1e+116)
1.0
(if (<= y -1.25e+61)
t_1
(if (<= y -2.9e-9)
t_0
(if (<= y -3.2e-44)
t_1
(if (<= y -2.1e-93)
(* y -0.5)
(if (<= y 5.2e-69) (/ x (- 2.0 x)) t_0))))))))
double code(double x, double y) {
double t_0 = y / (y + -2.0);
double t_1 = -1.0 - (((2.0 - y) - y) / x);
double tmp;
if (y <= -3.1e+116) {
tmp = 1.0;
} else if (y <= -1.25e+61) {
tmp = t_1;
} else if (y <= -2.9e-9) {
tmp = t_0;
} else if (y <= -3.2e-44) {
tmp = t_1;
} else if (y <= -2.1e-93) {
tmp = y * -0.5;
} else if (y <= 5.2e-69) {
tmp = x / (2.0 - x);
} 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 = y / (y + (-2.0d0))
t_1 = (-1.0d0) - (((2.0d0 - y) - y) / x)
if (y <= (-3.1d+116)) then
tmp = 1.0d0
else if (y <= (-1.25d+61)) then
tmp = t_1
else if (y <= (-2.9d-9)) then
tmp = t_0
else if (y <= (-3.2d-44)) then
tmp = t_1
else if (y <= (-2.1d-93)) then
tmp = y * (-0.5d0)
else if (y <= 5.2d-69) then
tmp = x / (2.0d0 - x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (y + -2.0);
double t_1 = -1.0 - (((2.0 - y) - y) / x);
double tmp;
if (y <= -3.1e+116) {
tmp = 1.0;
} else if (y <= -1.25e+61) {
tmp = t_1;
} else if (y <= -2.9e-9) {
tmp = t_0;
} else if (y <= -3.2e-44) {
tmp = t_1;
} else if (y <= -2.1e-93) {
tmp = y * -0.5;
} else if (y <= 5.2e-69) {
tmp = x / (2.0 - x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y / (y + -2.0) t_1 = -1.0 - (((2.0 - y) - y) / x) tmp = 0 if y <= -3.1e+116: tmp = 1.0 elif y <= -1.25e+61: tmp = t_1 elif y <= -2.9e-9: tmp = t_0 elif y <= -3.2e-44: tmp = t_1 elif y <= -2.1e-93: tmp = y * -0.5 elif y <= 5.2e-69: tmp = x / (2.0 - x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y / Float64(y + -2.0)) t_1 = Float64(-1.0 - Float64(Float64(Float64(2.0 - y) - y) / x)) tmp = 0.0 if (y <= -3.1e+116) tmp = 1.0; elseif (y <= -1.25e+61) tmp = t_1; elseif (y <= -2.9e-9) tmp = t_0; elseif (y <= -3.2e-44) tmp = t_1; elseif (y <= -2.1e-93) tmp = Float64(y * -0.5); elseif (y <= 5.2e-69) tmp = Float64(x / Float64(2.0 - x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y + -2.0); t_1 = -1.0 - (((2.0 - y) - y) / x); tmp = 0.0; if (y <= -3.1e+116) tmp = 1.0; elseif (y <= -1.25e+61) tmp = t_1; elseif (y <= -2.9e-9) tmp = t_0; elseif (y <= -3.2e-44) tmp = t_1; elseif (y <= -2.1e-93) tmp = y * -0.5; elseif (y <= 5.2e-69) tmp = x / (2.0 - x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 - N[(N[(N[(2.0 - y), $MachinePrecision] - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.1e+116], 1.0, If[LessEqual[y, -1.25e+61], t$95$1, If[LessEqual[y, -2.9e-9], t$95$0, If[LessEqual[y, -3.2e-44], t$95$1, If[LessEqual[y, -2.1e-93], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 5.2e-69], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y + -2}\\
t_1 := -1 - \frac{\left(2 - y\right) - y}{x}\\
\mathbf{if}\;y \leq -3.1 \cdot 10^{+116}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.25 \cdot 10^{+61}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -2.9 \cdot 10^{-9}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -3.2 \cdot 10^{-44}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{-93}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-69}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -3.09999999999999996e116Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 86.7%
if -3.09999999999999996e116 < y < -1.25000000000000004e61 or -2.89999999999999991e-9 < y < -3.19999999999999995e-44Initial program 100.0%
associate--r+100.0%
Simplified100.0%
div-sub100.0%
flip--67.5%
associate-/r/67.4%
associate-/r/67.5%
flip--100.0%
associate--l-100.0%
associate--l-100.0%
Applied egg-rr100.0%
sub-div100.0%
clear-num99.9%
Applied egg-rr99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
Applied egg-rr99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 81.0%
sub-neg81.0%
metadata-eval81.0%
+-commutative81.0%
associate-*r/81.0%
Simplified81.0%
if -1.25000000000000004e61 < y < -2.89999999999999991e-9 or 5.2000000000000004e-69 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around 0 75.8%
associate-*r/75.8%
neg-mul-175.8%
Simplified75.8%
distribute-frac-neg75.8%
neg-sub075.8%
div-inv75.5%
cancel-sign-sub-inv75.5%
div-inv75.8%
frac-2neg75.8%
remove-double-neg75.8%
sub-neg75.8%
distribute-neg-in75.8%
metadata-eval75.8%
remove-double-neg75.8%
Applied egg-rr75.8%
+-lft-identity75.8%
+-commutative75.8%
Simplified75.8%
if -3.19999999999999995e-44 < y < -2.1000000000000001e-93Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 78.2%
associate-*r/78.2%
neg-mul-178.2%
Simplified78.2%
Taylor expanded in y around 0 78.2%
*-commutative78.2%
Simplified78.2%
if -2.1000000000000001e-93 < y < 5.2000000000000004e-69Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 89.7%
Final simplification83.3%
(FPCore (x y)
:precision binary64
(if (<= y -5000000000000.0)
1.0
(if (<= y -1.95e-44)
-1.0
(if (<= y -3.55e-96)
(* y -0.5)
(if (<= y 2e-71)
-1.0
(if (<= y 7.2e-38) (* y -0.5) (if (<= y 1.4e+22) -1.0 1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -5000000000000.0) {
tmp = 1.0;
} else if (y <= -1.95e-44) {
tmp = -1.0;
} else if (y <= -3.55e-96) {
tmp = y * -0.5;
} else if (y <= 2e-71) {
tmp = -1.0;
} else if (y <= 7.2e-38) {
tmp = y * -0.5;
} else if (y <= 1.4e+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 <= (-5000000000000.0d0)) then
tmp = 1.0d0
else if (y <= (-1.95d-44)) then
tmp = -1.0d0
else if (y <= (-3.55d-96)) then
tmp = y * (-0.5d0)
else if (y <= 2d-71) then
tmp = -1.0d0
else if (y <= 7.2d-38) then
tmp = y * (-0.5d0)
else if (y <= 1.4d+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 <= -5000000000000.0) {
tmp = 1.0;
} else if (y <= -1.95e-44) {
tmp = -1.0;
} else if (y <= -3.55e-96) {
tmp = y * -0.5;
} else if (y <= 2e-71) {
tmp = -1.0;
} else if (y <= 7.2e-38) {
tmp = y * -0.5;
} else if (y <= 1.4e+22) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5000000000000.0: tmp = 1.0 elif y <= -1.95e-44: tmp = -1.0 elif y <= -3.55e-96: tmp = y * -0.5 elif y <= 2e-71: tmp = -1.0 elif y <= 7.2e-38: tmp = y * -0.5 elif y <= 1.4e+22: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5000000000000.0) tmp = 1.0; elseif (y <= -1.95e-44) tmp = -1.0; elseif (y <= -3.55e-96) tmp = Float64(y * -0.5); elseif (y <= 2e-71) tmp = -1.0; elseif (y <= 7.2e-38) tmp = Float64(y * -0.5); elseif (y <= 1.4e+22) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5000000000000.0) tmp = 1.0; elseif (y <= -1.95e-44) tmp = -1.0; elseif (y <= -3.55e-96) tmp = y * -0.5; elseif (y <= 2e-71) tmp = -1.0; elseif (y <= 7.2e-38) tmp = y * -0.5; elseif (y <= 1.4e+22) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5000000000000.0], 1.0, If[LessEqual[y, -1.95e-44], -1.0, If[LessEqual[y, -3.55e-96], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 2e-71], -1.0, If[LessEqual[y, 7.2e-38], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.4e+22], -1.0, 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5000000000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.95 \cdot 10^{-44}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -3.55 \cdot 10^{-96}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-71}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{-38}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+22}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5e12 or 1.4e22 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 79.7%
if -5e12 < y < -1.9500000000000001e-44 or -3.55000000000000019e-96 < y < 1.9999999999999998e-71 or 7.2000000000000001e-38 < y < 1.4e22Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 59.5%
if -1.9500000000000001e-44 < y < -3.55000000000000019e-96 or 1.9999999999999998e-71 < y < 7.2000000000000001e-38Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 80.4%
associate-*r/80.4%
neg-mul-180.4%
Simplified80.4%
Taylor expanded in y around 0 80.4%
*-commutative80.4%
Simplified80.4%
Final simplification69.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -800000000000.0)
1.0
(if (<= y -9.5e-44)
t_0
(if (<= y -7.2e-88)
(* y -0.5)
(if (<= y 8.5e-70)
t_0
(if (<= y 4.6e-38) (* y -0.5) (if (<= y 1.45e+22) -1.0 1.0))))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -800000000000.0) {
tmp = 1.0;
} else if (y <= -9.5e-44) {
tmp = t_0;
} else if (y <= -7.2e-88) {
tmp = y * -0.5;
} else if (y <= 8.5e-70) {
tmp = t_0;
} else if (y <= 4.6e-38) {
tmp = y * -0.5;
} else if (y <= 1.45e+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) :: t_0
real(8) :: tmp
t_0 = x / (2.0d0 - x)
if (y <= (-800000000000.0d0)) then
tmp = 1.0d0
else if (y <= (-9.5d-44)) then
tmp = t_0
else if (y <= (-7.2d-88)) then
tmp = y * (-0.5d0)
else if (y <= 8.5d-70) then
tmp = t_0
else if (y <= 4.6d-38) then
tmp = y * (-0.5d0)
else if (y <= 1.45d+22) 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 <= -800000000000.0) {
tmp = 1.0;
} else if (y <= -9.5e-44) {
tmp = t_0;
} else if (y <= -7.2e-88) {
tmp = y * -0.5;
} else if (y <= 8.5e-70) {
tmp = t_0;
} else if (y <= 4.6e-38) {
tmp = y * -0.5;
} else if (y <= 1.45e+22) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -800000000000.0: tmp = 1.0 elif y <= -9.5e-44: tmp = t_0 elif y <= -7.2e-88: tmp = y * -0.5 elif y <= 8.5e-70: tmp = t_0 elif y <= 4.6e-38: tmp = y * -0.5 elif y <= 1.45e+22: 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 <= -800000000000.0) tmp = 1.0; elseif (y <= -9.5e-44) tmp = t_0; elseif (y <= -7.2e-88) tmp = Float64(y * -0.5); elseif (y <= 8.5e-70) tmp = t_0; elseif (y <= 4.6e-38) tmp = Float64(y * -0.5); elseif (y <= 1.45e+22) 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 <= -800000000000.0) tmp = 1.0; elseif (y <= -9.5e-44) tmp = t_0; elseif (y <= -7.2e-88) tmp = y * -0.5; elseif (y <= 8.5e-70) tmp = t_0; elseif (y <= 4.6e-38) tmp = y * -0.5; elseif (y <= 1.45e+22) 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, -800000000000.0], 1.0, If[LessEqual[y, -9.5e-44], t$95$0, If[LessEqual[y, -7.2e-88], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 8.5e-70], t$95$0, If[LessEqual[y, 4.6e-38], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.45e+22], -1.0, 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -800000000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -9.5 \cdot 10^{-44}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -7.2 \cdot 10^{-88}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-70}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{-38}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+22}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -8e11 or 1.45e22 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 79.7%
if -8e11 < y < -9.49999999999999924e-44 or -7.1999999999999999e-88 < y < 8.5000000000000002e-70Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 87.1%
if -9.49999999999999924e-44 < y < -7.1999999999999999e-88 or 8.5000000000000002e-70 < y < 4.60000000000000003e-38Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 80.4%
associate-*r/80.4%
neg-mul-180.4%
Simplified80.4%
Taylor expanded in y around 0 80.4%
*-commutative80.4%
Simplified80.4%
if 4.60000000000000003e-38 < y < 1.45e22Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 68.0%
Final simplification82.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ y -2.0))) (t_1 (/ x (- 2.0 x))))
(if (<= y -3e-7)
t_0
(if (<= y -1.8e-44)
t_1
(if (<= y -7.2e-88) (* y -0.5) (if (<= y 1.25e-70) t_1 t_0))))))
double code(double x, double y) {
double t_0 = y / (y + -2.0);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -3e-7) {
tmp = t_0;
} else if (y <= -1.8e-44) {
tmp = t_1;
} else if (y <= -7.2e-88) {
tmp = y * -0.5;
} else if (y <= 1.25e-70) {
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 = y / (y + (-2.0d0))
t_1 = x / (2.0d0 - x)
if (y <= (-3d-7)) then
tmp = t_0
else if (y <= (-1.8d-44)) then
tmp = t_1
else if (y <= (-7.2d-88)) then
tmp = y * (-0.5d0)
else if (y <= 1.25d-70) 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 = y / (y + -2.0);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -3e-7) {
tmp = t_0;
} else if (y <= -1.8e-44) {
tmp = t_1;
} else if (y <= -7.2e-88) {
tmp = y * -0.5;
} else if (y <= 1.25e-70) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y / (y + -2.0) t_1 = x / (2.0 - x) tmp = 0 if y <= -3e-7: tmp = t_0 elif y <= -1.8e-44: tmp = t_1 elif y <= -7.2e-88: tmp = y * -0.5 elif y <= 1.25e-70: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y / Float64(y + -2.0)) t_1 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -3e-7) tmp = t_0; elseif (y <= -1.8e-44) tmp = t_1; elseif (y <= -7.2e-88) tmp = Float64(y * -0.5); elseif (y <= 1.25e-70) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y + -2.0); t_1 = x / (2.0 - x); tmp = 0.0; if (y <= -3e-7) tmp = t_0; elseif (y <= -1.8e-44) tmp = t_1; elseif (y <= -7.2e-88) tmp = y * -0.5; elseif (y <= 1.25e-70) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3e-7], t$95$0, If[LessEqual[y, -1.8e-44], t$95$1, If[LessEqual[y, -7.2e-88], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.25e-70], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y + -2}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -3 \cdot 10^{-7}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.8 \cdot 10^{-44}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -7.2 \cdot 10^{-88}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-70}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.9999999999999999e-7 or 1.25e-70 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around 0 75.7%
associate-*r/75.7%
neg-mul-175.7%
Simplified75.7%
distribute-frac-neg75.7%
neg-sub075.7%
div-inv75.4%
cancel-sign-sub-inv75.4%
div-inv75.7%
frac-2neg75.7%
remove-double-neg75.7%
sub-neg75.7%
distribute-neg-in75.7%
metadata-eval75.7%
remove-double-neg75.7%
Applied egg-rr75.7%
+-lft-identity75.7%
+-commutative75.7%
Simplified75.7%
if -2.9999999999999999e-7 < y < -1.7999999999999999e-44 or -7.1999999999999999e-88 < y < 1.25e-70Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 89.4%
if -1.7999999999999999e-44 < y < -7.1999999999999999e-88Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 78.2%
associate-*r/78.2%
neg-mul-178.2%
Simplified78.2%
Taylor expanded in y around 0 78.2%
*-commutative78.2%
Simplified78.2%
Final simplification81.7%
(FPCore (x y) :precision binary64 (if (<= y -1060000000000.0) 1.0 (if (<= y 1.4e+22) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1060000000000.0) {
tmp = 1.0;
} else if (y <= 1.4e+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 <= (-1060000000000.0d0)) then
tmp = 1.0d0
else if (y <= 1.4d+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 <= -1060000000000.0) {
tmp = 1.0;
} else if (y <= 1.4e+22) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1060000000000.0: tmp = 1.0 elif y <= 1.4e+22: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1060000000000.0) tmp = 1.0; elseif (y <= 1.4e+22) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1060000000000.0) tmp = 1.0; elseif (y <= 1.4e+22) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1060000000000.0], 1.0, If[LessEqual[y, 1.4e+22], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1060000000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+22}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.06e12 or 1.4e22 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 79.7%
if -1.06e12 < y < 1.4e22Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 54.4%
Final simplification65.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 38.8%
Final simplification38.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 2023297
(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))))