
(FPCore (x y) :precision binary64 (/ (- x y) (+ x y)))
double code(double x, double y) {
return (x - y) / (x + y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (x + y)
end function
public static double code(double x, double y) {
return (x - y) / (x + y);
}
def code(x, y): return (x - y) / (x + y)
function code(x, y) return Float64(Float64(x - y) / Float64(x + y)) end
function tmp = code(x, y) tmp = (x - y) / (x + y); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{x + y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (- x y) (+ x y)))
double code(double x, double y) {
return (x - y) / (x + y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (x + y)
end function
public static double code(double x, double y) {
return (x - y) / (x + y);
}
def code(x, y): return (x - y) / (x + y)
function code(x, y) return Float64(Float64(x - y) / Float64(x + y)) end
function tmp = code(x, y) tmp = (x - y) / (x + y); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{x + y}
\end{array}
(FPCore (x y) :precision binary64 (- (/ x (+ x y)) (/ y (+ x y))))
double code(double x, double y) {
return (x / (x + y)) - (y / (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / (x + y)) - (y / (x + y))
end function
public static double code(double x, double y) {
return (x / (x + y)) - (y / (x + y));
}
def code(x, y): return (x / (x + y)) - (y / (x + y))
function code(x, y) return Float64(Float64(x / Float64(x + y)) - Float64(y / Float64(x + y))) end
function tmp = code(x, y) tmp = (x / (x + y)) - (y / (x + y)); end
code[x_, y_] := N[(N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision] - N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x + y} - \frac{y}{x + y}
\end{array}
Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ x y) -1.0)) (t_1 (/ x (+ x y))))
(if (<= y -7.5e-21)
t_0
(if (<= y 2.1e-32)
t_1
(if (<= y 1.35e+104) t_0 (if (<= y 2.7e+122) t_1 (/ (- y) (+ x y))))))))
double code(double x, double y) {
double t_0 = (x / y) + -1.0;
double t_1 = x / (x + y);
double tmp;
if (y <= -7.5e-21) {
tmp = t_0;
} else if (y <= 2.1e-32) {
tmp = t_1;
} else if (y <= 1.35e+104) {
tmp = t_0;
} else if (y <= 2.7e+122) {
tmp = t_1;
} else {
tmp = -y / (x + y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x / y) + (-1.0d0)
t_1 = x / (x + y)
if (y <= (-7.5d-21)) then
tmp = t_0
else if (y <= 2.1d-32) then
tmp = t_1
else if (y <= 1.35d+104) then
tmp = t_0
else if (y <= 2.7d+122) then
tmp = t_1
else
tmp = -y / (x + y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x / y) + -1.0;
double t_1 = x / (x + y);
double tmp;
if (y <= -7.5e-21) {
tmp = t_0;
} else if (y <= 2.1e-32) {
tmp = t_1;
} else if (y <= 1.35e+104) {
tmp = t_0;
} else if (y <= 2.7e+122) {
tmp = t_1;
} else {
tmp = -y / (x + y);
}
return tmp;
}
def code(x, y): t_0 = (x / y) + -1.0 t_1 = x / (x + y) tmp = 0 if y <= -7.5e-21: tmp = t_0 elif y <= 2.1e-32: tmp = t_1 elif y <= 1.35e+104: tmp = t_0 elif y <= 2.7e+122: tmp = t_1 else: tmp = -y / (x + y) return tmp
function code(x, y) t_0 = Float64(Float64(x / y) + -1.0) t_1 = Float64(x / Float64(x + y)) tmp = 0.0 if (y <= -7.5e-21) tmp = t_0; elseif (y <= 2.1e-32) tmp = t_1; elseif (y <= 1.35e+104) tmp = t_0; elseif (y <= 2.7e+122) tmp = t_1; else tmp = Float64(Float64(-y) / Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) + -1.0; t_1 = x / (x + y); tmp = 0.0; if (y <= -7.5e-21) tmp = t_0; elseif (y <= 2.1e-32) tmp = t_1; elseif (y <= 1.35e+104) tmp = t_0; elseif (y <= 2.7e+122) tmp = t_1; else tmp = -y / (x + y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.5e-21], t$95$0, If[LessEqual[y, 2.1e-32], t$95$1, If[LessEqual[y, 1.35e+104], t$95$0, If[LessEqual[y, 2.7e+122], t$95$1, N[((-y) / N[(x + y), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + -1\\
t_1 := \frac{x}{x + y}\\
\mathbf{if}\;y \leq -7.5 \cdot 10^{-21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-32}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+104}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+122}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{-y}{x + y}\\
\end{array}
\end{array}
if y < -7.50000000000000072e-21 or 2.0999999999999999e-32 < y < 1.34999999999999992e104Initial program 99.9%
div-sub99.9%
Applied egg-rr99.9%
frac-sub51.5%
associate-/r*52.9%
*-commutative52.9%
Applied egg-rr52.9%
Taylor expanded in x around 0 77.0%
neg-mul-177.0%
Simplified77.0%
Taylor expanded in y around inf 77.5%
if -7.50000000000000072e-21 < y < 2.0999999999999999e-32 or 1.34999999999999992e104 < y < 2.6999999999999998e122Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
frac-sub55.3%
associate-/r*56.2%
*-commutative56.2%
Applied egg-rr56.2%
Taylor expanded in x around inf 80.1%
if 2.6999999999999998e122 < y Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub16.7%
associate-/r*18.9%
*-commutative18.9%
Applied egg-rr18.9%
Taylor expanded in x around 0 93.4%
neg-mul-193.4%
Simplified93.4%
Final simplification80.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ x y) -1.0)))
(if (<= y -6.6e-21)
t_0
(if (<= y 2.25e-32)
(+ 1.0 (* -2.0 (/ y x)))
(if (<= y 1.35e+104)
t_0
(if (<= y 2.7e+122) (/ x (+ x y)) (/ (- y) (+ x y))))))))
double code(double x, double y) {
double t_0 = (x / y) + -1.0;
double tmp;
if (y <= -6.6e-21) {
tmp = t_0;
} else if (y <= 2.25e-32) {
tmp = 1.0 + (-2.0 * (y / x));
} else if (y <= 1.35e+104) {
tmp = t_0;
} else if (y <= 2.7e+122) {
tmp = x / (x + y);
} else {
tmp = -y / (x + y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x / y) + (-1.0d0)
if (y <= (-6.6d-21)) then
tmp = t_0
else if (y <= 2.25d-32) then
tmp = 1.0d0 + ((-2.0d0) * (y / x))
else if (y <= 1.35d+104) then
tmp = t_0
else if (y <= 2.7d+122) then
tmp = x / (x + y)
else
tmp = -y / (x + y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x / y) + -1.0;
double tmp;
if (y <= -6.6e-21) {
tmp = t_0;
} else if (y <= 2.25e-32) {
tmp = 1.0 + (-2.0 * (y / x));
} else if (y <= 1.35e+104) {
tmp = t_0;
} else if (y <= 2.7e+122) {
tmp = x / (x + y);
} else {
tmp = -y / (x + y);
}
return tmp;
}
def code(x, y): t_0 = (x / y) + -1.0 tmp = 0 if y <= -6.6e-21: tmp = t_0 elif y <= 2.25e-32: tmp = 1.0 + (-2.0 * (y / x)) elif y <= 1.35e+104: tmp = t_0 elif y <= 2.7e+122: tmp = x / (x + y) else: tmp = -y / (x + y) return tmp
function code(x, y) t_0 = Float64(Float64(x / y) + -1.0) tmp = 0.0 if (y <= -6.6e-21) tmp = t_0; elseif (y <= 2.25e-32) tmp = Float64(1.0 + Float64(-2.0 * Float64(y / x))); elseif (y <= 1.35e+104) tmp = t_0; elseif (y <= 2.7e+122) tmp = Float64(x / Float64(x + y)); else tmp = Float64(Float64(-y) / Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) + -1.0; tmp = 0.0; if (y <= -6.6e-21) tmp = t_0; elseif (y <= 2.25e-32) tmp = 1.0 + (-2.0 * (y / x)); elseif (y <= 1.35e+104) tmp = t_0; elseif (y <= 2.7e+122) tmp = x / (x + y); else tmp = -y / (x + y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[y, -6.6e-21], t$95$0, If[LessEqual[y, 2.25e-32], N[(1.0 + N[(-2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+104], t$95$0, If[LessEqual[y, 2.7e+122], N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision], N[((-y) / N[(x + y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} + -1\\
\mathbf{if}\;y \leq -6.6 \cdot 10^{-21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{-32}:\\
\;\;\;\;1 + -2 \cdot \frac{y}{x}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+104}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+122}:\\
\;\;\;\;\frac{x}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-y}{x + y}\\
\end{array}
\end{array}
if y < -6.60000000000000018e-21 or 2.25000000000000002e-32 < y < 1.34999999999999992e104Initial program 99.9%
div-sub99.9%
Applied egg-rr99.9%
frac-sub51.5%
associate-/r*52.9%
*-commutative52.9%
Applied egg-rr52.9%
Taylor expanded in x around 0 77.0%
neg-mul-177.0%
Simplified77.0%
Taylor expanded in y around inf 77.5%
if -6.60000000000000018e-21 < y < 2.25000000000000002e-32Initial program 99.9%
Taylor expanded in y around 0 80.1%
if 1.34999999999999992e104 < y < 2.6999999999999998e122Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub33.3%
associate-/r*34.9%
*-commutative34.9%
Applied egg-rr34.9%
Taylor expanded in x around inf 85.1%
if 2.6999999999999998e122 < y Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub16.7%
associate-/r*18.9%
*-commutative18.9%
Applied egg-rr18.9%
Taylor expanded in x around 0 93.4%
neg-mul-193.4%
Simplified93.4%
Final simplification81.1%
(FPCore (x y)
:precision binary64
(if (or (<= y -6.5e-21)
(and (not (<= y 2.2e-32))
(or (<= y 1.35e+104) (not (<= y 2.7e+122)))))
(+ (/ x y) -1.0)
(/ x (+ x y))))
double code(double x, double y) {
double tmp;
if ((y <= -6.5e-21) || (!(y <= 2.2e-32) && ((y <= 1.35e+104) || !(y <= 2.7e+122)))) {
tmp = (x / y) + -1.0;
} else {
tmp = x / (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 <= (-6.5d-21)) .or. (.not. (y <= 2.2d-32)) .and. (y <= 1.35d+104) .or. (.not. (y <= 2.7d+122))) then
tmp = (x / y) + (-1.0d0)
else
tmp = x / (x + y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -6.5e-21) || (!(y <= 2.2e-32) && ((y <= 1.35e+104) || !(y <= 2.7e+122)))) {
tmp = (x / y) + -1.0;
} else {
tmp = x / (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -6.5e-21) or (not (y <= 2.2e-32) and ((y <= 1.35e+104) or not (y <= 2.7e+122))): tmp = (x / y) + -1.0 else: tmp = x / (x + y) return tmp
function code(x, y) tmp = 0.0 if ((y <= -6.5e-21) || (!(y <= 2.2e-32) && ((y <= 1.35e+104) || !(y <= 2.7e+122)))) tmp = Float64(Float64(x / y) + -1.0); else tmp = Float64(x / Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -6.5e-21) || (~((y <= 2.2e-32)) && ((y <= 1.35e+104) || ~((y <= 2.7e+122))))) tmp = (x / y) + -1.0; else tmp = x / (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -6.5e-21], And[N[Not[LessEqual[y, 2.2e-32]], $MachinePrecision], Or[LessEqual[y, 1.35e+104], N[Not[LessEqual[y, 2.7e+122]], $MachinePrecision]]]], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{-21} \lor \neg \left(y \leq 2.2 \cdot 10^{-32}\right) \land \left(y \leq 1.35 \cdot 10^{+104} \lor \neg \left(y \leq 2.7 \cdot 10^{+122}\right)\right):\\
\;\;\;\;\frac{x}{y} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + y}\\
\end{array}
\end{array}
if y < -6.49999999999999987e-21 or 2.2e-32 < y < 1.34999999999999992e104 or 2.6999999999999998e122 < y Initial program 99.9%
div-sub99.9%
Applied egg-rr99.9%
frac-sub42.1%
associate-/r*43.7%
*-commutative43.7%
Applied egg-rr43.7%
Taylor expanded in x around 0 81.4%
neg-mul-181.4%
Simplified81.4%
Taylor expanded in y around inf 81.8%
if -6.49999999999999987e-21 < y < 2.2e-32 or 1.34999999999999992e104 < y < 2.6999999999999998e122Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
frac-sub55.3%
associate-/r*56.2%
*-commutative56.2%
Applied egg-rr56.2%
Taylor expanded in x around inf 80.1%
Final simplification80.9%
(FPCore (x y)
:precision binary64
(if (<= y -7.6e-21)
-1.0
(if (<= y 4e-42)
1.0
(if (<= y 1.35e+104) -1.0 (if (<= y 2.7e+122) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -7.6e-21) {
tmp = -1.0;
} else if (y <= 4e-42) {
tmp = 1.0;
} else if (y <= 1.35e+104) {
tmp = -1.0;
} else if (y <= 2.7e+122) {
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 (y <= (-7.6d-21)) then
tmp = -1.0d0
else if (y <= 4d-42) then
tmp = 1.0d0
else if (y <= 1.35d+104) then
tmp = -1.0d0
else if (y <= 2.7d+122) 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 (y <= -7.6e-21) {
tmp = -1.0;
} else if (y <= 4e-42) {
tmp = 1.0;
} else if (y <= 1.35e+104) {
tmp = -1.0;
} else if (y <= 2.7e+122) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7.6e-21: tmp = -1.0 elif y <= 4e-42: tmp = 1.0 elif y <= 1.35e+104: tmp = -1.0 elif y <= 2.7e+122: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -7.6e-21) tmp = -1.0; elseif (y <= 4e-42) tmp = 1.0; elseif (y <= 1.35e+104) tmp = -1.0; elseif (y <= 2.7e+122) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -7.6e-21) tmp = -1.0; elseif (y <= 4e-42) tmp = 1.0; elseif (y <= 1.35e+104) tmp = -1.0; elseif (y <= 2.7e+122) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -7.6e-21], -1.0, If[LessEqual[y, 4e-42], 1.0, If[LessEqual[y, 1.35e+104], -1.0, If[LessEqual[y, 2.7e+122], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.6 \cdot 10^{-21}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-42}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+104}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+122}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < -7.5999999999999995e-21 or 4.00000000000000015e-42 < y < 1.34999999999999992e104 or 2.6999999999999998e122 < y Initial program 99.9%
Taylor expanded in x around 0 80.7%
if -7.5999999999999995e-21 < y < 4.00000000000000015e-42 or 1.34999999999999992e104 < y < 2.6999999999999998e122Initial program 99.9%
Taylor expanded in x around inf 79.5%
Final simplification80.1%
(FPCore (x y)
:precision binary64
(if (<= y -6.1e-21)
-1.0
(if (<= y 2.25e-32)
(- 1.0 (/ y x))
(if (<= y 1.35e+104) -1.0 (if (<= y 2.7e+122) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -6.1e-21) {
tmp = -1.0;
} else if (y <= 2.25e-32) {
tmp = 1.0 - (y / x);
} else if (y <= 1.35e+104) {
tmp = -1.0;
} else if (y <= 2.7e+122) {
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 (y <= (-6.1d-21)) then
tmp = -1.0d0
else if (y <= 2.25d-32) then
tmp = 1.0d0 - (y / x)
else if (y <= 1.35d+104) then
tmp = -1.0d0
else if (y <= 2.7d+122) 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 (y <= -6.1e-21) {
tmp = -1.0;
} else if (y <= 2.25e-32) {
tmp = 1.0 - (y / x);
} else if (y <= 1.35e+104) {
tmp = -1.0;
} else if (y <= 2.7e+122) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6.1e-21: tmp = -1.0 elif y <= 2.25e-32: tmp = 1.0 - (y / x) elif y <= 1.35e+104: tmp = -1.0 elif y <= 2.7e+122: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -6.1e-21) tmp = -1.0; elseif (y <= 2.25e-32) tmp = Float64(1.0 - Float64(y / x)); elseif (y <= 1.35e+104) tmp = -1.0; elseif (y <= 2.7e+122) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -6.1e-21) tmp = -1.0; elseif (y <= 2.25e-32) tmp = 1.0 - (y / x); elseif (y <= 1.35e+104) tmp = -1.0; elseif (y <= 2.7e+122) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6.1e-21], -1.0, If[LessEqual[y, 2.25e-32], N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+104], -1.0, If[LessEqual[y, 2.7e+122], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.1 \cdot 10^{-21}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{-32}:\\
\;\;\;\;1 - \frac{y}{x}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+104}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+122}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < -6.10000000000000013e-21 or 2.25000000000000002e-32 < y < 1.34999999999999992e104 or 2.6999999999999998e122 < y Initial program 99.9%
Taylor expanded in x around 0 81.1%
if -6.10000000000000013e-21 < y < 2.25000000000000002e-32Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
frac-sub56.4%
associate-/r*57.3%
*-commutative57.3%
Applied egg-rr57.3%
Taylor expanded in x around inf 79.8%
Taylor expanded in x around inf 79.2%
mul-1-neg79.2%
unsub-neg79.2%
Simplified79.2%
if 1.34999999999999992e104 < y < 2.6999999999999998e122Initial program 100.0%
Taylor expanded in x around inf 83.6%
Final simplification80.3%
(FPCore (x y) :precision binary64 (if (or (<= y -6e-21) (not (<= y 2e-32))) (+ (* 2.0 (/ x y)) -1.0) (+ 1.0 (* -2.0 (/ y x)))))
double code(double x, double y) {
double tmp;
if ((y <= -6e-21) || !(y <= 2e-32)) {
tmp = (2.0 * (x / y)) + -1.0;
} else {
tmp = 1.0 + (-2.0 * (y / 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-21)) .or. (.not. (y <= 2d-32))) then
tmp = (2.0d0 * (x / y)) + (-1.0d0)
else
tmp = 1.0d0 + ((-2.0d0) * (y / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -6e-21) || !(y <= 2e-32)) {
tmp = (2.0 * (x / y)) + -1.0;
} else {
tmp = 1.0 + (-2.0 * (y / x));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -6e-21) or not (y <= 2e-32): tmp = (2.0 * (x / y)) + -1.0 else: tmp = 1.0 + (-2.0 * (y / x)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -6e-21) || !(y <= 2e-32)) tmp = Float64(Float64(2.0 * Float64(x / y)) + -1.0); else tmp = Float64(1.0 + Float64(-2.0 * Float64(y / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -6e-21) || ~((y <= 2e-32))) tmp = (2.0 * (x / y)) + -1.0; else tmp = 1.0 + (-2.0 * (y / x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -6e-21], N[Not[LessEqual[y, 2e-32]], $MachinePrecision]], N[(N[(2.0 * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 + N[(-2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-21} \lor \neg \left(y \leq 2 \cdot 10^{-32}\right):\\
\;\;\;\;2 \cdot \frac{x}{y} + -1\\
\mathbf{else}:\\
\;\;\;\;1 + -2 \cdot \frac{y}{x}\\
\end{array}
\end{array}
if y < -5.99999999999999982e-21 or 2.00000000000000011e-32 < y Initial program 99.9%
Taylor expanded in x around 0 80.1%
if -5.99999999999999982e-21 < y < 2.00000000000000011e-32Initial program 99.9%
Taylor expanded in y around 0 80.1%
Final simplification80.1%
(FPCore (x y) :precision binary64 (if (or (<= y -6.2e-21) (not (<= y 2.05e-32))) (+ (/ x y) -1.0) (- 1.0 (/ y x))))
double code(double x, double y) {
double tmp;
if ((y <= -6.2e-21) || !(y <= 2.05e-32)) {
tmp = (x / y) + -1.0;
} else {
tmp = 1.0 - (y / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-6.2d-21)) .or. (.not. (y <= 2.05d-32))) then
tmp = (x / y) + (-1.0d0)
else
tmp = 1.0d0 - (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -6.2e-21) || !(y <= 2.05e-32)) {
tmp = (x / y) + -1.0;
} else {
tmp = 1.0 - (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -6.2e-21) or not (y <= 2.05e-32): tmp = (x / y) + -1.0 else: tmp = 1.0 - (y / x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -6.2e-21) || !(y <= 2.05e-32)) tmp = Float64(Float64(x / y) + -1.0); else tmp = Float64(1.0 - Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -6.2e-21) || ~((y <= 2.05e-32))) tmp = (x / y) + -1.0; else tmp = 1.0 - (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -6.2e-21], N[Not[LessEqual[y, 2.05e-32]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{-21} \lor \neg \left(y \leq 2.05 \cdot 10^{-32}\right):\\
\;\;\;\;\frac{x}{y} + -1\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{y}{x}\\
\end{array}
\end{array}
if y < -6.1999999999999997e-21 or 2.04999999999999988e-32 < y Initial program 99.9%
div-sub99.9%
Applied egg-rr99.9%
frac-sub41.7%
associate-/r*43.3%
*-commutative43.3%
Applied egg-rr43.3%
Taylor expanded in x around 0 78.7%
neg-mul-178.7%
Simplified78.7%
Taylor expanded in y around inf 79.0%
if -6.1999999999999997e-21 < y < 2.04999999999999988e-32Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
frac-sub56.4%
associate-/r*57.3%
*-commutative57.3%
Applied egg-rr57.3%
Taylor expanded in x around inf 79.8%
Taylor expanded in x around inf 79.2%
mul-1-neg79.2%
unsub-neg79.2%
Simplified79.2%
Final simplification79.1%
(FPCore (x y) :precision binary64 (/ 1.0 (/ (+ x y) (- x y))))
double code(double x, double y) {
return 1.0 / ((x + y) / (x - y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 / ((x + y) / (x - y))
end function
public static double code(double x, double y) {
return 1.0 / ((x + y) / (x - y));
}
def code(x, y): return 1.0 / ((x + y) / (x - y))
function code(x, y) return Float64(1.0 / Float64(Float64(x + y) / Float64(x - y))) end
function tmp = code(x, y) tmp = 1.0 / ((x + y) / (x - y)); end
code[x_, y_] := N[(1.0 / N[(N[(x + y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{x + y}{x - y}}
\end{array}
Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
sub-div99.9%
clear-num99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (/ (- x y) (+ x y)))
double code(double x, double y) {
return (x - y) / (x + y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (x + y)
end function
public static double code(double x, double y) {
return (x - y) / (x + y);
}
def code(x, y): return (x - y) / (x + y)
function code(x, y) return Float64(Float64(x - y) / Float64(x + y)) end
function tmp = code(x, y) tmp = (x - y) / (x + y); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{x + y}
\end{array}
Initial program 99.9%
Final simplification99.9%
(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 99.9%
Taylor expanded in x around 0 51.1%
Final simplification51.1%
(FPCore (x y) :precision binary64 (- (/ x (+ x y)) (/ y (+ x y))))
double code(double x, double y) {
return (x / (x + y)) - (y / (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / (x + y)) - (y / (x + y))
end function
public static double code(double x, double y) {
return (x / (x + y)) - (y / (x + y));
}
def code(x, y): return (x / (x + y)) - (y / (x + y))
function code(x, y) return Float64(Float64(x / Float64(x + y)) - Float64(y / Float64(x + y))) end
function tmp = code(x, y) tmp = (x / (x + y)) - (y / (x + y)); end
code[x_, y_] := N[(N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision] - N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x + y} - \frac{y}{x + y}
\end{array}
herbie shell --seed 2024041
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, D"
:precision binary64
:herbie-target
(- (/ x (+ x y)) (/ y (+ x y)))
(/ (- x y) (+ x y)))