
(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)))) (t_1 (+ (* 2.0 (/ x y)) -1.0)))
(if (<= x -2100000.0)
t_0
(if (<= x -1.5e-124)
t_1
(if (<= x -2.8e-137) 1.0 (if (<= x 5e+25) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + (-2.0 * (y / x));
double t_1 = (2.0 * (x / y)) + -1.0;
double tmp;
if (x <= -2100000.0) {
tmp = t_0;
} else if (x <= -1.5e-124) {
tmp = t_1;
} else if (x <= -2.8e-137) {
tmp = 1.0;
} else if (x <= 5e+25) {
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 + ((-2.0d0) * (y / x))
t_1 = (2.0d0 * (x / y)) + (-1.0d0)
if (x <= (-2100000.0d0)) then
tmp = t_0
else if (x <= (-1.5d-124)) then
tmp = t_1
else if (x <= (-2.8d-137)) then
tmp = 1.0d0
else if (x <= 5d+25) 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 + (-2.0 * (y / x));
double t_1 = (2.0 * (x / y)) + -1.0;
double tmp;
if (x <= -2100000.0) {
tmp = t_0;
} else if (x <= -1.5e-124) {
tmp = t_1;
} else if (x <= -2.8e-137) {
tmp = 1.0;
} else if (x <= 5e+25) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (-2.0 * (y / x)) t_1 = (2.0 * (x / y)) + -1.0 tmp = 0 if x <= -2100000.0: tmp = t_0 elif x <= -1.5e-124: tmp = t_1 elif x <= -2.8e-137: tmp = 1.0 elif x <= 5e+25: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(-2.0 * Float64(y / x))) t_1 = Float64(Float64(2.0 * Float64(x / y)) + -1.0) tmp = 0.0 if (x <= -2100000.0) tmp = t_0; elseif (x <= -1.5e-124) tmp = t_1; elseif (x <= -2.8e-137) tmp = 1.0; elseif (x <= 5e+25) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (-2.0 * (y / x)); t_1 = (2.0 * (x / y)) + -1.0; tmp = 0.0; if (x <= -2100000.0) tmp = t_0; elseif (x <= -1.5e-124) tmp = t_1; elseif (x <= -2.8e-137) tmp = 1.0; elseif (x <= 5e+25) tmp = t_1; 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]}, Block[{t$95$1 = N[(N[(2.0 * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[x, -2100000.0], t$95$0, If[LessEqual[x, -1.5e-124], t$95$1, If[LessEqual[x, -2.8e-137], 1.0, If[LessEqual[x, 5e+25], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -2 \cdot \frac{y}{x}\\
t_1 := 2 \cdot \frac{x}{y} + -1\\
\mathbf{if}\;x \leq -2100000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.5 \cdot 10^{-124}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2.8 \cdot 10^{-137}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+25}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.1e6 or 5.00000000000000024e25 < x Initial program 100.0%
Taylor expanded in y around 0 82.8%
if -2.1e6 < x < -1.5e-124 or -2.7999999999999999e-137 < x < 5.00000000000000024e25Initial program 99.9%
Taylor expanded in x around 0 77.9%
if -1.5e-124 < x < -2.7999999999999999e-137Initial program 100.0%
Taylor expanded in x around inf 100.0%
Final simplification80.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (* -2.0 (/ y x)))) (t_1 (/ y (- (- x) y))))
(if (<= x -8500.0)
t_0
(if (<= x -1.5e-124)
t_1
(if (<= x -2.4e-137) 1.0 (if (<= x 4.2e+23) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + (-2.0 * (y / x));
double t_1 = y / (-x - y);
double tmp;
if (x <= -8500.0) {
tmp = t_0;
} else if (x <= -1.5e-124) {
tmp = t_1;
} else if (x <= -2.4e-137) {
tmp = 1.0;
} else if (x <= 4.2e+23) {
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 + ((-2.0d0) * (y / x))
t_1 = y / (-x - y)
if (x <= (-8500.0d0)) then
tmp = t_0
else if (x <= (-1.5d-124)) then
tmp = t_1
else if (x <= (-2.4d-137)) then
tmp = 1.0d0
else if (x <= 4.2d+23) 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 + (-2.0 * (y / x));
double t_1 = y / (-x - y);
double tmp;
if (x <= -8500.0) {
tmp = t_0;
} else if (x <= -1.5e-124) {
tmp = t_1;
} else if (x <= -2.4e-137) {
tmp = 1.0;
} else if (x <= 4.2e+23) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (-2.0 * (y / x)) t_1 = y / (-x - y) tmp = 0 if x <= -8500.0: tmp = t_0 elif x <= -1.5e-124: tmp = t_1 elif x <= -2.4e-137: tmp = 1.0 elif x <= 4.2e+23: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(-2.0 * Float64(y / x))) t_1 = Float64(y / Float64(Float64(-x) - y)) tmp = 0.0 if (x <= -8500.0) tmp = t_0; elseif (x <= -1.5e-124) tmp = t_1; elseif (x <= -2.4e-137) tmp = 1.0; elseif (x <= 4.2e+23) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (-2.0 * (y / x)); t_1 = y / (-x - y); tmp = 0.0; if (x <= -8500.0) tmp = t_0; elseif (x <= -1.5e-124) tmp = t_1; elseif (x <= -2.4e-137) tmp = 1.0; elseif (x <= 4.2e+23) tmp = t_1; 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]}, Block[{t$95$1 = N[(y / N[((-x) - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8500.0], t$95$0, If[LessEqual[x, -1.5e-124], t$95$1, If[LessEqual[x, -2.4e-137], 1.0, If[LessEqual[x, 4.2e+23], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -2 \cdot \frac{y}{x}\\
t_1 := \frac{y}{\left(-x\right) - y}\\
\mathbf{if}\;x \leq -8500:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.5 \cdot 10^{-124}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2.4 \cdot 10^{-137}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+23}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -8500 or 4.2000000000000003e23 < x Initial program 100.0%
Taylor expanded in y around 0 82.8%
if -8500 < x < -1.5e-124 or -2.4e-137 < x < 4.2000000000000003e23Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
clear-num100.0%
frac-sub61.3%
*-un-lft-identity61.3%
Applied egg-rr61.3%
associate-*l/49.4%
unpow249.4%
associate-/r/49.7%
associate--l+49.7%
associate-*l/49.7%
associate-/l*49.8%
Simplified49.8%
associate-*l/49.5%
unpow249.5%
associate-/r*50.6%
*-commutative50.6%
associate-+r-50.6%
*-un-lft-identity50.6%
*-commutative50.6%
distribute-rgt-out--50.6%
Applied egg-rr50.6%
Taylor expanded in x around 0 77.3%
mul-1-neg77.3%
Simplified77.3%
if -1.5e-124 < x < -2.4e-137Initial program 100.0%
Taylor expanded in x around inf 100.0%
Final simplification80.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x y))) (t_1 (/ y (- (- x) y))))
(if (<= x -740000.0)
t_0
(if (<= x -1.5e-124)
t_1
(if (<= x -2.8e-137) 1.0 (if (<= x 4.4e+39) t_1 t_0))))))
double code(double x, double y) {
double t_0 = x / (x + y);
double t_1 = y / (-x - y);
double tmp;
if (x <= -740000.0) {
tmp = t_0;
} else if (x <= -1.5e-124) {
tmp = t_1;
} else if (x <= -2.8e-137) {
tmp = 1.0;
} else if (x <= 4.4e+39) {
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 = x / (x + y)
t_1 = y / (-x - y)
if (x <= (-740000.0d0)) then
tmp = t_0
else if (x <= (-1.5d-124)) then
tmp = t_1
else if (x <= (-2.8d-137)) then
tmp = 1.0d0
else if (x <= 4.4d+39) 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 = x / (x + y);
double t_1 = y / (-x - y);
double tmp;
if (x <= -740000.0) {
tmp = t_0;
} else if (x <= -1.5e-124) {
tmp = t_1;
} else if (x <= -2.8e-137) {
tmp = 1.0;
} else if (x <= 4.4e+39) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (x + y) t_1 = y / (-x - y) tmp = 0 if x <= -740000.0: tmp = t_0 elif x <= -1.5e-124: tmp = t_1 elif x <= -2.8e-137: tmp = 1.0 elif x <= 4.4e+39: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(x + y)) t_1 = Float64(y / Float64(Float64(-x) - y)) tmp = 0.0 if (x <= -740000.0) tmp = t_0; elseif (x <= -1.5e-124) tmp = t_1; elseif (x <= -2.8e-137) tmp = 1.0; elseif (x <= 4.4e+39) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + y); t_1 = y / (-x - y); tmp = 0.0; if (x <= -740000.0) tmp = t_0; elseif (x <= -1.5e-124) tmp = t_1; elseif (x <= -2.8e-137) tmp = 1.0; elseif (x <= 4.4e+39) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[((-x) - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -740000.0], t$95$0, If[LessEqual[x, -1.5e-124], t$95$1, If[LessEqual[x, -2.8e-137], 1.0, If[LessEqual[x, 4.4e+39], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + y}\\
t_1 := \frac{y}{\left(-x\right) - y}\\
\mathbf{if}\;x \leq -740000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.5 \cdot 10^{-124}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2.8 \cdot 10^{-137}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+39}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -7.4e5 or 4.4000000000000003e39 < x Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
clear-num100.0%
frac-sub92.3%
*-un-lft-identity92.3%
Applied egg-rr92.3%
associate-*l/30.9%
unpow230.9%
associate-/r/30.9%
associate--l+30.9%
associate-*l/29.9%
associate-/l*30.9%
Simplified30.9%
associate-*l/29.0%
unpow229.0%
associate-/r*31.1%
*-commutative31.1%
associate-+r-31.1%
*-un-lft-identity31.1%
*-commutative31.1%
distribute-rgt-out--31.2%
Applied egg-rr31.2%
Taylor expanded in x around inf 82.6%
if -7.4e5 < x < -1.5e-124 or -2.7999999999999999e-137 < x < 4.4000000000000003e39Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
clear-num100.0%
frac-sub61.9%
*-un-lft-identity61.9%
Applied egg-rr61.9%
associate-*l/50.2%
unpow250.2%
associate-/r/50.5%
associate--l+50.5%
associate-*l/50.5%
associate-/l*50.5%
Simplified50.5%
associate-*l/50.2%
unpow250.2%
associate-/r*51.4%
*-commutative51.4%
associate-+r-51.4%
*-un-lft-identity51.4%
*-commutative51.4%
distribute-rgt-out--51.4%
Applied egg-rr51.4%
Taylor expanded in x around 0 76.9%
mul-1-neg76.9%
Simplified76.9%
if -1.5e-124 < x < -2.7999999999999999e-137Initial program 100.0%
Taylor expanded in x around inf 100.0%
Final simplification80.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ x y))))
(if (<= x -95000.0)
t_0
(if (<= x -1.5e-124)
-1.0
(if (<= x -2.8e-137) 1.0 (if (<= x 2.1e+30) -1.0 t_0))))))
double code(double x, double y) {
double t_0 = x / (x + y);
double tmp;
if (x <= -95000.0) {
tmp = t_0;
} else if (x <= -1.5e-124) {
tmp = -1.0;
} else if (x <= -2.8e-137) {
tmp = 1.0;
} else if (x <= 2.1e+30) {
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 = x / (x + y)
if (x <= (-95000.0d0)) then
tmp = t_0
else if (x <= (-1.5d-124)) then
tmp = -1.0d0
else if (x <= (-2.8d-137)) then
tmp = 1.0d0
else if (x <= 2.1d+30) 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 = x / (x + y);
double tmp;
if (x <= -95000.0) {
tmp = t_0;
} else if (x <= -1.5e-124) {
tmp = -1.0;
} else if (x <= -2.8e-137) {
tmp = 1.0;
} else if (x <= 2.1e+30) {
tmp = -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (x + y) tmp = 0 if x <= -95000.0: tmp = t_0 elif x <= -1.5e-124: tmp = -1.0 elif x <= -2.8e-137: tmp = 1.0 elif x <= 2.1e+30: tmp = -1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(x + y)) tmp = 0.0 if (x <= -95000.0) tmp = t_0; elseif (x <= -1.5e-124) tmp = -1.0; elseif (x <= -2.8e-137) tmp = 1.0; elseif (x <= 2.1e+30) tmp = -1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (x + y); tmp = 0.0; if (x <= -95000.0) tmp = t_0; elseif (x <= -1.5e-124) tmp = -1.0; elseif (x <= -2.8e-137) tmp = 1.0; elseif (x <= 2.1e+30) tmp = -1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -95000.0], t$95$0, If[LessEqual[x, -1.5e-124], -1.0, If[LessEqual[x, -2.8e-137], 1.0, If[LessEqual[x, 2.1e+30], -1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + y}\\
\mathbf{if}\;x \leq -95000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.5 \cdot 10^{-124}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -2.8 \cdot 10^{-137}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+30}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -95000 or 2.1e30 < x Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
clear-num100.0%
frac-sub92.4%
*-un-lft-identity92.4%
Applied egg-rr92.4%
associate-*l/32.1%
unpow232.1%
associate-/r/32.0%
associate--l+32.0%
associate-*l/31.1%
associate-/l*32.0%
Simplified32.0%
associate-*l/30.2%
unpow230.2%
associate-/r*32.3%
*-commutative32.3%
associate-+r-32.3%
*-un-lft-identity32.3%
*-commutative32.3%
distribute-rgt-out--32.3%
Applied egg-rr32.3%
Taylor expanded in x around inf 82.1%
if -95000 < x < -1.5e-124 or -2.7999999999999999e-137 < x < 2.1e30Initial program 99.9%
Taylor expanded in x around 0 76.7%
if -1.5e-124 < x < -2.7999999999999999e-137Initial program 100.0%
Taylor expanded in x around inf 100.0%
(FPCore (x y)
:precision binary64
(if (<= x -10000.0)
1.0
(if (<= x -1.56e-124)
-1.0
(if (<= x -2.8e-137) 1.0 (if (<= x 2.8e+29) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -10000.0) {
tmp = 1.0;
} else if (x <= -1.56e-124) {
tmp = -1.0;
} else if (x <= -2.8e-137) {
tmp = 1.0;
} else if (x <= 2.8e+29) {
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 <= (-10000.0d0)) then
tmp = 1.0d0
else if (x <= (-1.56d-124)) then
tmp = -1.0d0
else if (x <= (-2.8d-137)) then
tmp = 1.0d0
else if (x <= 2.8d+29) 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 <= -10000.0) {
tmp = 1.0;
} else if (x <= -1.56e-124) {
tmp = -1.0;
} else if (x <= -2.8e-137) {
tmp = 1.0;
} else if (x <= 2.8e+29) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -10000.0: tmp = 1.0 elif x <= -1.56e-124: tmp = -1.0 elif x <= -2.8e-137: tmp = 1.0 elif x <= 2.8e+29: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -10000.0) tmp = 1.0; elseif (x <= -1.56e-124) tmp = -1.0; elseif (x <= -2.8e-137) tmp = 1.0; elseif (x <= 2.8e+29) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -10000.0) tmp = 1.0; elseif (x <= -1.56e-124) tmp = -1.0; elseif (x <= -2.8e-137) tmp = 1.0; elseif (x <= 2.8e+29) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -10000.0], 1.0, If[LessEqual[x, -1.56e-124], -1.0, If[LessEqual[x, -2.8e-137], 1.0, If[LessEqual[x, 2.8e+29], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1.56 \cdot 10^{-124}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -2.8 \cdot 10^{-137}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{+29}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1e4 or -1.55999999999999993e-124 < x < -2.7999999999999999e-137 or 2.8e29 < x Initial program 100.0%
Taylor expanded in x around inf 82.3%
if -1e4 < x < -1.55999999999999993e-124 or -2.7999999999999999e-137 < x < 2.8e29Initial program 99.9%
Taylor expanded in x around 0 76.7%
(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-num100.0%
Applied egg-rr100.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 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 47.8%
(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 2024106
(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)))