
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
(FPCore (x y) :precision binary64 (/ (- 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 -1.5e+19)
-1.0
(if (<= x -7.8e-7)
1.0
(if (<= x -1.55e-101)
(* x 0.5)
(if (<= x -9.6e-189)
1.0
(if (<= x -9.2e-246)
(* y -0.5)
(if (<= x 3e-37)
1.0
(if (<= x 9.5e-14)
(* x 0.5)
(if (<= x 45000000000000.0) 1.0 -1.0)))))))))
double code(double x, double y) {
double tmp;
if (x <= -1.5e+19) {
tmp = -1.0;
} else if (x <= -7.8e-7) {
tmp = 1.0;
} else if (x <= -1.55e-101) {
tmp = x * 0.5;
} else if (x <= -9.6e-189) {
tmp = 1.0;
} else if (x <= -9.2e-246) {
tmp = y * -0.5;
} else if (x <= 3e-37) {
tmp = 1.0;
} else if (x <= 9.5e-14) {
tmp = x * 0.5;
} else if (x <= 45000000000000.0) {
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 <= (-1.5d+19)) then
tmp = -1.0d0
else if (x <= (-7.8d-7)) then
tmp = 1.0d0
else if (x <= (-1.55d-101)) then
tmp = x * 0.5d0
else if (x <= (-9.6d-189)) then
tmp = 1.0d0
else if (x <= (-9.2d-246)) then
tmp = y * (-0.5d0)
else if (x <= 3d-37) then
tmp = 1.0d0
else if (x <= 9.5d-14) then
tmp = x * 0.5d0
else if (x <= 45000000000000.0d0) 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 <= -1.5e+19) {
tmp = -1.0;
} else if (x <= -7.8e-7) {
tmp = 1.0;
} else if (x <= -1.55e-101) {
tmp = x * 0.5;
} else if (x <= -9.6e-189) {
tmp = 1.0;
} else if (x <= -9.2e-246) {
tmp = y * -0.5;
} else if (x <= 3e-37) {
tmp = 1.0;
} else if (x <= 9.5e-14) {
tmp = x * 0.5;
} else if (x <= 45000000000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.5e+19: tmp = -1.0 elif x <= -7.8e-7: tmp = 1.0 elif x <= -1.55e-101: tmp = x * 0.5 elif x <= -9.6e-189: tmp = 1.0 elif x <= -9.2e-246: tmp = y * -0.5 elif x <= 3e-37: tmp = 1.0 elif x <= 9.5e-14: tmp = x * 0.5 elif x <= 45000000000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.5e+19) tmp = -1.0; elseif (x <= -7.8e-7) tmp = 1.0; elseif (x <= -1.55e-101) tmp = Float64(x * 0.5); elseif (x <= -9.6e-189) tmp = 1.0; elseif (x <= -9.2e-246) tmp = Float64(y * -0.5); elseif (x <= 3e-37) tmp = 1.0; elseif (x <= 9.5e-14) tmp = Float64(x * 0.5); elseif (x <= 45000000000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.5e+19) tmp = -1.0; elseif (x <= -7.8e-7) tmp = 1.0; elseif (x <= -1.55e-101) tmp = x * 0.5; elseif (x <= -9.6e-189) tmp = 1.0; elseif (x <= -9.2e-246) tmp = y * -0.5; elseif (x <= 3e-37) tmp = 1.0; elseif (x <= 9.5e-14) tmp = x * 0.5; elseif (x <= 45000000000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.5e+19], -1.0, If[LessEqual[x, -7.8e-7], 1.0, If[LessEqual[x, -1.55e-101], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -9.6e-189], 1.0, If[LessEqual[x, -9.2e-246], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 3e-37], 1.0, If[LessEqual[x, 9.5e-14], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 45000000000000.0], 1.0, -1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{+19}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -7.8 \cdot 10^{-7}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-101}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -9.6 \cdot 10^{-189}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -9.2 \cdot 10^{-246}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-37}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-14}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 45000000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.5e19 or 4.5e13 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 82.7%
if -1.5e19 < x < -7.80000000000000049e-7 or -1.54999999999999987e-101 < x < -9.5999999999999994e-189 or -9.199999999999999e-246 < x < 3e-37 or 9.4999999999999999e-14 < x < 4.5e13Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 64.5%
if -7.80000000000000049e-7 < x < -1.54999999999999987e-101 or 3e-37 < x < 9.4999999999999999e-14Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 74.6%
Taylor expanded in x around 0 71.7%
*-commutative71.7%
Simplified71.7%
if -9.5999999999999994e-189 < x < -9.199999999999999e-246Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in y around 0 79.3%
*-commutative79.3%
Simplified79.3%
Final simplification73.9%
(FPCore (x y)
:precision binary64
(if (<= x -1.02e+19)
-1.0
(if (<= x -9e-8)
(+ 1.0 (/ 2.0 y))
(if (<= x -6.2e-102)
(* x 0.5)
(if (<= x -1.25e-189)
1.0
(if (<= x -1.46e-245)
(* y -0.5)
(if (<= x 1.12e-36)
1.0
(if (<= x 6.5e-14)
(* x 0.5)
(if (<= x 42000000000000.0) 1.0 -1.0)))))))))
double code(double x, double y) {
double tmp;
if (x <= -1.02e+19) {
tmp = -1.0;
} else if (x <= -9e-8) {
tmp = 1.0 + (2.0 / y);
} else if (x <= -6.2e-102) {
tmp = x * 0.5;
} else if (x <= -1.25e-189) {
tmp = 1.0;
} else if (x <= -1.46e-245) {
tmp = y * -0.5;
} else if (x <= 1.12e-36) {
tmp = 1.0;
} else if (x <= 6.5e-14) {
tmp = x * 0.5;
} else if (x <= 42000000000000.0) {
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 <= (-1.02d+19)) then
tmp = -1.0d0
else if (x <= (-9d-8)) then
tmp = 1.0d0 + (2.0d0 / y)
else if (x <= (-6.2d-102)) then
tmp = x * 0.5d0
else if (x <= (-1.25d-189)) then
tmp = 1.0d0
else if (x <= (-1.46d-245)) then
tmp = y * (-0.5d0)
else if (x <= 1.12d-36) then
tmp = 1.0d0
else if (x <= 6.5d-14) then
tmp = x * 0.5d0
else if (x <= 42000000000000.0d0) 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 <= -1.02e+19) {
tmp = -1.0;
} else if (x <= -9e-8) {
tmp = 1.0 + (2.0 / y);
} else if (x <= -6.2e-102) {
tmp = x * 0.5;
} else if (x <= -1.25e-189) {
tmp = 1.0;
} else if (x <= -1.46e-245) {
tmp = y * -0.5;
} else if (x <= 1.12e-36) {
tmp = 1.0;
} else if (x <= 6.5e-14) {
tmp = x * 0.5;
} else if (x <= 42000000000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.02e+19: tmp = -1.0 elif x <= -9e-8: tmp = 1.0 + (2.0 / y) elif x <= -6.2e-102: tmp = x * 0.5 elif x <= -1.25e-189: tmp = 1.0 elif x <= -1.46e-245: tmp = y * -0.5 elif x <= 1.12e-36: tmp = 1.0 elif x <= 6.5e-14: tmp = x * 0.5 elif x <= 42000000000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.02e+19) tmp = -1.0; elseif (x <= -9e-8) tmp = Float64(1.0 + Float64(2.0 / y)); elseif (x <= -6.2e-102) tmp = Float64(x * 0.5); elseif (x <= -1.25e-189) tmp = 1.0; elseif (x <= -1.46e-245) tmp = Float64(y * -0.5); elseif (x <= 1.12e-36) tmp = 1.0; elseif (x <= 6.5e-14) tmp = Float64(x * 0.5); elseif (x <= 42000000000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.02e+19) tmp = -1.0; elseif (x <= -9e-8) tmp = 1.0 + (2.0 / y); elseif (x <= -6.2e-102) tmp = x * 0.5; elseif (x <= -1.25e-189) tmp = 1.0; elseif (x <= -1.46e-245) tmp = y * -0.5; elseif (x <= 1.12e-36) tmp = 1.0; elseif (x <= 6.5e-14) tmp = x * 0.5; elseif (x <= 42000000000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.02e+19], -1.0, If[LessEqual[x, -9e-8], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -6.2e-102], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -1.25e-189], 1.0, If[LessEqual[x, -1.46e-245], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1.12e-36], 1.0, If[LessEqual[x, 6.5e-14], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 42000000000000.0], 1.0, -1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.02 \cdot 10^{+19}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -9 \cdot 10^{-8}:\\
\;\;\;\;1 + \frac{2}{y}\\
\mathbf{elif}\;x \leq -6.2 \cdot 10^{-102}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -1.25 \cdot 10^{-189}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1.46 \cdot 10^{-245}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{-36}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{-14}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 42000000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.02e19 or 4.2e13 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 82.7%
if -1.02e19 < x < -8.99999999999999986e-8Initial program 99.8%
associate--r+99.8%
Simplified99.8%
Taylor expanded in y around inf 88.9%
associate--l+88.9%
associate-*r/88.9%
associate-*r/88.9%
div-sub88.9%
cancel-sign-sub-inv88.9%
metadata-eval88.9%
*-lft-identity88.9%
+-commutative88.9%
mul-1-neg88.9%
unsub-neg88.9%
Simplified88.9%
Taylor expanded in x around 0 87.7%
if -8.99999999999999986e-8 < x < -6.20000000000000026e-102 or 1.12e-36 < x < 6.5000000000000001e-14Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 74.6%
Taylor expanded in x around 0 71.7%
*-commutative71.7%
Simplified71.7%
if -6.20000000000000026e-102 < x < -1.2499999999999999e-189 or -1.46000000000000009e-245 < x < 1.12e-36 or 6.5000000000000001e-14 < x < 4.2e13Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 62.7%
if -1.2499999999999999e-189 < x < -1.46000000000000009e-245Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in y around 0 79.3%
*-commutative79.3%
Simplified79.3%
Final simplification73.9%
(FPCore (x y)
:precision binary64
(if (<= x -1e+19)
-1.0
(if (<= x -1.3e-7)
1.0
(if (<= x -3.5e-102)
(* x 0.5)
(if (<= x 1.1e-36)
1.0
(if (<= x 1.45e-13) (* x 0.5) (if (<= x 2.7e+14) 1.0 -1.0)))))))
double code(double x, double y) {
double tmp;
if (x <= -1e+19) {
tmp = -1.0;
} else if (x <= -1.3e-7) {
tmp = 1.0;
} else if (x <= -3.5e-102) {
tmp = x * 0.5;
} else if (x <= 1.1e-36) {
tmp = 1.0;
} else if (x <= 1.45e-13) {
tmp = x * 0.5;
} else if (x <= 2.7e+14) {
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+19)) then
tmp = -1.0d0
else if (x <= (-1.3d-7)) then
tmp = 1.0d0
else if (x <= (-3.5d-102)) then
tmp = x * 0.5d0
else if (x <= 1.1d-36) then
tmp = 1.0d0
else if (x <= 1.45d-13) then
tmp = x * 0.5d0
else if (x <= 2.7d+14) 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+19) {
tmp = -1.0;
} else if (x <= -1.3e-7) {
tmp = 1.0;
} else if (x <= -3.5e-102) {
tmp = x * 0.5;
} else if (x <= 1.1e-36) {
tmp = 1.0;
} else if (x <= 1.45e-13) {
tmp = x * 0.5;
} else if (x <= 2.7e+14) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e+19: tmp = -1.0 elif x <= -1.3e-7: tmp = 1.0 elif x <= -3.5e-102: tmp = x * 0.5 elif x <= 1.1e-36: tmp = 1.0 elif x <= 1.45e-13: tmp = x * 0.5 elif x <= 2.7e+14: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1e+19) tmp = -1.0; elseif (x <= -1.3e-7) tmp = 1.0; elseif (x <= -3.5e-102) tmp = Float64(x * 0.5); elseif (x <= 1.1e-36) tmp = 1.0; elseif (x <= 1.45e-13) tmp = Float64(x * 0.5); elseif (x <= 2.7e+14) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e+19) tmp = -1.0; elseif (x <= -1.3e-7) tmp = 1.0; elseif (x <= -3.5e-102) tmp = x * 0.5; elseif (x <= 1.1e-36) tmp = 1.0; elseif (x <= 1.45e-13) tmp = x * 0.5; elseif (x <= 2.7e+14) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e+19], -1.0, If[LessEqual[x, -1.3e-7], 1.0, If[LessEqual[x, -3.5e-102], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.1e-36], 1.0, If[LessEqual[x, 1.45e-13], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 2.7e+14], 1.0, -1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+19}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.3 \cdot 10^{-7}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -3.5 \cdot 10^{-102}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-36}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-13}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+14}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1e19 or 2.7e14 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 82.7%
if -1e19 < x < -1.29999999999999999e-7 or -3.49999999999999986e-102 < x < 1.1e-36 or 1.4499999999999999e-13 < x < 2.7e14Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 60.1%
if -1.29999999999999999e-7 < x < -3.49999999999999986e-102 or 1.1e-36 < x < 1.4499999999999999e-13Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 74.6%
Taylor expanded in x around 0 71.7%
*-commutative71.7%
Simplified71.7%
Final simplification71.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -2e+37)
1.0
(if (<= y -3.1e-15)
t_0
(if (<= y -1.9e-100) (* y -0.5) (if (<= y 6.1e+29) t_0 1.0))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -2e+37) {
tmp = 1.0;
} else if (y <= -3.1e-15) {
tmp = t_0;
} else if (y <= -1.9e-100) {
tmp = y * -0.5;
} else if (y <= 6.1e+29) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x / (2.0d0 - x)
if (y <= (-2d+37)) then
tmp = 1.0d0
else if (y <= (-3.1d-15)) then
tmp = t_0
else if (y <= (-1.9d-100)) then
tmp = y * (-0.5d0)
else if (y <= 6.1d+29) then
tmp = t_0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -2e+37) {
tmp = 1.0;
} else if (y <= -3.1e-15) {
tmp = t_0;
} else if (y <= -1.9e-100) {
tmp = y * -0.5;
} else if (y <= 6.1e+29) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -2e+37: tmp = 1.0 elif y <= -3.1e-15: tmp = t_0 elif y <= -1.9e-100: tmp = y * -0.5 elif y <= 6.1e+29: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -2e+37) tmp = 1.0; elseif (y <= -3.1e-15) tmp = t_0; elseif (y <= -1.9e-100) tmp = Float64(y * -0.5); elseif (y <= 6.1e+29) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); tmp = 0.0; if (y <= -2e+37) tmp = 1.0; elseif (y <= -3.1e-15) tmp = t_0; elseif (y <= -1.9e-100) tmp = y * -0.5; elseif (y <= 6.1e+29) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2e+37], 1.0, If[LessEqual[y, -3.1e-15], t$95$0, If[LessEqual[y, -1.9e-100], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 6.1e+29], t$95$0, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -2 \cdot 10^{+37}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -3.1 \cdot 10^{-15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.9 \cdot 10^{-100}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 6.1 \cdot 10^{+29}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.99999999999999991e37 or 6.0999999999999998e29 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 79.0%
if -1.99999999999999991e37 < y < -3.0999999999999999e-15 or -1.89999999999999999e-100 < y < 6.0999999999999998e29Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 80.7%
if -3.0999999999999999e-15 < y < -1.89999999999999999e-100Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 66.3%
mul-1-neg66.3%
distribute-neg-frac66.3%
Simplified66.3%
Taylor expanded in y around 0 66.2%
*-commutative66.2%
Simplified66.2%
Final simplification78.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ y -2.0))))
(if (<= x -1.9e+20)
-1.0
(if (<= x -6.5e-33)
t_0
(if (<= x -4.4e-100)
(* x 0.5)
(if (<= x 1.15e-36) t_0 (/ x (- 2.0 x))))))))
double code(double x, double y) {
double t_0 = y / (y + -2.0);
double tmp;
if (x <= -1.9e+20) {
tmp = -1.0;
} else if (x <= -6.5e-33) {
tmp = t_0;
} else if (x <= -4.4e-100) {
tmp = x * 0.5;
} else if (x <= 1.15e-36) {
tmp = t_0;
} else {
tmp = x / (2.0 - x);
}
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 = y / (y + (-2.0d0))
if (x <= (-1.9d+20)) then
tmp = -1.0d0
else if (x <= (-6.5d-33)) then
tmp = t_0
else if (x <= (-4.4d-100)) then
tmp = x * 0.5d0
else if (x <= 1.15d-36) then
tmp = t_0
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (y + -2.0);
double tmp;
if (x <= -1.9e+20) {
tmp = -1.0;
} else if (x <= -6.5e-33) {
tmp = t_0;
} else if (x <= -4.4e-100) {
tmp = x * 0.5;
} else if (x <= 1.15e-36) {
tmp = t_0;
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): t_0 = y / (y + -2.0) tmp = 0 if x <= -1.9e+20: tmp = -1.0 elif x <= -6.5e-33: tmp = t_0 elif x <= -4.4e-100: tmp = x * 0.5 elif x <= 1.15e-36: tmp = t_0 else: tmp = x / (2.0 - x) return tmp
function code(x, y) t_0 = Float64(y / Float64(y + -2.0)) tmp = 0.0 if (x <= -1.9e+20) tmp = -1.0; elseif (x <= -6.5e-33) tmp = t_0; elseif (x <= -4.4e-100) tmp = Float64(x * 0.5); elseif (x <= 1.15e-36) tmp = t_0; else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y + -2.0); tmp = 0.0; if (x <= -1.9e+20) tmp = -1.0; elseif (x <= -6.5e-33) tmp = t_0; elseif (x <= -4.4e-100) tmp = x * 0.5; elseif (x <= 1.15e-36) tmp = t_0; else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.9e+20], -1.0, If[LessEqual[x, -6.5e-33], t$95$0, If[LessEqual[x, -4.4e-100], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.15e-36], t$95$0, N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y + -2}\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{+20}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -6.5 \cdot 10^{-33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4.4 \cdot 10^{-100}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-36}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -1.9e20Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 84.1%
if -1.9e20 < x < -6.4999999999999993e-33 or -4.39999999999999978e-100 < x < 1.14999999999999998e-36Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 85.1%
mul-1-neg85.1%
distribute-neg-frac85.1%
Simplified85.1%
frac-2neg85.1%
div-inv85.0%
remove-double-neg85.0%
sub-neg85.0%
distribute-neg-in85.0%
metadata-eval85.0%
remove-double-neg85.0%
Applied egg-rr85.0%
associate-*r/85.1%
*-rgt-identity85.1%
+-commutative85.1%
Simplified85.1%
if -6.4999999999999993e-33 < x < -4.39999999999999978e-100Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 75.4%
Taylor expanded in x around 0 75.4%
*-commutative75.4%
Simplified75.4%
if 1.14999999999999998e-36 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 76.9%
Final simplification82.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ y -2.0))))
(if (<= x -2.35e+21)
(+ (/ (+ y (+ y -2.0)) x) -1.0)
(if (<= x -7e-33)
t_0
(if (<= x -4.4e-100)
(* x 0.5)
(if (<= x 1.3e-36) t_0 (/ x (- 2.0 x))))))))
double code(double x, double y) {
double t_0 = y / (y + -2.0);
double tmp;
if (x <= -2.35e+21) {
tmp = ((y + (y + -2.0)) / x) + -1.0;
} else if (x <= -7e-33) {
tmp = t_0;
} else if (x <= -4.4e-100) {
tmp = x * 0.5;
} else if (x <= 1.3e-36) {
tmp = t_0;
} else {
tmp = x / (2.0 - x);
}
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 = y / (y + (-2.0d0))
if (x <= (-2.35d+21)) then
tmp = ((y + (y + (-2.0d0))) / x) + (-1.0d0)
else if (x <= (-7d-33)) then
tmp = t_0
else if (x <= (-4.4d-100)) then
tmp = x * 0.5d0
else if (x <= 1.3d-36) then
tmp = t_0
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (y + -2.0);
double tmp;
if (x <= -2.35e+21) {
tmp = ((y + (y + -2.0)) / x) + -1.0;
} else if (x <= -7e-33) {
tmp = t_0;
} else if (x <= -4.4e-100) {
tmp = x * 0.5;
} else if (x <= 1.3e-36) {
tmp = t_0;
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): t_0 = y / (y + -2.0) tmp = 0 if x <= -2.35e+21: tmp = ((y + (y + -2.0)) / x) + -1.0 elif x <= -7e-33: tmp = t_0 elif x <= -4.4e-100: tmp = x * 0.5 elif x <= 1.3e-36: tmp = t_0 else: tmp = x / (2.0 - x) return tmp
function code(x, y) t_0 = Float64(y / Float64(y + -2.0)) tmp = 0.0 if (x <= -2.35e+21) tmp = Float64(Float64(Float64(y + Float64(y + -2.0)) / x) + -1.0); elseif (x <= -7e-33) tmp = t_0; elseif (x <= -4.4e-100) tmp = Float64(x * 0.5); elseif (x <= 1.3e-36) tmp = t_0; else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y + -2.0); tmp = 0.0; if (x <= -2.35e+21) tmp = ((y + (y + -2.0)) / x) + -1.0; elseif (x <= -7e-33) tmp = t_0; elseif (x <= -4.4e-100) tmp = x * 0.5; elseif (x <= 1.3e-36) tmp = t_0; else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.35e+21], N[(N[(N[(y + N[(y + -2.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, -7e-33], t$95$0, If[LessEqual[x, -4.4e-100], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.3e-36], t$95$0, N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y + -2}\\
\mathbf{if}\;x \leq -2.35 \cdot 10^{+21}:\\
\;\;\;\;\frac{y + \left(y + -2\right)}{x} + -1\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4.4 \cdot 10^{-100}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{-36}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -2.35e21Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num100.0%
inv-pow100.0%
associate--l-100.0%
Applied egg-rr100.0%
+-commutative100.0%
associate--l-100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in x around -inf 85.1%
sub-neg85.1%
Simplified85.1%
if -2.35e21 < x < -6.9999999999999997e-33 or -4.39999999999999978e-100 < x < 1.3e-36Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 85.1%
mul-1-neg85.1%
distribute-neg-frac85.1%
Simplified85.1%
frac-2neg85.1%
div-inv85.0%
remove-double-neg85.0%
sub-neg85.0%
distribute-neg-in85.0%
metadata-eval85.0%
remove-double-neg85.0%
Applied egg-rr85.0%
associate-*r/85.1%
*-rgt-identity85.1%
+-commutative85.1%
Simplified85.1%
if -6.9999999999999997e-33 < x < -4.39999999999999978e-100Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 75.4%
Taylor expanded in x around 0 75.4%
*-commutative75.4%
Simplified75.4%
if 1.3e-36 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 76.9%
Final simplification82.2%
(FPCore (x y) :precision binary64 (if (<= x -1.02e+21) -1.0 (if (<= x 75000000000000.0) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.02e+21) {
tmp = -1.0;
} else if (x <= 75000000000000.0) {
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 <= (-1.02d+21)) then
tmp = -1.0d0
else if (x <= 75000000000000.0d0) 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 <= -1.02e+21) {
tmp = -1.0;
} else if (x <= 75000000000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.02e+21: tmp = -1.0 elif x <= 75000000000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.02e+21) tmp = -1.0; elseif (x <= 75000000000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.02e+21) tmp = -1.0; elseif (x <= 75000000000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.02e+21], -1.0, If[LessEqual[x, 75000000000000.0], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.02 \cdot 10^{+21}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 75000000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.02e21 or 7.5e13 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 82.7%
if -1.02e21 < x < 7.5e13Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 54.0%
Final simplification66.5%
(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.0%
Final simplification38.0%
(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 2023230
(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))))