
(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 11 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 x) -1.0)))
(if (<= x -1e+14)
t_0
(if (<= x -4e-54)
(- 1.0 (/ x y))
(if (<= x -5.7e-92) (* x 0.5) (if (<= x 1.7e+54) 1.0 t_0))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double tmp;
if (x <= -1e+14) {
tmp = t_0;
} else if (x <= -4e-54) {
tmp = 1.0 - (x / y);
} else if (x <= -5.7e-92) {
tmp = x * 0.5;
} else if (x <= 1.7e+54) {
tmp = 1.0;
} 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) :: tmp
t_0 = (y / x) + (-1.0d0)
if (x <= (-1d+14)) then
tmp = t_0
else if (x <= (-4d-54)) then
tmp = 1.0d0 - (x / y)
else if (x <= (-5.7d-92)) then
tmp = x * 0.5d0
else if (x <= 1.7d+54) then
tmp = 1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double tmp;
if (x <= -1e+14) {
tmp = t_0;
} else if (x <= -4e-54) {
tmp = 1.0 - (x / y);
} else if (x <= -5.7e-92) {
tmp = x * 0.5;
} else if (x <= 1.7e+54) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 tmp = 0 if x <= -1e+14: tmp = t_0 elif x <= -4e-54: tmp = 1.0 - (x / y) elif x <= -5.7e-92: tmp = x * 0.5 elif x <= 1.7e+54: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(y / x) + -1.0) tmp = 0.0 if (x <= -1e+14) tmp = t_0; elseif (x <= -4e-54) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= -5.7e-92) tmp = Float64(x * 0.5); elseif (x <= 1.7e+54) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (y / x) + -1.0; tmp = 0.0; if (x <= -1e+14) tmp = t_0; elseif (x <= -4e-54) tmp = 1.0 - (x / y); elseif (x <= -5.7e-92) tmp = x * 0.5; elseif (x <= 1.7e+54) tmp = 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[x, -1e+14], t$95$0, If[LessEqual[x, -4e-54], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5.7e-92], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.7e+54], 1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
\mathbf{if}\;x \leq -1 \cdot 10^{+14}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4 \cdot 10^{-54}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq -5.7 \cdot 10^{-92}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{+54}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1e14 or 1.7e54 < x Initial program 99.9%
Taylor expanded in x around inf 78.9%
mul-1-neg78.9%
Simplified78.9%
Taylor expanded in x around 0 78.9%
if -1e14 < x < -4.0000000000000001e-54Initial program 100.0%
Taylor expanded in y around inf 61.9%
neg-mul-161.9%
Simplified61.9%
Taylor expanded in x around 0 61.9%
mul-1-neg61.9%
unsub-neg61.9%
Simplified61.9%
if -4.0000000000000001e-54 < x < -5.70000000000000009e-92Initial program 100.0%
Taylor expanded in y around 0 61.4%
Taylor expanded in x around 0 61.4%
*-commutative61.4%
Simplified61.4%
if -5.70000000000000009e-92 < x < 1.7e54Initial program 100.0%
Taylor expanded in y around inf 62.0%
Final simplification69.4%
(FPCore (x y)
:precision binary64
(if (<= x -75000000000000.0)
-1.0
(if (<= x -3.8e-54)
1.0
(if (<= x -2.5e-92) (* x 0.5) (if (<= x 2.7e+44) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -75000000000000.0) {
tmp = -1.0;
} else if (x <= -3.8e-54) {
tmp = 1.0;
} else if (x <= -2.5e-92) {
tmp = x * 0.5;
} else if (x <= 2.7e+44) {
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 <= (-75000000000000.0d0)) then
tmp = -1.0d0
else if (x <= (-3.8d-54)) then
tmp = 1.0d0
else if (x <= (-2.5d-92)) then
tmp = x * 0.5d0
else if (x <= 2.7d+44) 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 <= -75000000000000.0) {
tmp = -1.0;
} else if (x <= -3.8e-54) {
tmp = 1.0;
} else if (x <= -2.5e-92) {
tmp = x * 0.5;
} else if (x <= 2.7e+44) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -75000000000000.0: tmp = -1.0 elif x <= -3.8e-54: tmp = 1.0 elif x <= -2.5e-92: tmp = x * 0.5 elif x <= 2.7e+44: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -75000000000000.0) tmp = -1.0; elseif (x <= -3.8e-54) tmp = 1.0; elseif (x <= -2.5e-92) tmp = Float64(x * 0.5); elseif (x <= 2.7e+44) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -75000000000000.0) tmp = -1.0; elseif (x <= -3.8e-54) tmp = 1.0; elseif (x <= -2.5e-92) tmp = x * 0.5; elseif (x <= 2.7e+44) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -75000000000000.0], -1.0, If[LessEqual[x, -3.8e-54], 1.0, If[LessEqual[x, -2.5e-92], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 2.7e+44], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -75000000000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -3.8 \cdot 10^{-54}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{-92}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+44}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -7.5e13 or 2.7e44 < x Initial program 99.9%
Taylor expanded in x around inf 78.3%
if -7.5e13 < x < -3.8000000000000002e-54 or -2.50000000000000006e-92 < x < 2.7e44Initial program 100.0%
Taylor expanded in y around inf 62.0%
if -3.8000000000000002e-54 < x < -2.50000000000000006e-92Initial program 100.0%
Taylor expanded in y around 0 61.4%
Taylor expanded in x around 0 61.4%
*-commutative61.4%
Simplified61.4%
Final simplification69.2%
(FPCore (x y)
:precision binary64
(if (<= x -17200000000000.0)
-1.0
(if (<= x -1.7e-53)
(+ 1.0 (/ 2.0 y))
(if (<= x -5.6e-92) (* x 0.5) (if (<= x 6e+45) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -17200000000000.0) {
tmp = -1.0;
} else if (x <= -1.7e-53) {
tmp = 1.0 + (2.0 / y);
} else if (x <= -5.6e-92) {
tmp = x * 0.5;
} else if (x <= 6e+45) {
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 <= (-17200000000000.0d0)) then
tmp = -1.0d0
else if (x <= (-1.7d-53)) then
tmp = 1.0d0 + (2.0d0 / y)
else if (x <= (-5.6d-92)) then
tmp = x * 0.5d0
else if (x <= 6d+45) 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 <= -17200000000000.0) {
tmp = -1.0;
} else if (x <= -1.7e-53) {
tmp = 1.0 + (2.0 / y);
} else if (x <= -5.6e-92) {
tmp = x * 0.5;
} else if (x <= 6e+45) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -17200000000000.0: tmp = -1.0 elif x <= -1.7e-53: tmp = 1.0 + (2.0 / y) elif x <= -5.6e-92: tmp = x * 0.5 elif x <= 6e+45: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -17200000000000.0) tmp = -1.0; elseif (x <= -1.7e-53) tmp = Float64(1.0 + Float64(2.0 / y)); elseif (x <= -5.6e-92) tmp = Float64(x * 0.5); elseif (x <= 6e+45) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -17200000000000.0) tmp = -1.0; elseif (x <= -1.7e-53) tmp = 1.0 + (2.0 / y); elseif (x <= -5.6e-92) tmp = x * 0.5; elseif (x <= 6e+45) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -17200000000000.0], -1.0, If[LessEqual[x, -1.7e-53], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5.6e-92], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 6e+45], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -17200000000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.7 \cdot 10^{-53}:\\
\;\;\;\;1 + \frac{2}{y}\\
\mathbf{elif}\;x \leq -5.6 \cdot 10^{-92}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+45}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.72e13 or 6.00000000000000021e45 < x Initial program 99.9%
Taylor expanded in x around inf 78.3%
if -1.72e13 < x < -1.7e-53Initial program 100.0%
Taylor expanded in y around -inf 61.8%
Taylor expanded in x around 0 61.8%
associate-*r/61.8%
metadata-eval61.8%
Simplified61.8%
if -1.7e-53 < x < -5.6e-92Initial program 100.0%
Taylor expanded in y around 0 61.4%
Taylor expanded in x around 0 61.4%
*-commutative61.4%
Simplified61.4%
if -5.6e-92 < x < 6.00000000000000021e45Initial program 100.0%
Taylor expanded in y around inf 62.0%
Final simplification69.2%
(FPCore (x y)
:precision binary64
(if (<= x -32000000000000.0)
-1.0
(if (<= x -6.2e-53)
(- 1.0 (/ x y))
(if (<= x -3e-92) (* x 0.5) (if (<= x 2e+40) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -32000000000000.0) {
tmp = -1.0;
} else if (x <= -6.2e-53) {
tmp = 1.0 - (x / y);
} else if (x <= -3e-92) {
tmp = x * 0.5;
} else if (x <= 2e+40) {
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 <= (-32000000000000.0d0)) then
tmp = -1.0d0
else if (x <= (-6.2d-53)) then
tmp = 1.0d0 - (x / y)
else if (x <= (-3d-92)) then
tmp = x * 0.5d0
else if (x <= 2d+40) 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 <= -32000000000000.0) {
tmp = -1.0;
} else if (x <= -6.2e-53) {
tmp = 1.0 - (x / y);
} else if (x <= -3e-92) {
tmp = x * 0.5;
} else if (x <= 2e+40) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -32000000000000.0: tmp = -1.0 elif x <= -6.2e-53: tmp = 1.0 - (x / y) elif x <= -3e-92: tmp = x * 0.5 elif x <= 2e+40: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -32000000000000.0) tmp = -1.0; elseif (x <= -6.2e-53) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= -3e-92) tmp = Float64(x * 0.5); elseif (x <= 2e+40) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -32000000000000.0) tmp = -1.0; elseif (x <= -6.2e-53) tmp = 1.0 - (x / y); elseif (x <= -3e-92) tmp = x * 0.5; elseif (x <= 2e+40) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -32000000000000.0], -1.0, If[LessEqual[x, -6.2e-53], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3e-92], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 2e+40], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -32000000000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -6.2 \cdot 10^{-53}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-92}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+40}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -3.2e13 or 2.00000000000000006e40 < x Initial program 99.9%
Taylor expanded in x around inf 78.3%
if -3.2e13 < x < -6.20000000000000031e-53Initial program 100.0%
Taylor expanded in y around inf 61.9%
neg-mul-161.9%
Simplified61.9%
Taylor expanded in x around 0 61.9%
mul-1-neg61.9%
unsub-neg61.9%
Simplified61.9%
if -6.20000000000000031e-53 < x < -3.00000000000000013e-92Initial program 100.0%
Taylor expanded in y around 0 61.4%
Taylor expanded in x around 0 61.4%
*-commutative61.4%
Simplified61.4%
if -3.00000000000000013e-92 < x < 2.00000000000000006e40Initial program 100.0%
Taylor expanded in y around inf 62.0%
Final simplification69.2%
(FPCore (x y) :precision binary64 (if (<= y -1.7e-10) (/ y (+ y -2.0)) (if (<= y 5.1e+16) (/ (- x y) (- 2.0 x)) (+ 1.0 (/ (+ 2.0 (* x -2.0)) y)))))
double code(double x, double y) {
double tmp;
if (y <= -1.7e-10) {
tmp = y / (y + -2.0);
} else if (y <= 5.1e+16) {
tmp = (x - y) / (2.0 - x);
} else {
tmp = 1.0 + ((2.0 + (x * -2.0)) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.7d-10)) then
tmp = y / (y + (-2.0d0))
else if (y <= 5.1d+16) then
tmp = (x - y) / (2.0d0 - x)
else
tmp = 1.0d0 + ((2.0d0 + (x * (-2.0d0))) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.7e-10) {
tmp = y / (y + -2.0);
} else if (y <= 5.1e+16) {
tmp = (x - y) / (2.0 - x);
} else {
tmp = 1.0 + ((2.0 + (x * -2.0)) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.7e-10: tmp = y / (y + -2.0) elif y <= 5.1e+16: tmp = (x - y) / (2.0 - x) else: tmp = 1.0 + ((2.0 + (x * -2.0)) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.7e-10) tmp = Float64(y / Float64(y + -2.0)); elseif (y <= 5.1e+16) tmp = Float64(Float64(x - y) / Float64(2.0 - x)); else tmp = Float64(1.0 + Float64(Float64(2.0 + Float64(x * -2.0)) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.7e-10) tmp = y / (y + -2.0); elseif (y <= 5.1e+16) tmp = (x - y) / (2.0 - x); else tmp = 1.0 + ((2.0 + (x * -2.0)) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.7e-10], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.1e+16], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(2.0 + N[(x * -2.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{-10}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{+16}:\\
\;\;\;\;\frac{x - y}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{2 + x \cdot -2}{y}\\
\end{array}
\end{array}
if y < -1.70000000000000007e-10Initial program 99.9%
Taylor expanded in x around 0 80.1%
associate-*r/80.1%
neg-mul-180.1%
Simplified80.1%
frac-2neg80.1%
div-inv79.8%
remove-double-neg79.8%
sub-neg79.8%
distribute-neg-in79.8%
metadata-eval79.8%
remove-double-neg79.8%
Applied egg-rr79.8%
associate-*r/80.1%
*-rgt-identity80.1%
+-commutative80.1%
Simplified80.1%
if -1.70000000000000007e-10 < y < 5.1e16Initial program 100.0%
Taylor expanded in y around 0 98.5%
if 5.1e16 < y Initial program 100.0%
flip--39.7%
associate-/r/39.7%
metadata-eval39.7%
pow239.7%
Applied egg-rr39.7%
*-commutative39.7%
associate-*r/37.8%
associate-+r+37.8%
+-commutative37.8%
+-commutative37.8%
Simplified37.8%
Taylor expanded in y around -inf 69.3%
associate-*r/69.3%
cancel-sign-sub-inv69.3%
metadata-eval69.3%
distribute-lft-in69.3%
distribute-rgt1-in69.3%
metadata-eval69.3%
mul0-lft69.3%
metadata-eval69.3%
metadata-eval69.3%
metadata-eval69.3%
neg-mul-169.3%
distribute-lft-neg-in69.3%
metadata-eval69.3%
*-commutative69.3%
Simplified69.3%
Final simplification85.1%
(FPCore (x y) :precision binary64 (if (<= y -1.7e-10) (/ y (+ y -2.0)) (if (<= y 2.4e+17) (/ (- x y) (- 2.0 x)) (- 1.0 (/ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -1.7e-10) {
tmp = y / (y + -2.0);
} else if (y <= 2.4e+17) {
tmp = (x - y) / (2.0 - x);
} 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) :: tmp
if (y <= (-1.7d-10)) then
tmp = y / (y + (-2.0d0))
else if (y <= 2.4d+17) then
tmp = (x - y) / (2.0d0 - x)
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.7e-10) {
tmp = y / (y + -2.0);
} else if (y <= 2.4e+17) {
tmp = (x - y) / (2.0 - x);
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.7e-10: tmp = y / (y + -2.0) elif y <= 2.4e+17: tmp = (x - y) / (2.0 - x) else: tmp = 1.0 - (x / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.7e-10) tmp = Float64(y / Float64(y + -2.0)); elseif (y <= 2.4e+17) tmp = Float64(Float64(x - y) / Float64(2.0 - x)); else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.7e-10) tmp = y / (y + -2.0); elseif (y <= 2.4e+17) tmp = (x - y) / (2.0 - x); else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.7e-10], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.4e+17], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{-10}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+17}:\\
\;\;\;\;\frac{x - y}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -1.70000000000000007e-10Initial program 99.9%
Taylor expanded in x around 0 80.1%
associate-*r/80.1%
neg-mul-180.1%
Simplified80.1%
frac-2neg80.1%
div-inv79.8%
remove-double-neg79.8%
sub-neg79.8%
distribute-neg-in79.8%
metadata-eval79.8%
remove-double-neg79.8%
Applied egg-rr79.8%
associate-*r/80.1%
*-rgt-identity80.1%
+-commutative80.1%
Simplified80.1%
if -1.70000000000000007e-10 < y < 2.4e17Initial program 100.0%
Taylor expanded in y around 0 98.5%
if 2.4e17 < y Initial program 100.0%
Taylor expanded in y around inf 68.4%
neg-mul-168.4%
Simplified68.4%
Taylor expanded in x around 0 68.4%
mul-1-neg68.4%
unsub-neg68.4%
Simplified68.4%
Final simplification84.9%
(FPCore (x y) :precision binary64 (if (or (<= y -1.5e+69) (not (<= y 3.5e+14))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -1.5e+69) || !(y <= 3.5e+14)) {
tmp = 1.0 - (x / y);
} 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) :: tmp
if ((y <= (-1.5d+69)) .or. (.not. (y <= 3.5d+14))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.5e+69) || !(y <= 3.5e+14)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.5e+69) or not (y <= 3.5e+14): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.5e+69) || !(y <= 3.5e+14)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.5e+69) || ~((y <= 3.5e+14))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.5e+69], N[Not[LessEqual[y, 3.5e+14]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{+69} \lor \neg \left(y \leq 3.5 \cdot 10^{+14}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -1.49999999999999992e69 or 3.5e14 < y Initial program 100.0%
Taylor expanded in y around inf 75.6%
neg-mul-175.6%
Simplified75.6%
Taylor expanded in x around 0 75.6%
mul-1-neg75.6%
unsub-neg75.6%
Simplified75.6%
if -1.49999999999999992e69 < y < 3.5e14Initial program 100.0%
Taylor expanded in y around 0 74.7%
Final simplification75.1%
(FPCore (x y) :precision binary64 (if (or (<= y -6e-12) (not (<= y 8e-19))) (/ y (+ y -2.0)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -6e-12) || !(y <= 8e-19)) {
tmp = y / (y + -2.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) :: tmp
if ((y <= (-6d-12)) .or. (.not. (y <= 8d-19))) then
tmp = y / (y + (-2.0d0))
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -6e-12) || !(y <= 8e-19)) {
tmp = y / (y + -2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -6e-12) or not (y <= 8e-19): tmp = y / (y + -2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -6e-12) || !(y <= 8e-19)) tmp = Float64(y / Float64(y + -2.0)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -6e-12) || ~((y <= 8e-19))) tmp = y / (y + -2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -6e-12], N[Not[LessEqual[y, 8e-19]], $MachinePrecision]], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-12} \lor \neg \left(y \leq 8 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -6.0000000000000003e-12 or 7.9999999999999998e-19 < y Initial program 99.9%
Taylor expanded in x around 0 73.1%
associate-*r/73.1%
neg-mul-173.1%
Simplified73.1%
frac-2neg73.1%
div-inv72.9%
remove-double-neg72.9%
sub-neg72.9%
distribute-neg-in72.9%
metadata-eval72.9%
remove-double-neg72.9%
Applied egg-rr72.9%
associate-*r/73.1%
*-rgt-identity73.1%
+-commutative73.1%
Simplified73.1%
if -6.0000000000000003e-12 < y < 7.9999999999999998e-19Initial program 100.0%
Taylor expanded in y around 0 81.6%
Final simplification76.6%
(FPCore (x y) :precision binary64 (if (<= x -2.35e+14) -1.0 (if (<= x 7e+40) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -2.35e+14) {
tmp = -1.0;
} else if (x <= 7e+40) {
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 <= (-2.35d+14)) then
tmp = -1.0d0
else if (x <= 7d+40) 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 <= -2.35e+14) {
tmp = -1.0;
} else if (x <= 7e+40) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.35e+14: tmp = -1.0 elif x <= 7e+40: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.35e+14) tmp = -1.0; elseif (x <= 7e+40) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.35e+14) tmp = -1.0; elseif (x <= 7e+40) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.35e+14], -1.0, If[LessEqual[x, 7e+40], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.35 \cdot 10^{+14}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+40}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.35e14 or 6.9999999999999998e40 < x Initial program 99.9%
Taylor expanded in x around inf 78.3%
if -2.35e14 < x < 6.9999999999999998e40Initial program 100.0%
Taylor expanded in y around inf 58.7%
Final simplification67.4%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 37.4%
Final simplification37.4%
(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 2024024
(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))))