
(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
(let* ((t_0 (+ (/ y x) -1.0)))
(if (<= x -9e+43)
t_0
(if (<= x 5e-285)
(- 1.0 (/ x y))
(if (<= x 5.7e-229)
(* y -0.5)
(if (<= x 3.1e-174)
1.0
(if (<= x 2.7e-154) (* y -0.5) (if (<= x 4.1e+73) 1.0 t_0))))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double tmp;
if (x <= -9e+43) {
tmp = t_0;
} else if (x <= 5e-285) {
tmp = 1.0 - (x / y);
} else if (x <= 5.7e-229) {
tmp = y * -0.5;
} else if (x <= 3.1e-174) {
tmp = 1.0;
} else if (x <= 2.7e-154) {
tmp = y * -0.5;
} else if (x <= 4.1e+73) {
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 <= (-9d+43)) then
tmp = t_0
else if (x <= 5d-285) then
tmp = 1.0d0 - (x / y)
else if (x <= 5.7d-229) then
tmp = y * (-0.5d0)
else if (x <= 3.1d-174) then
tmp = 1.0d0
else if (x <= 2.7d-154) then
tmp = y * (-0.5d0)
else if (x <= 4.1d+73) 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 <= -9e+43) {
tmp = t_0;
} else if (x <= 5e-285) {
tmp = 1.0 - (x / y);
} else if (x <= 5.7e-229) {
tmp = y * -0.5;
} else if (x <= 3.1e-174) {
tmp = 1.0;
} else if (x <= 2.7e-154) {
tmp = y * -0.5;
} else if (x <= 4.1e+73) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 tmp = 0 if x <= -9e+43: tmp = t_0 elif x <= 5e-285: tmp = 1.0 - (x / y) elif x <= 5.7e-229: tmp = y * -0.5 elif x <= 3.1e-174: tmp = 1.0 elif x <= 2.7e-154: tmp = y * -0.5 elif x <= 4.1e+73: 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 <= -9e+43) tmp = t_0; elseif (x <= 5e-285) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= 5.7e-229) tmp = Float64(y * -0.5); elseif (x <= 3.1e-174) tmp = 1.0; elseif (x <= 2.7e-154) tmp = Float64(y * -0.5); elseif (x <= 4.1e+73) 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 <= -9e+43) tmp = t_0; elseif (x <= 5e-285) tmp = 1.0 - (x / y); elseif (x <= 5.7e-229) tmp = y * -0.5; elseif (x <= 3.1e-174) tmp = 1.0; elseif (x <= 2.7e-154) tmp = y * -0.5; elseif (x <= 4.1e+73) 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, -9e+43], t$95$0, If[LessEqual[x, 5e-285], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.7e-229], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 3.1e-174], 1.0, If[LessEqual[x, 2.7e-154], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 4.1e+73], 1.0, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
\mathbf{if}\;x \leq -9 \cdot 10^{+43}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-285}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq 5.7 \cdot 10^{-229}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-174}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-154}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{+73}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -9e43 or 4.0999999999999998e73 < x Initial program 100.0%
clear-num99.9%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 86.7%
Taylor expanded in x around 0 86.9%
if -9e43 < x < 5.00000000000000018e-285Initial program 99.9%
clear-num99.8%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 60.9%
Taylor expanded in y around 0 61.1%
mul-1-neg61.1%
unsub-neg61.1%
Simplified61.1%
if 5.00000000000000018e-285 < x < 5.70000000000000023e-229 or 3.0999999999999999e-174 < x < 2.69999999999999989e-154Initial program 100.0%
Taylor expanded in x around 0 88.4%
mul-1-neg88.4%
distribute-neg-frac88.4%
Simplified88.4%
Taylor expanded in y around 0 67.5%
*-commutative67.5%
Simplified67.5%
if 5.70000000000000023e-229 < x < 3.0999999999999999e-174 or 2.69999999999999989e-154 < x < 4.0999999999999998e73Initial program 99.9%
Taylor expanded in y around inf 59.5%
Final simplification72.5%
(FPCore (x y)
:precision binary64
(if (<= x -9e+43)
-1.0
(if (<= x 2.2e-287)
1.0
(if (<= x 1.1e-228)
(* y -0.5)
(if (<= x 3.1e-174)
1.0
(if (<= x 1.34e-154) (* y -0.5) (if (<= x 1.55e+68) 1.0 -1.0)))))))
double code(double x, double y) {
double tmp;
if (x <= -9e+43) {
tmp = -1.0;
} else if (x <= 2.2e-287) {
tmp = 1.0;
} else if (x <= 1.1e-228) {
tmp = y * -0.5;
} else if (x <= 3.1e-174) {
tmp = 1.0;
} else if (x <= 1.34e-154) {
tmp = y * -0.5;
} else if (x <= 1.55e+68) {
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 <= (-9d+43)) then
tmp = -1.0d0
else if (x <= 2.2d-287) then
tmp = 1.0d0
else if (x <= 1.1d-228) then
tmp = y * (-0.5d0)
else if (x <= 3.1d-174) then
tmp = 1.0d0
else if (x <= 1.34d-154) then
tmp = y * (-0.5d0)
else if (x <= 1.55d+68) 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 <= -9e+43) {
tmp = -1.0;
} else if (x <= 2.2e-287) {
tmp = 1.0;
} else if (x <= 1.1e-228) {
tmp = y * -0.5;
} else if (x <= 3.1e-174) {
tmp = 1.0;
} else if (x <= 1.34e-154) {
tmp = y * -0.5;
} else if (x <= 1.55e+68) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9e+43: tmp = -1.0 elif x <= 2.2e-287: tmp = 1.0 elif x <= 1.1e-228: tmp = y * -0.5 elif x <= 3.1e-174: tmp = 1.0 elif x <= 1.34e-154: tmp = y * -0.5 elif x <= 1.55e+68: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -9e+43) tmp = -1.0; elseif (x <= 2.2e-287) tmp = 1.0; elseif (x <= 1.1e-228) tmp = Float64(y * -0.5); elseif (x <= 3.1e-174) tmp = 1.0; elseif (x <= 1.34e-154) tmp = Float64(y * -0.5); elseif (x <= 1.55e+68) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9e+43) tmp = -1.0; elseif (x <= 2.2e-287) tmp = 1.0; elseif (x <= 1.1e-228) tmp = y * -0.5; elseif (x <= 3.1e-174) tmp = 1.0; elseif (x <= 1.34e-154) tmp = y * -0.5; elseif (x <= 1.55e+68) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9e+43], -1.0, If[LessEqual[x, 2.2e-287], 1.0, If[LessEqual[x, 1.1e-228], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 3.1e-174], 1.0, If[LessEqual[x, 1.34e-154], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1.55e+68], 1.0, -1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+43}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-287}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-228}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-174}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.34 \cdot 10^{-154}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+68}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9e43 or 1.5499999999999999e68 < x Initial program 100.0%
Taylor expanded in x around inf 86.6%
if -9e43 < x < 2.2e-287 or 1.1e-228 < x < 3.0999999999999999e-174 or 1.34000000000000006e-154 < x < 1.5499999999999999e68Initial program 99.9%
Taylor expanded in y around inf 60.2%
if 2.2e-287 < x < 1.1e-228 or 3.0999999999999999e-174 < x < 1.34000000000000006e-154Initial program 100.0%
Taylor expanded in x around 0 88.4%
mul-1-neg88.4%
distribute-neg-frac88.4%
Simplified88.4%
Taylor expanded in y around 0 67.5%
*-commutative67.5%
Simplified67.5%
Final simplification72.3%
(FPCore (x y)
:precision binary64
(if (<= x -9e+43)
-1.0
(if (<= x 2.5e-281)
(- 1.0 (/ x y))
(if (<= x 6.3e-229)
(* y -0.5)
(if (<= x 1.6e-174)
1.0
(if (<= x 1.25e-154) (* y -0.5) (if (<= x 4.2e+70) 1.0 -1.0)))))))
double code(double x, double y) {
double tmp;
if (x <= -9e+43) {
tmp = -1.0;
} else if (x <= 2.5e-281) {
tmp = 1.0 - (x / y);
} else if (x <= 6.3e-229) {
tmp = y * -0.5;
} else if (x <= 1.6e-174) {
tmp = 1.0;
} else if (x <= 1.25e-154) {
tmp = y * -0.5;
} else if (x <= 4.2e+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 <= (-9d+43)) then
tmp = -1.0d0
else if (x <= 2.5d-281) then
tmp = 1.0d0 - (x / y)
else if (x <= 6.3d-229) then
tmp = y * (-0.5d0)
else if (x <= 1.6d-174) then
tmp = 1.0d0
else if (x <= 1.25d-154) then
tmp = y * (-0.5d0)
else if (x <= 4.2d+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 <= -9e+43) {
tmp = -1.0;
} else if (x <= 2.5e-281) {
tmp = 1.0 - (x / y);
} else if (x <= 6.3e-229) {
tmp = y * -0.5;
} else if (x <= 1.6e-174) {
tmp = 1.0;
} else if (x <= 1.25e-154) {
tmp = y * -0.5;
} else if (x <= 4.2e+70) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9e+43: tmp = -1.0 elif x <= 2.5e-281: tmp = 1.0 - (x / y) elif x <= 6.3e-229: tmp = y * -0.5 elif x <= 1.6e-174: tmp = 1.0 elif x <= 1.25e-154: tmp = y * -0.5 elif x <= 4.2e+70: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -9e+43) tmp = -1.0; elseif (x <= 2.5e-281) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= 6.3e-229) tmp = Float64(y * -0.5); elseif (x <= 1.6e-174) tmp = 1.0; elseif (x <= 1.25e-154) tmp = Float64(y * -0.5); elseif (x <= 4.2e+70) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9e+43) tmp = -1.0; elseif (x <= 2.5e-281) tmp = 1.0 - (x / y); elseif (x <= 6.3e-229) tmp = y * -0.5; elseif (x <= 1.6e-174) tmp = 1.0; elseif (x <= 1.25e-154) tmp = y * -0.5; elseif (x <= 4.2e+70) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9e+43], -1.0, If[LessEqual[x, 2.5e-281], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.3e-229], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1.6e-174], 1.0, If[LessEqual[x, 1.25e-154], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 4.2e+70], 1.0, -1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+43}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-281}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq 6.3 \cdot 10^{-229}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-174}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-154}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+70}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9e43 or 4.20000000000000015e70 < x Initial program 100.0%
Taylor expanded in x around inf 86.6%
if -9e43 < x < 2.4999999999999999e-281Initial program 99.9%
clear-num99.8%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 60.9%
Taylor expanded in y around 0 61.1%
mul-1-neg61.1%
unsub-neg61.1%
Simplified61.1%
if 2.4999999999999999e-281 < x < 6.29999999999999987e-229 or 1.6e-174 < x < 1.25000000000000005e-154Initial program 100.0%
Taylor expanded in x around 0 88.4%
mul-1-neg88.4%
distribute-neg-frac88.4%
Simplified88.4%
Taylor expanded in y around 0 67.5%
*-commutative67.5%
Simplified67.5%
if 6.29999999999999987e-229 < x < 1.6e-174 or 1.25000000000000005e-154 < x < 4.20000000000000015e70Initial program 99.9%
Taylor expanded in y around inf 59.5%
Final simplification72.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ y -2.0))))
(if (<= x -9e+43)
(+ (/ y x) -1.0)
(if (<= x 4.7e-43)
t_0
(if (<= x 2700000.0)
(/ x (- 2.0 x))
(if (<= x 4.2e+70) t_0 (/ (- x y) (- x))))))))
double code(double x, double y) {
double t_0 = y / (y + -2.0);
double tmp;
if (x <= -9e+43) {
tmp = (y / x) + -1.0;
} else if (x <= 4.7e-43) {
tmp = t_0;
} else if (x <= 2700000.0) {
tmp = x / (2.0 - x);
} else if (x <= 4.2e+70) {
tmp = t_0;
} else {
tmp = (x - y) / -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 <= (-9d+43)) then
tmp = (y / x) + (-1.0d0)
else if (x <= 4.7d-43) then
tmp = t_0
else if (x <= 2700000.0d0) then
tmp = x / (2.0d0 - x)
else if (x <= 4.2d+70) then
tmp = t_0
else
tmp = (x - y) / -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 <= -9e+43) {
tmp = (y / x) + -1.0;
} else if (x <= 4.7e-43) {
tmp = t_0;
} else if (x <= 2700000.0) {
tmp = x / (2.0 - x);
} else if (x <= 4.2e+70) {
tmp = t_0;
} else {
tmp = (x - y) / -x;
}
return tmp;
}
def code(x, y): t_0 = y / (y + -2.0) tmp = 0 if x <= -9e+43: tmp = (y / x) + -1.0 elif x <= 4.7e-43: tmp = t_0 elif x <= 2700000.0: tmp = x / (2.0 - x) elif x <= 4.2e+70: tmp = t_0 else: tmp = (x - y) / -x return tmp
function code(x, y) t_0 = Float64(y / Float64(y + -2.0)) tmp = 0.0 if (x <= -9e+43) tmp = Float64(Float64(y / x) + -1.0); elseif (x <= 4.7e-43) tmp = t_0; elseif (x <= 2700000.0) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 4.2e+70) tmp = t_0; else tmp = Float64(Float64(x - y) / Float64(-x)); end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y + -2.0); tmp = 0.0; if (x <= -9e+43) tmp = (y / x) + -1.0; elseif (x <= 4.7e-43) tmp = t_0; elseif (x <= 2700000.0) tmp = x / (2.0 - x); elseif (x <= 4.2e+70) tmp = t_0; else tmp = (x - y) / -x; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9e+43], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, 4.7e-43], t$95$0, If[LessEqual[x, 2700000.0], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.2e+70], t$95$0, N[(N[(x - y), $MachinePrecision] / (-x)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y + -2}\\
\mathbf{if}\;x \leq -9 \cdot 10^{+43}:\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{-43}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2700000:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+70}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{-x}\\
\end{array}
\end{array}
if x < -9e43Initial program 100.0%
clear-num100.0%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 82.3%
Taylor expanded in x around 0 82.5%
if -9e43 < x < 4.7000000000000001e-43 or 2.7e6 < x < 4.20000000000000015e70Initial program 100.0%
Taylor expanded in x around 0 82.6%
mul-1-neg82.6%
distribute-neg-frac82.6%
Simplified82.6%
expm1-log1p-u82.6%
expm1-udef57.5%
add-sqr-sqrt30.8%
sqrt-unprod17.0%
sqr-neg17.0%
sqrt-unprod1.3%
add-sqr-sqrt3.0%
frac-2neg3.0%
add-sqr-sqrt1.4%
sqrt-unprod15.0%
sqr-neg15.0%
sqrt-unprod26.6%
add-sqr-sqrt57.5%
sub-neg57.5%
distribute-neg-in57.5%
metadata-eval57.5%
remove-double-neg57.5%
Applied egg-rr57.5%
expm1-def82.6%
expm1-log1p82.6%
+-commutative82.6%
Simplified82.6%
if 4.7000000000000001e-43 < x < 2.7e6Initial program 99.9%
Taylor expanded in y around 0 66.5%
if 4.20000000000000015e70 < x Initial program 99.9%
clear-num99.9%
associate-/r/99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 90.3%
expm1-log1p-u88.8%
expm1-udef88.8%
*-commutative88.8%
frac-2neg88.8%
metadata-eval88.8%
un-div-inv89.0%
Applied egg-rr89.0%
expm1-def89.0%
expm1-log1p90.6%
Simplified90.6%
Final simplification83.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ x (- 2.0 x))))
(if (<= y -2000000000000.0)
t_0
(if (<= y 1.35e-92)
t_1
(if (<= y 6.2e-12) (* y -0.5) (if (<= y 5.8e+117) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -2000000000000.0) {
tmp = t_0;
} else if (y <= 1.35e-92) {
tmp = t_1;
} else if (y <= 6.2e-12) {
tmp = y * -0.5;
} else if (y <= 5.8e+117) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
t_1 = x / (2.0d0 - x)
if (y <= (-2000000000000.0d0)) then
tmp = t_0
else if (y <= 1.35d-92) then
tmp = t_1
else if (y <= 6.2d-12) then
tmp = y * (-0.5d0)
else if (y <= 5.8d+117) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -2000000000000.0) {
tmp = t_0;
} else if (y <= 1.35e-92) {
tmp = t_1;
} else if (y <= 6.2e-12) {
tmp = y * -0.5;
} else if (y <= 5.8e+117) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) t_1 = x / (2.0 - x) tmp = 0 if y <= -2000000000000.0: tmp = t_0 elif y <= 1.35e-92: tmp = t_1 elif y <= 6.2e-12: tmp = y * -0.5 elif y <= 5.8e+117: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) t_1 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -2000000000000.0) tmp = t_0; elseif (y <= 1.35e-92) tmp = t_1; elseif (y <= 6.2e-12) tmp = Float64(y * -0.5); elseif (y <= 5.8e+117) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); t_1 = x / (2.0 - x); tmp = 0.0; if (y <= -2000000000000.0) tmp = t_0; elseif (y <= 1.35e-92) tmp = t_1; elseif (y <= 6.2e-12) tmp = y * -0.5; elseif (y <= 5.8e+117) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2000000000000.0], t$95$0, If[LessEqual[y, 1.35e-92], t$95$1, If[LessEqual[y, 6.2e-12], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 5.8e+117], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -2000000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-92}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{-12}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+117}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2e12 or 5.80000000000000055e117 < y Initial program 100.0%
clear-num99.9%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 77.7%
Taylor expanded in y around 0 77.9%
mul-1-neg77.9%
unsub-neg77.9%
Simplified77.9%
if -2e12 < y < 1.34999999999999998e-92 or 6.2000000000000002e-12 < y < 5.80000000000000055e117Initial program 100.0%
Taylor expanded in y around 0 74.0%
if 1.34999999999999998e-92 < y < 6.2000000000000002e-12Initial program 99.8%
Taylor expanded in x around 0 62.2%
mul-1-neg62.2%
distribute-neg-frac62.2%
Simplified62.2%
Taylor expanded in y around 0 61.3%
*-commutative61.3%
Simplified61.3%
Final simplification74.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ y x) -1.0)) (t_1 (/ y (+ y -2.0))))
(if (<= x -9e+43)
t_0
(if (<= x 2.4e-42)
t_1
(if (<= x 0.32) (/ x (- 2.0 x)) (if (<= x 1.05e+68) t_1 t_0))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double t_1 = y / (y + -2.0);
double tmp;
if (x <= -9e+43) {
tmp = t_0;
} else if (x <= 2.4e-42) {
tmp = t_1;
} else if (x <= 0.32) {
tmp = x / (2.0 - x);
} else if (x <= 1.05e+68) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (y / x) + (-1.0d0)
t_1 = y / (y + (-2.0d0))
if (x <= (-9d+43)) then
tmp = t_0
else if (x <= 2.4d-42) then
tmp = t_1
else if (x <= 0.32d0) then
tmp = x / (2.0d0 - x)
else if (x <= 1.05d+68) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double t_1 = y / (y + -2.0);
double tmp;
if (x <= -9e+43) {
tmp = t_0;
} else if (x <= 2.4e-42) {
tmp = t_1;
} else if (x <= 0.32) {
tmp = x / (2.0 - x);
} else if (x <= 1.05e+68) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 t_1 = y / (y + -2.0) tmp = 0 if x <= -9e+43: tmp = t_0 elif x <= 2.4e-42: tmp = t_1 elif x <= 0.32: tmp = x / (2.0 - x) elif x <= 1.05e+68: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(y / x) + -1.0) t_1 = Float64(y / Float64(y + -2.0)) tmp = 0.0 if (x <= -9e+43) tmp = t_0; elseif (x <= 2.4e-42) tmp = t_1; elseif (x <= 0.32) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 1.05e+68) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (y / x) + -1.0; t_1 = y / (y + -2.0); tmp = 0.0; if (x <= -9e+43) tmp = t_0; elseif (x <= 2.4e-42) tmp = t_1; elseif (x <= 0.32) tmp = x / (2.0 - x); elseif (x <= 1.05e+68) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9e+43], t$95$0, If[LessEqual[x, 2.4e-42], t$95$1, If[LessEqual[x, 0.32], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.05e+68], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
t_1 := \frac{y}{y + -2}\\
\mathbf{if}\;x \leq -9 \cdot 10^{+43}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-42}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 0.32:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+68}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -9e43 or 1.05e68 < x Initial program 100.0%
clear-num99.9%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 86.7%
Taylor expanded in x around 0 86.9%
if -9e43 < x < 2.40000000000000003e-42 or 0.320000000000000007 < x < 1.05e68Initial program 100.0%
Taylor expanded in x around 0 82.6%
mul-1-neg82.6%
distribute-neg-frac82.6%
Simplified82.6%
expm1-log1p-u82.6%
expm1-udef57.5%
add-sqr-sqrt30.8%
sqrt-unprod17.0%
sqr-neg17.0%
sqrt-unprod1.3%
add-sqr-sqrt3.0%
frac-2neg3.0%
add-sqr-sqrt1.4%
sqrt-unprod15.0%
sqr-neg15.0%
sqrt-unprod26.6%
add-sqr-sqrt57.5%
sub-neg57.5%
distribute-neg-in57.5%
metadata-eval57.5%
remove-double-neg57.5%
Applied egg-rr57.5%
expm1-def82.6%
expm1-log1p82.6%
+-commutative82.6%
Simplified82.6%
if 2.40000000000000003e-42 < x < 0.320000000000000007Initial program 99.9%
Taylor expanded in y around 0 66.5%
Final simplification83.4%
(FPCore (x y) :precision binary64 (if (<= x -9e+43) -1.0 (if (<= x 2e+68) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -9e+43) {
tmp = -1.0;
} else if (x <= 2e+68) {
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 <= (-9d+43)) then
tmp = -1.0d0
else if (x <= 2d+68) 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 <= -9e+43) {
tmp = -1.0;
} else if (x <= 2e+68) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9e+43: tmp = -1.0 elif x <= 2e+68: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -9e+43) tmp = -1.0; elseif (x <= 2e+68) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9e+43) tmp = -1.0; elseif (x <= 2e+68) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9e+43], -1.0, If[LessEqual[x, 2e+68], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+43}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+68}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9e43 or 1.99999999999999991e68 < x Initial program 100.0%
Taylor expanded in x around inf 86.6%
if -9e43 < x < 1.99999999999999991e68Initial program 99.9%
Taylor expanded in y around inf 54.5%
Final simplification68.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 40.6%
Final simplification40.6%
(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 2024011
(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))))