
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ y x) -1.0)))
(if (<= x -0.84)
t_0
(if (<= x -2e-68)
(* x 0.5)
(if (<= x 4.5e-243)
1.0
(if (<= x 2.6e-192) (* y -0.5) (if (<= x 4.8e+70) 1.0 t_0)))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double tmp;
if (x <= -0.84) {
tmp = t_0;
} else if (x <= -2e-68) {
tmp = x * 0.5;
} else if (x <= 4.5e-243) {
tmp = 1.0;
} else if (x <= 2.6e-192) {
tmp = y * -0.5;
} else if (x <= 4.8e+70) {
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 <= (-0.84d0)) then
tmp = t_0
else if (x <= (-2d-68)) then
tmp = x * 0.5d0
else if (x <= 4.5d-243) then
tmp = 1.0d0
else if (x <= 2.6d-192) then
tmp = y * (-0.5d0)
else if (x <= 4.8d+70) 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 <= -0.84) {
tmp = t_0;
} else if (x <= -2e-68) {
tmp = x * 0.5;
} else if (x <= 4.5e-243) {
tmp = 1.0;
} else if (x <= 2.6e-192) {
tmp = y * -0.5;
} else if (x <= 4.8e+70) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 tmp = 0 if x <= -0.84: tmp = t_0 elif x <= -2e-68: tmp = x * 0.5 elif x <= 4.5e-243: tmp = 1.0 elif x <= 2.6e-192: tmp = y * -0.5 elif x <= 4.8e+70: 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 <= -0.84) tmp = t_0; elseif (x <= -2e-68) tmp = Float64(x * 0.5); elseif (x <= 4.5e-243) tmp = 1.0; elseif (x <= 2.6e-192) tmp = Float64(y * -0.5); elseif (x <= 4.8e+70) 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 <= -0.84) tmp = t_0; elseif (x <= -2e-68) tmp = x * 0.5; elseif (x <= 4.5e-243) tmp = 1.0; elseif (x <= 2.6e-192) tmp = y * -0.5; elseif (x <= 4.8e+70) 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, -0.84], t$95$0, If[LessEqual[x, -2e-68], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 4.5e-243], 1.0, If[LessEqual[x, 2.6e-192], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 4.8e+70], 1.0, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
\mathbf{if}\;x \leq -0.84:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-68}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-243}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-192}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{+70}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -0.839999999999999969 or 4.79999999999999974e70 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 82.8%
neg-mul-182.8%
Simplified82.8%
Taylor expanded in x around 0 82.8%
if -0.839999999999999969 < x < -2.00000000000000013e-68Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 70.1%
Taylor expanded in x around 0 66.2%
*-commutative66.2%
Simplified66.2%
if -2.00000000000000013e-68 < x < 4.50000000000000017e-243 or 2.6000000000000002e-192 < x < 4.79999999999999974e70Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 60.5%
if 4.50000000000000017e-243 < x < 2.6000000000000002e-192Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 71.1%
associate-*r/71.1%
neg-mul-171.1%
Simplified71.1%
Taylor expanded in y around 0 57.3%
*-commutative57.3%
Simplified57.3%
Final simplification70.9%
(FPCore (x y) :precision binary64 (if (or (<= x -2.0) (not (<= x 4.2e-6))) (/ (- x y) (- (- x) y)) (/ (- x y) (- 2.0 y))))
double code(double x, double y) {
double tmp;
if ((x <= -2.0) || !(x <= 4.2e-6)) {
tmp = (x - y) / (-x - y);
} else {
tmp = (x - y) / (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 ((x <= (-2.0d0)) .or. (.not. (x <= 4.2d-6))) then
tmp = (x - y) / (-x - y)
else
tmp = (x - y) / (2.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -2.0) || !(x <= 4.2e-6)) {
tmp = (x - y) / (-x - y);
} else {
tmp = (x - y) / (2.0 - y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -2.0) or not (x <= 4.2e-6): tmp = (x - y) / (-x - y) else: tmp = (x - y) / (2.0 - y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -2.0) || !(x <= 4.2e-6)) tmp = Float64(Float64(x - y) / Float64(Float64(-x) - y)); else tmp = Float64(Float64(x - y) / Float64(2.0 - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -2.0) || ~((x <= 4.2e-6))) tmp = (x - y) / (-x - y); else tmp = (x - y) / (2.0 - y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -2.0], N[Not[LessEqual[x, 4.2e-6]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] / N[((-x) - y), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \lor \neg \left(x \leq 4.2 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{x - y}{\left(-x\right) - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\end{array}
\end{array}
if x < -2 or 4.1999999999999996e-6 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
flip--52.3%
div-inv52.2%
fma-neg52.2%
metadata-eval52.2%
+-commutative52.2%
Applied egg-rr52.2%
fma-neg52.2%
+-commutative52.2%
Simplified52.2%
Taylor expanded in x around inf 98.8%
neg-mul-198.8%
Simplified98.8%
if -2 < x < 4.1999999999999996e-6Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 99.1%
Final simplification98.9%
(FPCore (x y)
:precision binary64
(if (<= x -2.0)
-1.0
(if (<= x -1.45e-68)
(* x 0.5)
(if (<= x 1.4e-242)
1.0
(if (<= x 9e-193) (* y -0.5) (if (<= x 1.25e+72) 1.0 -1.0))))))
double code(double x, double y) {
double tmp;
if (x <= -2.0) {
tmp = -1.0;
} else if (x <= -1.45e-68) {
tmp = x * 0.5;
} else if (x <= 1.4e-242) {
tmp = 1.0;
} else if (x <= 9e-193) {
tmp = y * -0.5;
} else if (x <= 1.25e+72) {
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.0d0)) then
tmp = -1.0d0
else if (x <= (-1.45d-68)) then
tmp = x * 0.5d0
else if (x <= 1.4d-242) then
tmp = 1.0d0
else if (x <= 9d-193) then
tmp = y * (-0.5d0)
else if (x <= 1.25d+72) 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.0) {
tmp = -1.0;
} else if (x <= -1.45e-68) {
tmp = x * 0.5;
} else if (x <= 1.4e-242) {
tmp = 1.0;
} else if (x <= 9e-193) {
tmp = y * -0.5;
} else if (x <= 1.25e+72) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.0: tmp = -1.0 elif x <= -1.45e-68: tmp = x * 0.5 elif x <= 1.4e-242: tmp = 1.0 elif x <= 9e-193: tmp = y * -0.5 elif x <= 1.25e+72: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.0) tmp = -1.0; elseif (x <= -1.45e-68) tmp = Float64(x * 0.5); elseif (x <= 1.4e-242) tmp = 1.0; elseif (x <= 9e-193) tmp = Float64(y * -0.5); elseif (x <= 1.25e+72) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.0) tmp = -1.0; elseif (x <= -1.45e-68) tmp = x * 0.5; elseif (x <= 1.4e-242) tmp = 1.0; elseif (x <= 9e-193) tmp = y * -0.5; elseif (x <= 1.25e+72) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.0], -1.0, If[LessEqual[x, -1.45e-68], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.4e-242], 1.0, If[LessEqual[x, 9e-193], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1.25e+72], 1.0, -1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.45 \cdot 10^{-68}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-242}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-193}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{+72}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2 or 1.24999999999999998e72 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 82.4%
if -2 < x < -1.45e-68Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 70.1%
Taylor expanded in x around 0 66.2%
*-commutative66.2%
Simplified66.2%
if -1.45e-68 < x < 1.39999999999999992e-242 or 8.9999999999999997e-193 < x < 1.24999999999999998e72Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 60.5%
if 1.39999999999999992e-242 < x < 8.9999999999999997e-193Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 71.1%
associate-*r/71.1%
neg-mul-171.1%
Simplified71.1%
Taylor expanded in y around 0 57.3%
*-commutative57.3%
Simplified57.3%
Final simplification70.7%
(FPCore (x y) :precision binary64 (if (<= x -3.5e-5) (/ x (- 2.0 x)) (if (<= x 6e+72) (/ (- x y) (- 2.0 y)) (+ (/ y x) -1.0))))
double code(double x, double y) {
double tmp;
if (x <= -3.5e-5) {
tmp = x / (2.0 - x);
} else if (x <= 6e+72) {
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 <= (-3.5d-5)) then
tmp = x / (2.0d0 - x)
else if (x <= 6d+72) 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 <= -3.5e-5) {
tmp = x / (2.0 - x);
} else if (x <= 6e+72) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = (y / x) + -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.5e-5: tmp = x / (2.0 - x) elif x <= 6e+72: tmp = (x - y) / (2.0 - y) else: tmp = (y / x) + -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -3.5e-5) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 6e+72) 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 <= -3.5e-5) tmp = x / (2.0 - x); elseif (x <= 6e+72) tmp = (x - y) / (2.0 - y); else tmp = (y / x) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.5e-5], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6e+72], 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 -3.5 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+72}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x} + -1\\
\end{array}
\end{array}
if x < -3.4999999999999997e-5Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 79.9%
if -3.4999999999999997e-5 < x < 6.00000000000000006e72Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 97.1%
if 6.00000000000000006e72 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 88.0%
neg-mul-188.0%
Simplified88.0%
Taylor expanded in x around 0 88.0%
Final simplification90.7%
(FPCore (x y) :precision binary64 (if (<= y -2.0) 1.0 (if (<= y 8.5e+32) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -2.0) {
tmp = 1.0;
} else if (y <= 8.5e+32) {
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 <= (-2.0d0)) then
tmp = 1.0d0
else if (y <= 8.5d+32) 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 <= -2.0) {
tmp = 1.0;
} else if (y <= 8.5e+32) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.0: tmp = 1.0 elif y <= 8.5e+32: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.0) tmp = 1.0; elseif (y <= 8.5e+32) 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 <= -2.0) tmp = 1.0; elseif (y <= 8.5e+32) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.0], 1.0, If[LessEqual[y, 8.5e+32], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{+32}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2 or 8.4999999999999998e32 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 72.2%
if -2 < y < 8.4999999999999998e32Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 76.9%
Final simplification74.7%
(FPCore (x y) :precision binary64 (if (<= x -2.2e-68) (/ x (- 2.0 x)) (if (<= x 2.3e+71) (/ y (+ y -2.0)) (+ (/ y x) -1.0))))
double code(double x, double y) {
double tmp;
if (x <= -2.2e-68) {
tmp = x / (2.0 - x);
} else if (x <= 2.3e+71) {
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 <= (-2.2d-68)) then
tmp = x / (2.0d0 - x)
else if (x <= 2.3d+71) 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 <= -2.2e-68) {
tmp = x / (2.0 - x);
} else if (x <= 2.3e+71) {
tmp = y / (y + -2.0);
} else {
tmp = (y / x) + -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.2e-68: tmp = x / (2.0 - x) elif x <= 2.3e+71: tmp = y / (y + -2.0) else: tmp = (y / x) + -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.2e-68) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 2.3e+71) 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 <= -2.2e-68) tmp = x / (2.0 - x); elseif (x <= 2.3e+71) tmp = y / (y + -2.0); else tmp = (y / x) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.2e-68], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.3e+71], 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 -2.2 \cdot 10^{-68}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+71}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x} + -1\\
\end{array}
\end{array}
if x < -2.20000000000000002e-68Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 77.8%
if -2.20000000000000002e-68 < x < 2.3000000000000002e71Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 78.9%
associate-*r/78.9%
neg-mul-178.9%
Simplified78.9%
frac-2neg78.9%
div-inv78.7%
remove-double-neg78.7%
sub-neg78.7%
distribute-neg-in78.7%
metadata-eval78.7%
remove-double-neg78.7%
Applied egg-rr78.7%
associate-*r/78.9%
*-rgt-identity78.9%
+-commutative78.9%
Simplified78.9%
if 2.3000000000000002e71 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 88.0%
neg-mul-188.0%
Simplified88.0%
Taylor expanded in x around 0 88.0%
Final simplification80.3%
(FPCore (x y) :precision binary64 (if (<= x -2.0) -1.0 (if (<= x -1.75e-68) (* x 0.5) (if (<= x 4.8e+70) 1.0 -1.0))))
double code(double x, double y) {
double tmp;
if (x <= -2.0) {
tmp = -1.0;
} else if (x <= -1.75e-68) {
tmp = x * 0.5;
} else if (x <= 4.8e+70) {
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.0d0)) then
tmp = -1.0d0
else if (x <= (-1.75d-68)) then
tmp = x * 0.5d0
else if (x <= 4.8d+70) 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.0) {
tmp = -1.0;
} else if (x <= -1.75e-68) {
tmp = x * 0.5;
} else if (x <= 4.8e+70) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.0: tmp = -1.0 elif x <= -1.75e-68: tmp = x * 0.5 elif x <= 4.8e+70: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.0) tmp = -1.0; elseif (x <= -1.75e-68) tmp = Float64(x * 0.5); elseif (x <= 4.8e+70) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.0) tmp = -1.0; elseif (x <= -1.75e-68) tmp = x * 0.5; elseif (x <= 4.8e+70) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.0], -1.0, If[LessEqual[x, -1.75e-68], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 4.8e+70], 1.0, -1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.75 \cdot 10^{-68}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{+70}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2 or 4.79999999999999974e70 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 82.4%
if -2 < x < -1.75000000000000006e-68Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 70.1%
Taylor expanded in x around 0 66.2%
*-commutative66.2%
Simplified66.2%
if -1.75000000000000006e-68 < x < 4.79999999999999974e70Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 55.3%
Final simplification68.3%
(FPCore (x y) :precision binary64 (if (<= x -8.5e-37) -1.0 (if (<= x 5e+70) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -8.5e-37) {
tmp = -1.0;
} else if (x <= 5e+70) {
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 <= (-8.5d-37)) then
tmp = -1.0d0
else if (x <= 5d+70) 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 <= -8.5e-37) {
tmp = -1.0;
} else if (x <= 5e+70) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8.5e-37: tmp = -1.0 elif x <= 5e+70: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -8.5e-37) tmp = -1.0; elseif (x <= 5e+70) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -8.5e-37) tmp = -1.0; elseif (x <= 5e+70) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8.5e-37], -1.0, If[LessEqual[x, 5e+70], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{-37}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+70}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -8.5000000000000007e-37 or 5.0000000000000002e70 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 78.2%
if -8.5000000000000007e-37 < x < 5.0000000000000002e70Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 53.1%
Final simplification65.3%
(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 40.2%
Final simplification40.2%
(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 2023214
(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))))