
(FPCore (f n) :precision binary64 (/ (- (+ f n)) (- f n)))
double code(double f, double n) {
return -(f + n) / (f - n);
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
code = -(f + n) / (f - n)
end function
public static double code(double f, double n) {
return -(f + n) / (f - n);
}
def code(f, n): return -(f + n) / (f - n)
function code(f, n) return Float64(Float64(-Float64(f + n)) / Float64(f - n)) end
function tmp = code(f, n) tmp = -(f + n) / (f - n); end
code[f_, n_] := N[((-N[(f + n), $MachinePrecision]) / N[(f - n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-\left(f + n\right)}{f - n}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (f n) :precision binary64 (/ (- (+ f n)) (- f n)))
double code(double f, double n) {
return -(f + n) / (f - n);
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
code = -(f + n) / (f - n)
end function
public static double code(double f, double n) {
return -(f + n) / (f - n);
}
def code(f, n): return -(f + n) / (f - n)
function code(f, n) return Float64(Float64(-Float64(f + n)) / Float64(f - n)) end
function tmp = code(f, n) tmp = -(f + n) / (f - n); end
code[f_, n_] := N[((-N[(f + n), $MachinePrecision]) / N[(f - n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-\left(f + n\right)}{f - n}
\end{array}
(FPCore (f n) :precision binary64 (log1p (expm1 (/ (+ f n) (- n f)))))
double code(double f, double n) {
return log1p(expm1(((f + n) / (n - f))));
}
public static double code(double f, double n) {
return Math.log1p(Math.expm1(((f + n) / (n - f))));
}
def code(f, n): return math.log1p(math.expm1(((f + n) / (n - f))))
function code(f, n) return log1p(expm1(Float64(Float64(f + n) / Float64(n - f)))) end
code[f_, n_] := N[Log[1 + N[(Exp[N[(N[(f + n), $MachinePrecision] / N[(n - f), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{f + n}{n - f}\right)\right)
\end{array}
Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
log1p-expm1-u99.9%
Applied egg-rr99.9%
(FPCore (f n)
:precision binary64
(let* ((t_0 (+ (* -2.0 (/ n f)) -1.0)))
(if (<= f -7.2e+55)
t_0
(if (<= f -1.2e+39)
1.0
(if (<= f -1.65e-18)
-1.0
(if (<= f 3.3e+71) (+ 1.0 (* 2.0 (/ f n))) t_0))))))
double code(double f, double n) {
double t_0 = (-2.0 * (n / f)) + -1.0;
double tmp;
if (f <= -7.2e+55) {
tmp = t_0;
} else if (f <= -1.2e+39) {
tmp = 1.0;
} else if (f <= -1.65e-18) {
tmp = -1.0;
} else if (f <= 3.3e+71) {
tmp = 1.0 + (2.0 * (f / n));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = ((-2.0d0) * (n / f)) + (-1.0d0)
if (f <= (-7.2d+55)) then
tmp = t_0
else if (f <= (-1.2d+39)) then
tmp = 1.0d0
else if (f <= (-1.65d-18)) then
tmp = -1.0d0
else if (f <= 3.3d+71) then
tmp = 1.0d0 + (2.0d0 * (f / n))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double f, double n) {
double t_0 = (-2.0 * (n / f)) + -1.0;
double tmp;
if (f <= -7.2e+55) {
tmp = t_0;
} else if (f <= -1.2e+39) {
tmp = 1.0;
} else if (f <= -1.65e-18) {
tmp = -1.0;
} else if (f <= 3.3e+71) {
tmp = 1.0 + (2.0 * (f / n));
} else {
tmp = t_0;
}
return tmp;
}
def code(f, n): t_0 = (-2.0 * (n / f)) + -1.0 tmp = 0 if f <= -7.2e+55: tmp = t_0 elif f <= -1.2e+39: tmp = 1.0 elif f <= -1.65e-18: tmp = -1.0 elif f <= 3.3e+71: tmp = 1.0 + (2.0 * (f / n)) else: tmp = t_0 return tmp
function code(f, n) t_0 = Float64(Float64(-2.0 * Float64(n / f)) + -1.0) tmp = 0.0 if (f <= -7.2e+55) tmp = t_0; elseif (f <= -1.2e+39) tmp = 1.0; elseif (f <= -1.65e-18) tmp = -1.0; elseif (f <= 3.3e+71) tmp = Float64(1.0 + Float64(2.0 * Float64(f / n))); else tmp = t_0; end return tmp end
function tmp_2 = code(f, n) t_0 = (-2.0 * (n / f)) + -1.0; tmp = 0.0; if (f <= -7.2e+55) tmp = t_0; elseif (f <= -1.2e+39) tmp = 1.0; elseif (f <= -1.65e-18) tmp = -1.0; elseif (f <= 3.3e+71) tmp = 1.0 + (2.0 * (f / n)); else tmp = t_0; end tmp_2 = tmp; end
code[f_, n_] := Block[{t$95$0 = N[(N[(-2.0 * N[(n / f), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[f, -7.2e+55], t$95$0, If[LessEqual[f, -1.2e+39], 1.0, If[LessEqual[f, -1.65e-18], -1.0, If[LessEqual[f, 3.3e+71], N[(1.0 + N[(2.0 * N[(f / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -2 \cdot \frac{n}{f} + -1\\
\mathbf{if}\;f \leq -7.2 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;f \leq -1.2 \cdot 10^{+39}:\\
\;\;\;\;1\\
\mathbf{elif}\;f \leq -1.65 \cdot 10^{-18}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq 3.3 \cdot 10^{+71}:\\
\;\;\;\;1 + 2 \cdot \frac{f}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if f < -7.19999999999999975e55 or 3.2999999999999998e71 < f Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in n around 0 85.6%
if -7.19999999999999975e55 < f < -1.2e39Initial program 100.0%
distribute-frac-neg100.0%
distribute-neg-frac2100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in f around 0 100.0%
if -1.2e39 < f < -1.6500000000000001e-18Initial program 100.0%
distribute-frac-neg100.0%
distribute-neg-frac2100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in f around inf 78.1%
if -1.6500000000000001e-18 < f < 3.2999999999999998e71Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in f around 0 75.4%
Final simplification80.0%
(FPCore (f n)
:precision binary64
(let* ((t_0 (/ (+ f n) (- f))))
(if (<= f -1.02e+55)
t_0
(if (<= f -1.15e+41)
1.0
(if (<= f -1.5e-18)
-1.0
(if (<= f 4.1e+71) (+ 1.0 (* 2.0 (/ f n))) t_0))))))
double code(double f, double n) {
double t_0 = (f + n) / -f;
double tmp;
if (f <= -1.02e+55) {
tmp = t_0;
} else if (f <= -1.15e+41) {
tmp = 1.0;
} else if (f <= -1.5e-18) {
tmp = -1.0;
} else if (f <= 4.1e+71) {
tmp = 1.0 + (2.0 * (f / n));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (f + n) / -f
if (f <= (-1.02d+55)) then
tmp = t_0
else if (f <= (-1.15d+41)) then
tmp = 1.0d0
else if (f <= (-1.5d-18)) then
tmp = -1.0d0
else if (f <= 4.1d+71) then
tmp = 1.0d0 + (2.0d0 * (f / n))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double f, double n) {
double t_0 = (f + n) / -f;
double tmp;
if (f <= -1.02e+55) {
tmp = t_0;
} else if (f <= -1.15e+41) {
tmp = 1.0;
} else if (f <= -1.5e-18) {
tmp = -1.0;
} else if (f <= 4.1e+71) {
tmp = 1.0 + (2.0 * (f / n));
} else {
tmp = t_0;
}
return tmp;
}
def code(f, n): t_0 = (f + n) / -f tmp = 0 if f <= -1.02e+55: tmp = t_0 elif f <= -1.15e+41: tmp = 1.0 elif f <= -1.5e-18: tmp = -1.0 elif f <= 4.1e+71: tmp = 1.0 + (2.0 * (f / n)) else: tmp = t_0 return tmp
function code(f, n) t_0 = Float64(Float64(f + n) / Float64(-f)) tmp = 0.0 if (f <= -1.02e+55) tmp = t_0; elseif (f <= -1.15e+41) tmp = 1.0; elseif (f <= -1.5e-18) tmp = -1.0; elseif (f <= 4.1e+71) tmp = Float64(1.0 + Float64(2.0 * Float64(f / n))); else tmp = t_0; end return tmp end
function tmp_2 = code(f, n) t_0 = (f + n) / -f; tmp = 0.0; if (f <= -1.02e+55) tmp = t_0; elseif (f <= -1.15e+41) tmp = 1.0; elseif (f <= -1.5e-18) tmp = -1.0; elseif (f <= 4.1e+71) tmp = 1.0 + (2.0 * (f / n)); else tmp = t_0; end tmp_2 = tmp; end
code[f_, n_] := Block[{t$95$0 = N[(N[(f + n), $MachinePrecision] / (-f)), $MachinePrecision]}, If[LessEqual[f, -1.02e+55], t$95$0, If[LessEqual[f, -1.15e+41], 1.0, If[LessEqual[f, -1.5e-18], -1.0, If[LessEqual[f, 4.1e+71], N[(1.0 + N[(2.0 * N[(f / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{f + n}{-f}\\
\mathbf{if}\;f \leq -1.02 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;f \leq -1.15 \cdot 10^{+41}:\\
\;\;\;\;1\\
\mathbf{elif}\;f \leq -1.5 \cdot 10^{-18}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq 4.1 \cdot 10^{+71}:\\
\;\;\;\;1 + 2 \cdot \frac{f}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if f < -1.02000000000000002e55 or 4.1000000000000002e71 < f Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt43.6%
times-frac43.5%
Applied egg-rr43.5%
associate-*l/43.6%
*-lft-identity43.6%
associate-/l/43.6%
Simplified43.6%
Taylor expanded in n around 0 84.7%
neg-mul-184.7%
Simplified84.7%
if -1.02000000000000002e55 < f < -1.1499999999999999e41Initial program 100.0%
distribute-frac-neg100.0%
distribute-neg-frac2100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in f around 0 100.0%
if -1.1499999999999999e41 < f < -1.49999999999999991e-18Initial program 100.0%
distribute-frac-neg100.0%
distribute-neg-frac2100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in f around inf 78.1%
if -1.49999999999999991e-18 < f < 4.1000000000000002e71Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in f around 0 75.4%
(FPCore (f n)
:precision binary64
(let* ((t_0 (/ (+ f n) (- f))))
(if (<= f -1.12e+55)
t_0
(if (<= f -1e+43)
1.0
(if (<= f -2.5e-18) -1.0 (if (<= f 8e+71) (/ (+ f n) n) t_0))))))
double code(double f, double n) {
double t_0 = (f + n) / -f;
double tmp;
if (f <= -1.12e+55) {
tmp = t_0;
} else if (f <= -1e+43) {
tmp = 1.0;
} else if (f <= -2.5e-18) {
tmp = -1.0;
} else if (f <= 8e+71) {
tmp = (f + n) / n;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (f + n) / -f
if (f <= (-1.12d+55)) then
tmp = t_0
else if (f <= (-1d+43)) then
tmp = 1.0d0
else if (f <= (-2.5d-18)) then
tmp = -1.0d0
else if (f <= 8d+71) then
tmp = (f + n) / n
else
tmp = t_0
end if
code = tmp
end function
public static double code(double f, double n) {
double t_0 = (f + n) / -f;
double tmp;
if (f <= -1.12e+55) {
tmp = t_0;
} else if (f <= -1e+43) {
tmp = 1.0;
} else if (f <= -2.5e-18) {
tmp = -1.0;
} else if (f <= 8e+71) {
tmp = (f + n) / n;
} else {
tmp = t_0;
}
return tmp;
}
def code(f, n): t_0 = (f + n) / -f tmp = 0 if f <= -1.12e+55: tmp = t_0 elif f <= -1e+43: tmp = 1.0 elif f <= -2.5e-18: tmp = -1.0 elif f <= 8e+71: tmp = (f + n) / n else: tmp = t_0 return tmp
function code(f, n) t_0 = Float64(Float64(f + n) / Float64(-f)) tmp = 0.0 if (f <= -1.12e+55) tmp = t_0; elseif (f <= -1e+43) tmp = 1.0; elseif (f <= -2.5e-18) tmp = -1.0; elseif (f <= 8e+71) tmp = Float64(Float64(f + n) / n); else tmp = t_0; end return tmp end
function tmp_2 = code(f, n) t_0 = (f + n) / -f; tmp = 0.0; if (f <= -1.12e+55) tmp = t_0; elseif (f <= -1e+43) tmp = 1.0; elseif (f <= -2.5e-18) tmp = -1.0; elseif (f <= 8e+71) tmp = (f + n) / n; else tmp = t_0; end tmp_2 = tmp; end
code[f_, n_] := Block[{t$95$0 = N[(N[(f + n), $MachinePrecision] / (-f)), $MachinePrecision]}, If[LessEqual[f, -1.12e+55], t$95$0, If[LessEqual[f, -1e+43], 1.0, If[LessEqual[f, -2.5e-18], -1.0, If[LessEqual[f, 8e+71], N[(N[(f + n), $MachinePrecision] / n), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{f + n}{-f}\\
\mathbf{if}\;f \leq -1.12 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;f \leq -1 \cdot 10^{+43}:\\
\;\;\;\;1\\
\mathbf{elif}\;f \leq -2.5 \cdot 10^{-18}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq 8 \cdot 10^{+71}:\\
\;\;\;\;\frac{f + n}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if f < -1.12000000000000006e55 or 8.0000000000000003e71 < f Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt43.6%
times-frac43.5%
Applied egg-rr43.5%
associate-*l/43.6%
*-lft-identity43.6%
associate-/l/43.6%
Simplified43.6%
Taylor expanded in n around 0 84.7%
neg-mul-184.7%
Simplified84.7%
if -1.12000000000000006e55 < f < -1.00000000000000001e43Initial program 100.0%
distribute-frac-neg100.0%
distribute-neg-frac2100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in f around 0 100.0%
if -1.00000000000000001e43 < f < -2.50000000000000018e-18Initial program 100.0%
distribute-frac-neg100.0%
distribute-neg-frac2100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in f around inf 78.1%
if -2.50000000000000018e-18 < f < 8.0000000000000003e71Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt43.3%
times-frac43.2%
Applied egg-rr43.2%
associate-*l/43.3%
*-lft-identity43.3%
associate-/l/43.3%
Simplified43.3%
Taylor expanded in n around inf 75.1%
(FPCore (f n)
:precision binary64
(if (<= f -2.5e+55)
-1.0
(if (<= f -9.2e+42)
1.0
(if (<= f -2.45e-18) -1.0 (if (<= f 6.5e+71) (/ (+ f n) n) -1.0)))))
double code(double f, double n) {
double tmp;
if (f <= -2.5e+55) {
tmp = -1.0;
} else if (f <= -9.2e+42) {
tmp = 1.0;
} else if (f <= -2.45e-18) {
tmp = -1.0;
} else if (f <= 6.5e+71) {
tmp = (f + n) / n;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
real(8) :: tmp
if (f <= (-2.5d+55)) then
tmp = -1.0d0
else if (f <= (-9.2d+42)) then
tmp = 1.0d0
else if (f <= (-2.45d-18)) then
tmp = -1.0d0
else if (f <= 6.5d+71) then
tmp = (f + n) / n
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if (f <= -2.5e+55) {
tmp = -1.0;
} else if (f <= -9.2e+42) {
tmp = 1.0;
} else if (f <= -2.45e-18) {
tmp = -1.0;
} else if (f <= 6.5e+71) {
tmp = (f + n) / n;
} else {
tmp = -1.0;
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -2.5e+55: tmp = -1.0 elif f <= -9.2e+42: tmp = 1.0 elif f <= -2.45e-18: tmp = -1.0 elif f <= 6.5e+71: tmp = (f + n) / n else: tmp = -1.0 return tmp
function code(f, n) tmp = 0.0 if (f <= -2.5e+55) tmp = -1.0; elseif (f <= -9.2e+42) tmp = 1.0; elseif (f <= -2.45e-18) tmp = -1.0; elseif (f <= 6.5e+71) tmp = Float64(Float64(f + n) / n); else tmp = -1.0; end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -2.5e+55) tmp = -1.0; elseif (f <= -9.2e+42) tmp = 1.0; elseif (f <= -2.45e-18) tmp = -1.0; elseif (f <= 6.5e+71) tmp = (f + n) / n; else tmp = -1.0; end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -2.5e+55], -1.0, If[LessEqual[f, -9.2e+42], 1.0, If[LessEqual[f, -2.45e-18], -1.0, If[LessEqual[f, 6.5e+71], N[(N[(f + n), $MachinePrecision] / n), $MachinePrecision], -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -2.5 \cdot 10^{+55}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq -9.2 \cdot 10^{+42}:\\
\;\;\;\;1\\
\mathbf{elif}\;f \leq -2.45 \cdot 10^{-18}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq 6.5 \cdot 10^{+71}:\\
\;\;\;\;\frac{f + n}{n}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if f < -2.50000000000000023e55 or -9.2e42 < f < -2.4500000000000001e-18 or 6.49999999999999954e71 < f Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in f around inf 83.8%
if -2.50000000000000023e55 < f < -9.2e42Initial program 100.0%
distribute-frac-neg100.0%
distribute-neg-frac2100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in f around 0 100.0%
if -2.4500000000000001e-18 < f < 6.49999999999999954e71Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt43.3%
times-frac43.2%
Applied egg-rr43.2%
associate-*l/43.3%
*-lft-identity43.3%
associate-/l/43.3%
Simplified43.3%
Taylor expanded in n around inf 75.1%
(FPCore (f n)
:precision binary64
(if (<= f -1.02e+55)
-1.0
(if (<= f -1e+43)
1.0
(if (<= f -2.75e-18) -1.0 (if (<= f 5e+67) 1.0 -1.0)))))
double code(double f, double n) {
double tmp;
if (f <= -1.02e+55) {
tmp = -1.0;
} else if (f <= -1e+43) {
tmp = 1.0;
} else if (f <= -2.75e-18) {
tmp = -1.0;
} else if (f <= 5e+67) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
real(8) :: tmp
if (f <= (-1.02d+55)) then
tmp = -1.0d0
else if (f <= (-1d+43)) then
tmp = 1.0d0
else if (f <= (-2.75d-18)) then
tmp = -1.0d0
else if (f <= 5d+67) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if (f <= -1.02e+55) {
tmp = -1.0;
} else if (f <= -1e+43) {
tmp = 1.0;
} else if (f <= -2.75e-18) {
tmp = -1.0;
} else if (f <= 5e+67) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -1.02e+55: tmp = -1.0 elif f <= -1e+43: tmp = 1.0 elif f <= -2.75e-18: tmp = -1.0 elif f <= 5e+67: tmp = 1.0 else: tmp = -1.0 return tmp
function code(f, n) tmp = 0.0 if (f <= -1.02e+55) tmp = -1.0; elseif (f <= -1e+43) tmp = 1.0; elseif (f <= -2.75e-18) tmp = -1.0; elseif (f <= 5e+67) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -1.02e+55) tmp = -1.0; elseif (f <= -1e+43) tmp = 1.0; elseif (f <= -2.75e-18) tmp = -1.0; elseif (f <= 5e+67) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -1.02e+55], -1.0, If[LessEqual[f, -1e+43], 1.0, If[LessEqual[f, -2.75e-18], -1.0, If[LessEqual[f, 5e+67], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -1.02 \cdot 10^{+55}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq -1 \cdot 10^{+43}:\\
\;\;\;\;1\\
\mathbf{elif}\;f \leq -2.75 \cdot 10^{-18}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq 5 \cdot 10^{+67}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if f < -1.02000000000000002e55 or -1.00000000000000001e43 < f < -2.75e-18 or 4.99999999999999976e67 < f Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in f around inf 83.2%
if -1.02000000000000002e55 < f < -1.00000000000000001e43 or -2.75e-18 < f < 4.99999999999999976e67Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in f around 0 75.4%
(FPCore (f n) :precision binary64 (/ (+ f n) (- n f)))
double code(double f, double n) {
return (f + n) / (n - f);
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
code = (f + n) / (n - f)
end function
public static double code(double f, double n) {
return (f + n) / (n - f);
}
def code(f, n): return (f + n) / (n - f)
function code(f, n) return Float64(Float64(f + n) / Float64(n - f)) end
function tmp = code(f, n) tmp = (f + n) / (n - f); end
code[f_, n_] := N[(N[(f + n), $MachinePrecision] / N[(n - f), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{f + n}{n - f}
\end{array}
Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
(FPCore (f n) :precision binary64 -1.0)
double code(double f, double n) {
return -1.0;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
code = -1.0d0
end function
public static double code(double f, double n) {
return -1.0;
}
def code(f, n): return -1.0
function code(f, n) return -1.0 end
function tmp = code(f, n) tmp = -1.0; end
code[f_, n_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 99.9%
distribute-frac-neg99.9%
distribute-neg-frac299.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in f around inf 49.0%
herbie shell --seed 2024096
(FPCore (f n)
:name "subtraction fraction"
:precision binary64
(/ (- (+ f n)) (- f n)))