
(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 99.9%
div-sub100.0%
Applied egg-rr100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (* -2.0 (/ y x)))))
(if (<= x -6.8e-10)
t_0
(if (<= x 1.9e-51)
(+ (* 2.0 (/ x y)) -1.0)
(if (<= x 1.9e+26) (/ (- x y) x) (if (<= x 6.8e+42) -1.0 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + (-2.0 * (y / x));
double tmp;
if (x <= -6.8e-10) {
tmp = t_0;
} else if (x <= 1.9e-51) {
tmp = (2.0 * (x / y)) + -1.0;
} else if (x <= 1.9e+26) {
tmp = (x - y) / x;
} else if (x <= 6.8e+42) {
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 = 1.0d0 + ((-2.0d0) * (y / x))
if (x <= (-6.8d-10)) then
tmp = t_0
else if (x <= 1.9d-51) then
tmp = (2.0d0 * (x / y)) + (-1.0d0)
else if (x <= 1.9d+26) then
tmp = (x - y) / x
else if (x <= 6.8d+42) 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 = 1.0 + (-2.0 * (y / x));
double tmp;
if (x <= -6.8e-10) {
tmp = t_0;
} else if (x <= 1.9e-51) {
tmp = (2.0 * (x / y)) + -1.0;
} else if (x <= 1.9e+26) {
tmp = (x - y) / x;
} else if (x <= 6.8e+42) {
tmp = -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (-2.0 * (y / x)) tmp = 0 if x <= -6.8e-10: tmp = t_0 elif x <= 1.9e-51: tmp = (2.0 * (x / y)) + -1.0 elif x <= 1.9e+26: tmp = (x - y) / x elif x <= 6.8e+42: tmp = -1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(-2.0 * Float64(y / x))) tmp = 0.0 if (x <= -6.8e-10) tmp = t_0; elseif (x <= 1.9e-51) tmp = Float64(Float64(2.0 * Float64(x / y)) + -1.0); elseif (x <= 1.9e+26) tmp = Float64(Float64(x - y) / x); elseif (x <= 6.8e+42) tmp = -1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (-2.0 * (y / x)); tmp = 0.0; if (x <= -6.8e-10) tmp = t_0; elseif (x <= 1.9e-51) tmp = (2.0 * (x / y)) + -1.0; elseif (x <= 1.9e+26) tmp = (x - y) / x; elseif (x <= 6.8e+42) tmp = -1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(-2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.8e-10], t$95$0, If[LessEqual[x, 1.9e-51], N[(N[(2.0 * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, 1.9e+26], N[(N[(x - y), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 6.8e+42], -1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -2 \cdot \frac{y}{x}\\
\mathbf{if}\;x \leq -6.8 \cdot 10^{-10}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-51}:\\
\;\;\;\;2 \cdot \frac{x}{y} + -1\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+26}:\\
\;\;\;\;\frac{x - y}{x}\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+42}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -6.8000000000000003e-10 or 6.7999999999999995e42 < x Initial program 99.9%
Taylor expanded in y around 0 79.8%
if -6.8000000000000003e-10 < x < 1.90000000000000001e-51Initial program 99.9%
Taylor expanded in x around 0 78.2%
if 1.90000000000000001e-51 < x < 1.9000000000000001e26Initial program 99.9%
Taylor expanded in x around inf 68.3%
if 1.9000000000000001e26 < x < 6.7999999999999995e42Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification78.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (* -2.0 (/ y x)))))
(if (<= x -50000000000.0)
t_0
(if (<= x 1.35e-62)
(/ (- y) (+ x y))
(if (<= x 2e+26) (/ (- x y) x) (if (<= x 6.8e+42) -1.0 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + (-2.0 * (y / x));
double tmp;
if (x <= -50000000000.0) {
tmp = t_0;
} else if (x <= 1.35e-62) {
tmp = -y / (x + y);
} else if (x <= 2e+26) {
tmp = (x - y) / x;
} else if (x <= 6.8e+42) {
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 = 1.0d0 + ((-2.0d0) * (y / x))
if (x <= (-50000000000.0d0)) then
tmp = t_0
else if (x <= 1.35d-62) then
tmp = -y / (x + y)
else if (x <= 2d+26) then
tmp = (x - y) / x
else if (x <= 6.8d+42) 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 = 1.0 + (-2.0 * (y / x));
double tmp;
if (x <= -50000000000.0) {
tmp = t_0;
} else if (x <= 1.35e-62) {
tmp = -y / (x + y);
} else if (x <= 2e+26) {
tmp = (x - y) / x;
} else if (x <= 6.8e+42) {
tmp = -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (-2.0 * (y / x)) tmp = 0 if x <= -50000000000.0: tmp = t_0 elif x <= 1.35e-62: tmp = -y / (x + y) elif x <= 2e+26: tmp = (x - y) / x elif x <= 6.8e+42: tmp = -1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(-2.0 * Float64(y / x))) tmp = 0.0 if (x <= -50000000000.0) tmp = t_0; elseif (x <= 1.35e-62) tmp = Float64(Float64(-y) / Float64(x + y)); elseif (x <= 2e+26) tmp = Float64(Float64(x - y) / x); elseif (x <= 6.8e+42) tmp = -1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (-2.0 * (y / x)); tmp = 0.0; if (x <= -50000000000.0) tmp = t_0; elseif (x <= 1.35e-62) tmp = -y / (x + y); elseif (x <= 2e+26) tmp = (x - y) / x; elseif (x <= 6.8e+42) tmp = -1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(-2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -50000000000.0], t$95$0, If[LessEqual[x, 1.35e-62], N[((-y) / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2e+26], N[(N[(x - y), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 6.8e+42], -1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -2 \cdot \frac{y}{x}\\
\mathbf{if}\;x \leq -50000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-62}:\\
\;\;\;\;\frac{-y}{x + y}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+26}:\\
\;\;\;\;\frac{x - y}{x}\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+42}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5e10 or 6.7999999999999995e42 < x Initial program 100.0%
Taylor expanded in y around 0 81.9%
if -5e10 < x < 1.3500000000000001e-62Initial program 99.9%
Taylor expanded in x around 0 76.3%
neg-mul-176.3%
Simplified76.3%
if 1.3500000000000001e-62 < x < 2.0000000000000001e26Initial program 99.9%
Taylor expanded in x around inf 66.4%
if 2.0000000000000001e26 < x < 6.7999999999999995e42Initial program 100.0%
Taylor expanded in x around 0 100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- x y) x)))
(if (<= x -1.5e+14)
t_0
(if (<= x 1.7e-62)
(/ (- y) (+ x y))
(if (or (<= x 1.85e+26) (not (<= x 7.6e+42))) t_0 -1.0)))))
double code(double x, double y) {
double t_0 = (x - y) / x;
double tmp;
if (x <= -1.5e+14) {
tmp = t_0;
} else if (x <= 1.7e-62) {
tmp = -y / (x + y);
} else if ((x <= 1.85e+26) || !(x <= 7.6e+42)) {
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 = (x - y) / x
if (x <= (-1.5d+14)) then
tmp = t_0
else if (x <= 1.7d-62) then
tmp = -y / (x + y)
else if ((x <= 1.85d+26) .or. (.not. (x <= 7.6d+42))) 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 = (x - y) / x;
double tmp;
if (x <= -1.5e+14) {
tmp = t_0;
} else if (x <= 1.7e-62) {
tmp = -y / (x + y);
} else if ((x <= 1.85e+26) || !(x <= 7.6e+42)) {
tmp = t_0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = (x - y) / x tmp = 0 if x <= -1.5e+14: tmp = t_0 elif x <= 1.7e-62: tmp = -y / (x + y) elif (x <= 1.85e+26) or not (x <= 7.6e+42): tmp = t_0 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) / x) tmp = 0.0 if (x <= -1.5e+14) tmp = t_0; elseif (x <= 1.7e-62) tmp = Float64(Float64(-y) / Float64(x + y)); elseif ((x <= 1.85e+26) || !(x <= 7.6e+42)) tmp = t_0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) / x; tmp = 0.0; if (x <= -1.5e+14) tmp = t_0; elseif (x <= 1.7e-62) tmp = -y / (x + y); elseif ((x <= 1.85e+26) || ~((x <= 7.6e+42))) tmp = t_0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[x, -1.5e+14], t$95$0, If[LessEqual[x, 1.7e-62], N[((-y) / N[(x + y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 1.85e+26], N[Not[LessEqual[x, 7.6e+42]], $MachinePrecision]], t$95$0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{x}\\
\mathbf{if}\;x \leq -1.5 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-62}:\\
\;\;\;\;\frac{-y}{x + y}\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{+26} \lor \neg \left(x \leq 7.6 \cdot 10^{+42}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.5e14 or 1.69999999999999994e-62 < x < 1.84999999999999994e26 or 7.5999999999999997e42 < x Initial program 99.9%
Taylor expanded in x around inf 79.5%
if -1.5e14 < x < 1.69999999999999994e-62Initial program 99.9%
Taylor expanded in x around 0 76.3%
neg-mul-176.3%
Simplified76.3%
if 1.84999999999999994e26 < x < 7.5999999999999997e42Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification78.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- x y) x)))
(if (<= x -5.3e-11)
t_0
(if (<= x 2.8e-51)
(/ (- x y) y)
(if (or (<= x 1.45e+26) (not (<= x 6.8e+42))) t_0 -1.0)))))
double code(double x, double y) {
double t_0 = (x - y) / x;
double tmp;
if (x <= -5.3e-11) {
tmp = t_0;
} else if (x <= 2.8e-51) {
tmp = (x - y) / y;
} else if ((x <= 1.45e+26) || !(x <= 6.8e+42)) {
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 = (x - y) / x
if (x <= (-5.3d-11)) then
tmp = t_0
else if (x <= 2.8d-51) then
tmp = (x - y) / y
else if ((x <= 1.45d+26) .or. (.not. (x <= 6.8d+42))) 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 = (x - y) / x;
double tmp;
if (x <= -5.3e-11) {
tmp = t_0;
} else if (x <= 2.8e-51) {
tmp = (x - y) / y;
} else if ((x <= 1.45e+26) || !(x <= 6.8e+42)) {
tmp = t_0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = (x - y) / x tmp = 0 if x <= -5.3e-11: tmp = t_0 elif x <= 2.8e-51: tmp = (x - y) / y elif (x <= 1.45e+26) or not (x <= 6.8e+42): tmp = t_0 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) / x) tmp = 0.0 if (x <= -5.3e-11) tmp = t_0; elseif (x <= 2.8e-51) tmp = Float64(Float64(x - y) / y); elseif ((x <= 1.45e+26) || !(x <= 6.8e+42)) tmp = t_0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) / x; tmp = 0.0; if (x <= -5.3e-11) tmp = t_0; elseif (x <= 2.8e-51) tmp = (x - y) / y; elseif ((x <= 1.45e+26) || ~((x <= 6.8e+42))) tmp = t_0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[x, -5.3e-11], t$95$0, If[LessEqual[x, 2.8e-51], N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision], If[Or[LessEqual[x, 1.45e+26], N[Not[LessEqual[x, 6.8e+42]], $MachinePrecision]], t$95$0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{x}\\
\mathbf{if}\;x \leq -5.3 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-51}:\\
\;\;\;\;\frac{x - y}{y}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{+26} \lor \neg \left(x \leq 6.8 \cdot 10^{+42}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -5.2999999999999998e-11 or 2.8e-51 < x < 1.45e26 or 6.7999999999999995e42 < x Initial program 99.9%
Taylor expanded in x around inf 78.2%
if -5.2999999999999998e-11 < x < 2.8e-51Initial program 99.9%
Taylor expanded in x around 0 77.4%
if 1.45e26 < x < 6.7999999999999995e42Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification78.3%
(FPCore (x y) :precision binary64 (if (or (<= x -9.8e-11) (not (<= x 1.8e-62))) (/ (- x y) x) -1.0))
double code(double x, double y) {
double tmp;
if ((x <= -9.8e-11) || !(x <= 1.8e-62)) {
tmp = (x - 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 <= (-9.8d-11)) .or. (.not. (x <= 1.8d-62))) then
tmp = (x - y) / x
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -9.8e-11) || !(x <= 1.8e-62)) {
tmp = (x - y) / x;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -9.8e-11) or not (x <= 1.8e-62): tmp = (x - y) / x else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if ((x <= -9.8e-11) || !(x <= 1.8e-62)) tmp = Float64(Float64(x - y) / x); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -9.8e-11) || ~((x <= 1.8e-62))) tmp = (x - y) / x; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -9.8e-11], N[Not[LessEqual[x, 1.8e-62]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] / x), $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.8 \cdot 10^{-11} \lor \neg \left(x \leq 1.8 \cdot 10^{-62}\right):\\
\;\;\;\;\frac{x - y}{x}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.7999999999999998e-11 or 1.8e-62 < x Initial program 99.9%
Taylor expanded in x around inf 75.1%
if -9.7999999999999998e-11 < x < 1.8e-62Initial program 99.9%
Taylor expanded in x around 0 77.2%
Final simplification76.1%
(FPCore (x y) :precision binary64 (if (<= x -28000000000000.0) 1.0 (if (<= x 8e-55) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -28000000000000.0) {
tmp = 1.0;
} else if (x <= 8e-55) {
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 <= (-28000000000000.0d0)) then
tmp = 1.0d0
else if (x <= 8d-55) 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 <= -28000000000000.0) {
tmp = 1.0;
} else if (x <= 8e-55) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -28000000000000.0: tmp = 1.0 elif x <= 8e-55: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -28000000000000.0) tmp = 1.0; elseif (x <= 8e-55) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -28000000000000.0) tmp = 1.0; elseif (x <= 8e-55) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -28000000000000.0], 1.0, If[LessEqual[x, 8e-55], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -28000000000000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-55}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -2.8e13 or 7.99999999999999996e-55 < x Initial program 100.0%
Taylor expanded in x around inf 76.3%
if -2.8e13 < x < 7.99999999999999996e-55Initial program 99.9%
Taylor expanded in x around 0 75.1%
(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%
(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 49.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 2024111
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, D"
:precision binary64
:alt
(- (/ x (+ x y)) (/ y (+ x y)))
(/ (- x y) (+ x y)))