
(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 9 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 100.0%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= x -7.6e+18)
(- 1.0 (/ y x))
(if (<= x 2.1e-41)
(+ (/ x y) -1.0)
(if (or (<= x 3.3e+90) (not (<= x 3.5e+113)))
(/ x (+ x y))
(/ (- y) (+ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -7.6e+18) {
tmp = 1.0 - (y / x);
} else if (x <= 2.1e-41) {
tmp = (x / y) + -1.0;
} else if ((x <= 3.3e+90) || !(x <= 3.5e+113)) {
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) :: tmp
if (x <= (-7.6d+18)) then
tmp = 1.0d0 - (y / x)
else if (x <= 2.1d-41) then
tmp = (x / y) + (-1.0d0)
else if ((x <= 3.3d+90) .or. (.not. (x <= 3.5d+113))) 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 tmp;
if (x <= -7.6e+18) {
tmp = 1.0 - (y / x);
} else if (x <= 2.1e-41) {
tmp = (x / y) + -1.0;
} else if ((x <= 3.3e+90) || !(x <= 3.5e+113)) {
tmp = x / (x + y);
} else {
tmp = -y / (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -7.6e+18: tmp = 1.0 - (y / x) elif x <= 2.1e-41: tmp = (x / y) + -1.0 elif (x <= 3.3e+90) or not (x <= 3.5e+113): tmp = x / (x + y) else: tmp = -y / (x + y) return tmp
function code(x, y) tmp = 0.0 if (x <= -7.6e+18) tmp = Float64(1.0 - Float64(y / x)); elseif (x <= 2.1e-41) tmp = Float64(Float64(x / y) + -1.0); elseif ((x <= 3.3e+90) || !(x <= 3.5e+113)) tmp = Float64(x / Float64(x + y)); else tmp = Float64(Float64(-y) / Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -7.6e+18) tmp = 1.0 - (y / x); elseif (x <= 2.1e-41) tmp = (x / y) + -1.0; elseif ((x <= 3.3e+90) || ~((x <= 3.5e+113))) tmp = x / (x + y); else tmp = -y / (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -7.6e+18], N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.1e-41], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], If[Or[LessEqual[x, 3.3e+90], N[Not[LessEqual[x, 3.5e+113]], $MachinePrecision]], N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision], N[((-y) / N[(x + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.6 \cdot 10^{+18}:\\
\;\;\;\;1 - \frac{y}{x}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-41}:\\
\;\;\;\;\frac{x}{y} + -1\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+90} \lor \neg \left(x \leq 3.5 \cdot 10^{+113}\right):\\
\;\;\;\;\frac{x}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-y}{x + y}\\
\end{array}
\end{array}
if x < -7.6e18Initial program 99.9%
div-sub99.9%
Applied egg-rr99.9%
frac-sub30.9%
associate-/r*32.5%
*-commutative32.5%
Applied egg-rr32.5%
Taylor expanded in x around inf 81.8%
Taylor expanded in x around inf 82.1%
mul-1-neg82.1%
unsub-neg82.1%
Simplified82.1%
if -7.6e18 < x < 2.10000000000000013e-41Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub66.6%
associate-/r*67.1%
*-commutative67.1%
Applied egg-rr67.1%
Taylor expanded in x around 0 76.9%
neg-mul-176.9%
Simplified76.9%
Taylor expanded in y around inf 77.0%
if 2.10000000000000013e-41 < x < 3.30000000000000008e90 or 3.5000000000000001e113 < x Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub39.7%
associate-/r*41.1%
*-commutative41.1%
Applied egg-rr41.1%
Taylor expanded in x around inf 86.9%
if 3.30000000000000008e90 < x < 3.5000000000000001e113Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub44.4%
associate-/r*45.5%
*-commutative45.5%
Applied egg-rr45.5%
Taylor expanded in x around 0 79.0%
neg-mul-179.0%
Simplified79.0%
Final simplification80.6%
(FPCore (x y)
:precision binary64
(if (<= x -2.4e+17)
(- 1.0 (/ y x))
(if (<= x 9e-40)
(+ (* 2.0 (/ x y)) -1.0)
(if (or (<= x 6.8e+90) (not (<= x 3.5e+113)))
(/ x (+ x y))
(/ (- y) (+ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -2.4e+17) {
tmp = 1.0 - (y / x);
} else if (x <= 9e-40) {
tmp = (2.0 * (x / y)) + -1.0;
} else if ((x <= 6.8e+90) || !(x <= 3.5e+113)) {
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) :: tmp
if (x <= (-2.4d+17)) then
tmp = 1.0d0 - (y / x)
else if (x <= 9d-40) then
tmp = (2.0d0 * (x / y)) + (-1.0d0)
else if ((x <= 6.8d+90) .or. (.not. (x <= 3.5d+113))) 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 tmp;
if (x <= -2.4e+17) {
tmp = 1.0 - (y / x);
} else if (x <= 9e-40) {
tmp = (2.0 * (x / y)) + -1.0;
} else if ((x <= 6.8e+90) || !(x <= 3.5e+113)) {
tmp = x / (x + y);
} else {
tmp = -y / (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.4e+17: tmp = 1.0 - (y / x) elif x <= 9e-40: tmp = (2.0 * (x / y)) + -1.0 elif (x <= 6.8e+90) or not (x <= 3.5e+113): tmp = x / (x + y) else: tmp = -y / (x + y) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.4e+17) tmp = Float64(1.0 - Float64(y / x)); elseif (x <= 9e-40) tmp = Float64(Float64(2.0 * Float64(x / y)) + -1.0); elseif ((x <= 6.8e+90) || !(x <= 3.5e+113)) tmp = Float64(x / Float64(x + y)); else tmp = Float64(Float64(-y) / Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.4e+17) tmp = 1.0 - (y / x); elseif (x <= 9e-40) tmp = (2.0 * (x / y)) + -1.0; elseif ((x <= 6.8e+90) || ~((x <= 3.5e+113))) tmp = x / (x + y); else tmp = -y / (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.4e+17], N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9e-40], N[(N[(2.0 * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[Or[LessEqual[x, 6.8e+90], N[Not[LessEqual[x, 3.5e+113]], $MachinePrecision]], N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision], N[((-y) / N[(x + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{+17}:\\
\;\;\;\;1 - \frac{y}{x}\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-40}:\\
\;\;\;\;2 \cdot \frac{x}{y} + -1\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+90} \lor \neg \left(x \leq 3.5 \cdot 10^{+113}\right):\\
\;\;\;\;\frac{x}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-y}{x + y}\\
\end{array}
\end{array}
if x < -2.4e17Initial program 99.9%
div-sub99.9%
Applied egg-rr99.9%
frac-sub30.9%
associate-/r*32.5%
*-commutative32.5%
Applied egg-rr32.5%
Taylor expanded in x around inf 81.8%
Taylor expanded in x around inf 82.1%
mul-1-neg82.1%
unsub-neg82.1%
Simplified82.1%
if -2.4e17 < x < 9.0000000000000002e-40Initial program 100.0%
Taylor expanded in x around 0 77.7%
if 9.0000000000000002e-40 < x < 6.80000000000000036e90 or 3.5000000000000001e113 < x Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub39.7%
associate-/r*41.1%
*-commutative41.1%
Applied egg-rr41.1%
Taylor expanded in x around inf 86.9%
if 6.80000000000000036e90 < x < 3.5000000000000001e113Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub44.4%
associate-/r*45.5%
*-commutative45.5%
Applied egg-rr45.5%
Taylor expanded in x around 0 79.0%
neg-mul-179.0%
Simplified79.0%
Final simplification80.9%
(FPCore (x y)
:precision binary64
(if (or (<= x -6.7e+16)
(and (not (<= x 1.55e-35)) (or (<= x 6.8e+90) (not (<= x 1.55e+95)))))
(- 1.0 (/ y x))
-1.0))
double code(double x, double y) {
double tmp;
if ((x <= -6.7e+16) || (!(x <= 1.55e-35) && ((x <= 6.8e+90) || !(x <= 1.55e+95)))) {
tmp = 1.0 - (y / 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 ((x <= (-6.7d+16)) .or. (.not. (x <= 1.55d-35)) .and. (x <= 6.8d+90) .or. (.not. (x <= 1.55d+95))) then
tmp = 1.0d0 - (y / x)
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -6.7e+16) || (!(x <= 1.55e-35) && ((x <= 6.8e+90) || !(x <= 1.55e+95)))) {
tmp = 1.0 - (y / x);
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -6.7e+16) or (not (x <= 1.55e-35) and ((x <= 6.8e+90) or not (x <= 1.55e+95))): tmp = 1.0 - (y / x) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if ((x <= -6.7e+16) || (!(x <= 1.55e-35) && ((x <= 6.8e+90) || !(x <= 1.55e+95)))) tmp = Float64(1.0 - Float64(y / x)); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -6.7e+16) || (~((x <= 1.55e-35)) && ((x <= 6.8e+90) || ~((x <= 1.55e+95))))) tmp = 1.0 - (y / x); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -6.7e+16], And[N[Not[LessEqual[x, 1.55e-35]], $MachinePrecision], Or[LessEqual[x, 6.8e+90], N[Not[LessEqual[x, 1.55e+95]], $MachinePrecision]]]], N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.7 \cdot 10^{+16} \lor \neg \left(x \leq 1.55 \cdot 10^{-35}\right) \land \left(x \leq 6.8 \cdot 10^{+90} \lor \neg \left(x \leq 1.55 \cdot 10^{+95}\right)\right):\\
\;\;\;\;1 - \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -6.7e16 or 1.55000000000000006e-35 < x < 6.80000000000000036e90 or 1.5500000000000001e95 < x Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub36.0%
associate-/r*37.6%
*-commutative37.6%
Applied egg-rr37.6%
Taylor expanded in x around inf 83.4%
Taylor expanded in x around inf 83.5%
mul-1-neg83.5%
unsub-neg83.5%
Simplified83.5%
if -6.7e16 < x < 1.55000000000000006e-35 or 6.80000000000000036e90 < x < 1.5500000000000001e95Initial program 100.0%
Taylor expanded in x around 0 77.2%
Final simplification80.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ y x))))
(if (<= x -1.02e+17)
t_0
(if (<= x 2.8e-37)
(+ (/ x y) -1.0)
(if (or (<= x 8.5e+90) (not (<= x 1.55e+95))) t_0 -1.0)))))
double code(double x, double y) {
double t_0 = 1.0 - (y / x);
double tmp;
if (x <= -1.02e+17) {
tmp = t_0;
} else if (x <= 2.8e-37) {
tmp = (x / y) + -1.0;
} else if ((x <= 8.5e+90) || !(x <= 1.55e+95)) {
tmp = t_0;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (y / x)
if (x <= (-1.02d+17)) then
tmp = t_0
else if (x <= 2.8d-37) then
tmp = (x / y) + (-1.0d0)
else if ((x <= 8.5d+90) .or. (.not. (x <= 1.55d+95))) then
tmp = t_0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (y / x);
double tmp;
if (x <= -1.02e+17) {
tmp = t_0;
} else if (x <= 2.8e-37) {
tmp = (x / y) + -1.0;
} else if ((x <= 8.5e+90) || !(x <= 1.55e+95)) {
tmp = t_0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (y / x) tmp = 0 if x <= -1.02e+17: tmp = t_0 elif x <= 2.8e-37: tmp = (x / y) + -1.0 elif (x <= 8.5e+90) or not (x <= 1.55e+95): tmp = t_0 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(y / x)) tmp = 0.0 if (x <= -1.02e+17) tmp = t_0; elseif (x <= 2.8e-37) tmp = Float64(Float64(x / y) + -1.0); elseif ((x <= 8.5e+90) || !(x <= 1.55e+95)) tmp = t_0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (y / x); tmp = 0.0; if (x <= -1.02e+17) tmp = t_0; elseif (x <= 2.8e-37) tmp = (x / y) + -1.0; elseif ((x <= 8.5e+90) || ~((x <= 1.55e+95))) tmp = t_0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.02e+17], t$95$0, If[LessEqual[x, 2.8e-37], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], If[Or[LessEqual[x, 8.5e+90], N[Not[LessEqual[x, 1.55e+95]], $MachinePrecision]], t$95$0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{x}\\
\mathbf{if}\;x \leq -1.02 \cdot 10^{+17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-37}:\\
\;\;\;\;\frac{x}{y} + -1\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+90} \lor \neg \left(x \leq 1.55 \cdot 10^{+95}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.02e17 or 2.8000000000000001e-37 < x < 8.5000000000000002e90 or 1.5500000000000001e95 < x Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub36.0%
associate-/r*37.6%
*-commutative37.6%
Applied egg-rr37.6%
Taylor expanded in x around inf 83.4%
Taylor expanded in x around inf 83.5%
mul-1-neg83.5%
unsub-neg83.5%
Simplified83.5%
if -1.02e17 < x < 2.8000000000000001e-37Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub66.6%
associate-/r*67.1%
*-commutative67.1%
Applied egg-rr67.1%
Taylor expanded in x around 0 76.9%
neg-mul-176.9%
Simplified76.9%
Taylor expanded in y around inf 77.0%
if 8.5000000000000002e90 < x < 1.5500000000000001e95Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification80.5%
(FPCore (x y)
:precision binary64
(if (<= x -1.35e+17)
(- 1.0 (/ y x))
(if (or (<= x 3.2e-35) (and (not (<= x 8.5e+90)) (<= x 1.95e+115)))
(+ (/ x y) -1.0)
(/ x (+ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.35e+17) {
tmp = 1.0 - (y / x);
} else if ((x <= 3.2e-35) || (!(x <= 8.5e+90) && (x <= 1.95e+115))) {
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 (x <= (-1.35d+17)) then
tmp = 1.0d0 - (y / x)
else if ((x <= 3.2d-35) .or. (.not. (x <= 8.5d+90)) .and. (x <= 1.95d+115)) 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 (x <= -1.35e+17) {
tmp = 1.0 - (y / x);
} else if ((x <= 3.2e-35) || (!(x <= 8.5e+90) && (x <= 1.95e+115))) {
tmp = (x / y) + -1.0;
} else {
tmp = x / (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.35e+17: tmp = 1.0 - (y / x) elif (x <= 3.2e-35) or (not (x <= 8.5e+90) and (x <= 1.95e+115)): tmp = (x / y) + -1.0 else: tmp = x / (x + y) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.35e+17) tmp = Float64(1.0 - Float64(y / x)); elseif ((x <= 3.2e-35) || (!(x <= 8.5e+90) && (x <= 1.95e+115))) 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 (x <= -1.35e+17) tmp = 1.0 - (y / x); elseif ((x <= 3.2e-35) || (~((x <= 8.5e+90)) && (x <= 1.95e+115))) tmp = (x / y) + -1.0; else tmp = x / (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.35e+17], N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 3.2e-35], And[N[Not[LessEqual[x, 8.5e+90]], $MachinePrecision], LessEqual[x, 1.95e+115]]], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+17}:\\
\;\;\;\;1 - \frac{y}{x}\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-35} \lor \neg \left(x \leq 8.5 \cdot 10^{+90}\right) \land x \leq 1.95 \cdot 10^{+115}:\\
\;\;\;\;\frac{x}{y} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + y}\\
\end{array}
\end{array}
if x < -1.35e17Initial program 99.9%
div-sub99.9%
Applied egg-rr99.9%
frac-sub30.9%
associate-/r*32.5%
*-commutative32.5%
Applied egg-rr32.5%
Taylor expanded in x around inf 81.8%
Taylor expanded in x around inf 82.1%
mul-1-neg82.1%
unsub-neg82.1%
Simplified82.1%
if -1.35e17 < x < 3.1999999999999998e-35 or 8.5000000000000002e90 < x < 1.95000000000000003e115Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub65.2%
associate-/r*65.7%
*-commutative65.7%
Applied egg-rr65.7%
Taylor expanded in x around 0 77.1%
neg-mul-177.1%
Simplified77.1%
Taylor expanded in y around inf 77.1%
if 3.1999999999999998e-35 < x < 8.5000000000000002e90 or 1.95000000000000003e115 < x Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
frac-sub39.7%
associate-/r*41.1%
*-commutative41.1%
Applied egg-rr41.1%
Taylor expanded in x around inf 86.9%
Final simplification80.6%
(FPCore (x y)
:precision binary64
(if (<= x -5e-39)
1.0
(if (<= x 1e-40)
-1.0
(if (<= x 8.5e+90) 1.0 (if (<= x 1.55e+95) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -5e-39) {
tmp = 1.0;
} else if (x <= 1e-40) {
tmp = -1.0;
} else if (x <= 8.5e+90) {
tmp = 1.0;
} else if (x <= 1.55e+95) {
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 <= (-5d-39)) then
tmp = 1.0d0
else if (x <= 1d-40) then
tmp = -1.0d0
else if (x <= 8.5d+90) then
tmp = 1.0d0
else if (x <= 1.55d+95) 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 <= -5e-39) {
tmp = 1.0;
} else if (x <= 1e-40) {
tmp = -1.0;
} else if (x <= 8.5e+90) {
tmp = 1.0;
} else if (x <= 1.55e+95) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5e-39: tmp = 1.0 elif x <= 1e-40: tmp = -1.0 elif x <= 8.5e+90: tmp = 1.0 elif x <= 1.55e+95: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -5e-39) tmp = 1.0; elseif (x <= 1e-40) tmp = -1.0; elseif (x <= 8.5e+90) tmp = 1.0; elseif (x <= 1.55e+95) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5e-39) tmp = 1.0; elseif (x <= 1e-40) tmp = -1.0; elseif (x <= 8.5e+90) tmp = 1.0; elseif (x <= 1.55e+95) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5e-39], 1.0, If[LessEqual[x, 1e-40], -1.0, If[LessEqual[x, 8.5e+90], 1.0, If[LessEqual[x, 1.55e+95], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-39}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 10^{-40}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+90}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+95}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -4.9999999999999998e-39 or 9.9999999999999993e-41 < x < 8.5000000000000002e90 or 1.5500000000000001e95 < x Initial program 100.0%
Taylor expanded in x around inf 81.1%
if -4.9999999999999998e-39 < x < 9.9999999999999993e-41 or 8.5000000000000002e90 < x < 1.5500000000000001e95Initial program 100.0%
Taylor expanded in x around 0 78.9%
Final simplification80.0%
(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 100.0%
Final simplification100.0%
(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 0 48.3%
Final simplification48.3%
(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 2024027
(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)))