
(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 (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
(let* ((t_0 (* (- x y) 0.5)) (t_1 (+ (/ y x) -1.0)))
(if (<= x -5.8e+24)
t_1
(if (<= x -1.05e-32)
1.0
(if (<= x 8e-279)
t_0
(if (<= x 9e-110)
1.0
(if (<= x 3.5e-55) t_0 (if (<= x 1.82e+68) 1.0 t_1))))))))
double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double t_1 = (y / x) + -1.0;
double tmp;
if (x <= -5.8e+24) {
tmp = t_1;
} else if (x <= -1.05e-32) {
tmp = 1.0;
} else if (x <= 8e-279) {
tmp = t_0;
} else if (x <= 9e-110) {
tmp = 1.0;
} else if (x <= 3.5e-55) {
tmp = t_0;
} else if (x <= 1.82e+68) {
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 = (y / x) + (-1.0d0)
if (x <= (-5.8d+24)) then
tmp = t_1
else if (x <= (-1.05d-32)) then
tmp = 1.0d0
else if (x <= 8d-279) then
tmp = t_0
else if (x <= 9d-110) then
tmp = 1.0d0
else if (x <= 3.5d-55) then
tmp = t_0
else if (x <= 1.82d+68) 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 = (y / x) + -1.0;
double tmp;
if (x <= -5.8e+24) {
tmp = t_1;
} else if (x <= -1.05e-32) {
tmp = 1.0;
} else if (x <= 8e-279) {
tmp = t_0;
} else if (x <= 9e-110) {
tmp = 1.0;
} else if (x <= 3.5e-55) {
tmp = t_0;
} else if (x <= 1.82e+68) {
tmp = 1.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = (x - y) * 0.5 t_1 = (y / x) + -1.0 tmp = 0 if x <= -5.8e+24: tmp = t_1 elif x <= -1.05e-32: tmp = 1.0 elif x <= 8e-279: tmp = t_0 elif x <= 9e-110: tmp = 1.0 elif x <= 3.5e-55: tmp = t_0 elif x <= 1.82e+68: tmp = 1.0 else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) * 0.5) t_1 = Float64(Float64(y / x) + -1.0) tmp = 0.0 if (x <= -5.8e+24) tmp = t_1; elseif (x <= -1.05e-32) tmp = 1.0; elseif (x <= 8e-279) tmp = t_0; elseif (x <= 9e-110) tmp = 1.0; elseif (x <= 3.5e-55) tmp = t_0; elseif (x <= 1.82e+68) 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 = (y / x) + -1.0; tmp = 0.0; if (x <= -5.8e+24) tmp = t_1; elseif (x <= -1.05e-32) tmp = 1.0; elseif (x <= 8e-279) tmp = t_0; elseif (x <= 9e-110) tmp = 1.0; elseif (x <= 3.5e-55) tmp = t_0; elseif (x <= 1.82e+68) 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[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[x, -5.8e+24], t$95$1, If[LessEqual[x, -1.05e-32], 1.0, If[LessEqual[x, 8e-279], t$95$0, If[LessEqual[x, 9e-110], 1.0, If[LessEqual[x, 3.5e-55], t$95$0, If[LessEqual[x, 1.82e+68], 1.0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot 0.5\\
t_1 := \frac{y}{x} + -1\\
\mathbf{if}\;x \leq -5.8 \cdot 10^{+24}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.05 \cdot 10^{-32}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-279}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-110}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{-55}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.82 \cdot 10^{+68}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -5.79999999999999958e24 or 1.81999999999999991e68 < x 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 x around inf 81.6%
Taylor expanded in x around 0 81.9%
if -5.79999999999999958e24 < x < -1.05e-32 or 8.00000000000000044e-279 < x < 9.0000000000000002e-110 or 3.50000000000000025e-55 < x < 1.81999999999999991e68Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 62.6%
if -1.05e-32 < x < 8.00000000000000044e-279 or 9.0000000000000002e-110 < x < 3.50000000000000025e-55Initial 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 99.8%
Taylor expanded in y around 0 64.2%
Final simplification71.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (- x y) 0.5)))
(if (<= x -5.9e+23)
-1.0
(if (<= x -1.26e-33)
1.0
(if (<= x 3.1e-280)
t_0
(if (<= x 5.2e-109)
1.0
(if (<= x 2.5e-55) t_0 (if (<= x 3.15e+63) 1.0 -1.0))))))))
double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double tmp;
if (x <= -5.9e+23) {
tmp = -1.0;
} else if (x <= -1.26e-33) {
tmp = 1.0;
} else if (x <= 3.1e-280) {
tmp = t_0;
} else if (x <= 5.2e-109) {
tmp = 1.0;
} else if (x <= 2.5e-55) {
tmp = t_0;
} else if (x <= 3.15e+63) {
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 (x <= (-5.9d+23)) then
tmp = -1.0d0
else if (x <= (-1.26d-33)) then
tmp = 1.0d0
else if (x <= 3.1d-280) then
tmp = t_0
else if (x <= 5.2d-109) then
tmp = 1.0d0
else if (x <= 2.5d-55) then
tmp = t_0
else if (x <= 3.15d+63) 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 (x <= -5.9e+23) {
tmp = -1.0;
} else if (x <= -1.26e-33) {
tmp = 1.0;
} else if (x <= 3.1e-280) {
tmp = t_0;
} else if (x <= 5.2e-109) {
tmp = 1.0;
} else if (x <= 2.5e-55) {
tmp = t_0;
} else if (x <= 3.15e+63) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = (x - y) * 0.5 tmp = 0 if x <= -5.9e+23: tmp = -1.0 elif x <= -1.26e-33: tmp = 1.0 elif x <= 3.1e-280: tmp = t_0 elif x <= 5.2e-109: tmp = 1.0 elif x <= 2.5e-55: tmp = t_0 elif x <= 3.15e+63: 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 (x <= -5.9e+23) tmp = -1.0; elseif (x <= -1.26e-33) tmp = 1.0; elseif (x <= 3.1e-280) tmp = t_0; elseif (x <= 5.2e-109) tmp = 1.0; elseif (x <= 2.5e-55) tmp = t_0; elseif (x <= 3.15e+63) 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 (x <= -5.9e+23) tmp = -1.0; elseif (x <= -1.26e-33) tmp = 1.0; elseif (x <= 3.1e-280) tmp = t_0; elseif (x <= 5.2e-109) tmp = 1.0; elseif (x <= 2.5e-55) tmp = t_0; elseif (x <= 3.15e+63) 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[x, -5.9e+23], -1.0, If[LessEqual[x, -1.26e-33], 1.0, If[LessEqual[x, 3.1e-280], t$95$0, If[LessEqual[x, 5.2e-109], 1.0, If[LessEqual[x, 2.5e-55], t$95$0, If[LessEqual[x, 3.15e+63], 1.0, -1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot 0.5\\
\mathbf{if}\;x \leq -5.9 \cdot 10^{+23}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.26 \cdot 10^{-33}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-280}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-109}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-55}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.15 \cdot 10^{+63}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -5.89999999999999987e23 or 3.1499999999999999e63 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 81.5%
if -5.89999999999999987e23 < x < -1.26000000000000005e-33 or 3.10000000000000021e-280 < x < 5.1999999999999997e-109 or 2.5000000000000001e-55 < x < 3.1499999999999999e63Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 62.6%
if -1.26000000000000005e-33 < x < 3.10000000000000021e-280 or 5.1999999999999997e-109 < x < 2.5000000000000001e-55Initial 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 99.8%
Taylor expanded in y around 0 64.2%
Final simplification71.8%
(FPCore (x y) :precision binary64 (if (<= x -78.0) (/ x (- 2.0 x)) (if (<= x 7.5e+68) (/ (- x y) (- 2.0 y)) (+ (/ y x) -1.0))))
double code(double x, double y) {
double tmp;
if (x <= -78.0) {
tmp = x / (2.0 - x);
} else if (x <= 7.5e+68) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = (y / x) + -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 <= (-78.0d0)) then
tmp = x / (2.0d0 - x)
else if (x <= 7.5d+68) then
tmp = (x - y) / (2.0d0 - y)
else
tmp = (y / x) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -78.0) {
tmp = x / (2.0 - x);
} else if (x <= 7.5e+68) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = (y / x) + -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -78.0: tmp = x / (2.0 - x) elif x <= 7.5e+68: tmp = (x - y) / (2.0 - y) else: tmp = (y / x) + -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -78.0) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 7.5e+68) tmp = Float64(Float64(x - y) / Float64(2.0 - y)); else tmp = Float64(Float64(y / x) + -1.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -78.0) tmp = x / (2.0 - x); elseif (x <= 7.5e+68) tmp = (x - y) / (2.0 - y); else tmp = (y / x) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -78.0], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.5e+68], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -78:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+68}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x} + -1\\
\end{array}
\end{array}
if x < -78Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 75.4%
if -78 < x < 7.49999999999999959e68Initial program 99.9%
associate--r+99.9%
Simplified99.9%
clear-num99.8%
associate-/r/99.8%
associate--l-99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 95.6%
Taylor expanded in x around 0 95.7%
+-commutative95.7%
mul-1-neg95.7%
sub-neg95.7%
div-sub95.7%
Simplified95.7%
if 7.49999999999999959e68 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.6%
associate--l-99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 86.5%
Taylor expanded in x around 0 86.7%
Final simplification88.1%
(FPCore (x y)
:precision binary64
(if (<= x -1e+23)
-1.0
(if (<= x -1.55e-130)
1.0
(if (<= x 8.6e-280) (* y -0.5) (if (<= x 1.28e+64) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1e+23) {
tmp = -1.0;
} else if (x <= -1.55e-130) {
tmp = 1.0;
} else if (x <= 8.6e-280) {
tmp = y * -0.5;
} else if (x <= 1.28e+64) {
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 <= (-1d+23)) then
tmp = -1.0d0
else if (x <= (-1.55d-130)) then
tmp = 1.0d0
else if (x <= 8.6d-280) then
tmp = y * (-0.5d0)
else if (x <= 1.28d+64) 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 <= -1e+23) {
tmp = -1.0;
} else if (x <= -1.55e-130) {
tmp = 1.0;
} else if (x <= 8.6e-280) {
tmp = y * -0.5;
} else if (x <= 1.28e+64) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e+23: tmp = -1.0 elif x <= -1.55e-130: tmp = 1.0 elif x <= 8.6e-280: tmp = y * -0.5 elif x <= 1.28e+64: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1e+23) tmp = -1.0; elseif (x <= -1.55e-130) tmp = 1.0; elseif (x <= 8.6e-280) tmp = Float64(y * -0.5); elseif (x <= 1.28e+64) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e+23) tmp = -1.0; elseif (x <= -1.55e-130) tmp = 1.0; elseif (x <= 8.6e-280) tmp = y * -0.5; elseif (x <= 1.28e+64) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e+23], -1.0, If[LessEqual[x, -1.55e-130], 1.0, If[LessEqual[x, 8.6e-280], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1.28e+64], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+23}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-130}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 8.6 \cdot 10^{-280}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 1.28 \cdot 10^{+64}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.9999999999999992e22 or 1.28000000000000004e64 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 81.5%
if -9.9999999999999992e22 < x < -1.55000000000000005e-130 or 8.5999999999999997e-280 < x < 1.28000000000000004e64Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 56.0%
if -1.55000000000000005e-130 < x < 8.5999999999999997e-280Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around 0 86.4%
mul-1-neg86.4%
distribute-neg-frac86.4%
Simplified86.4%
Taylor expanded in y around 0 51.8%
*-commutative51.8%
Simplified51.8%
Final simplification67.3%
(FPCore (x y) :precision binary64 (if (<= y -6e+62) 1.0 (if (<= y 4.4e+88) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -6e+62) {
tmp = 1.0;
} else if (y <= 4.4e+88) {
tmp = x / (2.0 - x);
} 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 <= (-6d+62)) then
tmp = 1.0d0
else if (y <= 4.4d+88) then
tmp = x / (2.0d0 - x)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -6e+62) {
tmp = 1.0;
} else if (y <= 4.4e+88) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6e+62: tmp = 1.0 elif y <= 4.4e+88: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -6e+62) tmp = 1.0; elseif (y <= 4.4e+88) tmp = Float64(x / Float64(2.0 - x)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -6e+62) tmp = 1.0; elseif (y <= 4.4e+88) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6e+62], 1.0, If[LessEqual[y, 4.4e+88], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+62}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{+88}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -6e62 or 4.40000000000000017e88 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 81.1%
if -6e62 < y < 4.40000000000000017e88Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 73.7%
Final simplification76.6%
(FPCore (x y) :precision binary64 (if (<= x -270.0) (/ x (- 2.0 x)) (if (<= x 2.85e+68) (/ y (+ y -2.0)) (+ (/ y x) -1.0))))
double code(double x, double y) {
double tmp;
if (x <= -270.0) {
tmp = x / (2.0 - x);
} else if (x <= 2.85e+68) {
tmp = y / (y + -2.0);
} else {
tmp = (y / x) + -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 <= (-270.0d0)) then
tmp = x / (2.0d0 - x)
else if (x <= 2.85d+68) then
tmp = y / (y + (-2.0d0))
else
tmp = (y / x) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -270.0) {
tmp = x / (2.0 - x);
} else if (x <= 2.85e+68) {
tmp = y / (y + -2.0);
} else {
tmp = (y / x) + -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -270.0: tmp = x / (2.0 - x) elif x <= 2.85e+68: tmp = y / (y + -2.0) else: tmp = (y / x) + -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -270.0) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 2.85e+68) tmp = Float64(y / Float64(y + -2.0)); else tmp = Float64(Float64(y / x) + -1.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -270.0) tmp = x / (2.0 - x); elseif (x <= 2.85e+68) tmp = y / (y + -2.0); else tmp = (y / x) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -270.0], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.85e+68], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -270:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 2.85 \cdot 10^{+68}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x} + -1\\
\end{array}
\end{array}
if x < -270Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 75.4%
if -270 < x < 2.8499999999999998e68Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around 0 75.8%
mul-1-neg75.8%
distribute-neg-frac75.8%
Simplified75.8%
frac-2neg75.8%
div-inv75.7%
remove-double-neg75.7%
sub-neg75.7%
distribute-neg-in75.7%
metadata-eval75.7%
remove-double-neg75.7%
Applied egg-rr75.7%
associate-*r/75.8%
*-rgt-identity75.8%
+-commutative75.8%
Simplified75.8%
if 2.8499999999999998e68 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.6%
associate--l-99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 86.5%
Taylor expanded in x around 0 86.7%
Final simplification78.0%
(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 -4e+21) -1.0 (if (<= x 2.3e+63) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -4e+21) {
tmp = -1.0;
} else if (x <= 2.3e+63) {
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 <= (-4d+21)) then
tmp = -1.0d0
else if (x <= 2.3d+63) 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 <= -4e+21) {
tmp = -1.0;
} else if (x <= 2.3e+63) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4e+21: tmp = -1.0 elif x <= 2.3e+63: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -4e+21) tmp = -1.0; elseif (x <= 2.3e+63) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -4e+21) tmp = -1.0; elseif (x <= 2.3e+63) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4e+21], -1.0, If[LessEqual[x, 2.3e+63], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+21}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+63}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -4e21 or 2.29999999999999993e63 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 81.5%
if -4e21 < x < 2.29999999999999993e63Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 50.6%
Final simplification65.0%
(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 41.5%
Final simplification41.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 2023252
(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))))