
(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 9 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 (/ (+ 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 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%
(FPCore (f n)
:precision binary64
(if (or (<= f -5.5e+29)
(and (not (<= f 4.1e-88)) (or (<= f 7.8e-46) (not (<= f 70000.0)))))
(+ (* -2.0 (/ n f)) -1.0)
(+ 1.0 (/ (* f 2.0) n))))
double code(double f, double n) {
double tmp;
if ((f <= -5.5e+29) || (!(f <= 4.1e-88) && ((f <= 7.8e-46) || !(f <= 70000.0)))) {
tmp = (-2.0 * (n / f)) + -1.0;
} else {
tmp = 1.0 + ((f * 2.0) / n);
}
return tmp;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
real(8) :: tmp
if ((f <= (-5.5d+29)) .or. (.not. (f <= 4.1d-88)) .and. (f <= 7.8d-46) .or. (.not. (f <= 70000.0d0))) then
tmp = ((-2.0d0) * (n / f)) + (-1.0d0)
else
tmp = 1.0d0 + ((f * 2.0d0) / n)
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if ((f <= -5.5e+29) || (!(f <= 4.1e-88) && ((f <= 7.8e-46) || !(f <= 70000.0)))) {
tmp = (-2.0 * (n / f)) + -1.0;
} else {
tmp = 1.0 + ((f * 2.0) / n);
}
return tmp;
}
def code(f, n): tmp = 0 if (f <= -5.5e+29) or (not (f <= 4.1e-88) and ((f <= 7.8e-46) or not (f <= 70000.0))): tmp = (-2.0 * (n / f)) + -1.0 else: tmp = 1.0 + ((f * 2.0) / n) return tmp
function code(f, n) tmp = 0.0 if ((f <= -5.5e+29) || (!(f <= 4.1e-88) && ((f <= 7.8e-46) || !(f <= 70000.0)))) tmp = Float64(Float64(-2.0 * Float64(n / f)) + -1.0); else tmp = Float64(1.0 + Float64(Float64(f * 2.0) / n)); end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if ((f <= -5.5e+29) || (~((f <= 4.1e-88)) && ((f <= 7.8e-46) || ~((f <= 70000.0))))) tmp = (-2.0 * (n / f)) + -1.0; else tmp = 1.0 + ((f * 2.0) / n); end tmp_2 = tmp; end
code[f_, n_] := If[Or[LessEqual[f, -5.5e+29], And[N[Not[LessEqual[f, 4.1e-88]], $MachinePrecision], Or[LessEqual[f, 7.8e-46], N[Not[LessEqual[f, 70000.0]], $MachinePrecision]]]], N[(N[(-2.0 * N[(n / f), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 + N[(N[(f * 2.0), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -5.5 \cdot 10^{+29} \lor \neg \left(f \leq 4.1 \cdot 10^{-88}\right) \land \left(f \leq 7.8 \cdot 10^{-46} \lor \neg \left(f \leq 70000\right)\right):\\
\;\;\;\;-2 \cdot \frac{n}{f} + -1\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{f \cdot 2}{n}\\
\end{array}
\end{array}
if f < -5.5e29 or 4.1000000000000001e-88 < f < 7.8000000000000005e-46 or 7e4 < f Initial 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 n around 0 80.0%
if -5.5e29 < f < 4.1000000000000001e-88 or 7.8000000000000005e-46 < f < 7e4Initial 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 80.2%
associate-*r/80.2%
Simplified80.2%
Final simplification80.1%
(FPCore (f n)
:precision binary64
(let* ((t_0 (- -1.0 (/ n f))) (t_1 (+ 1.0 (/ (* f 2.0) n))))
(if (<= f -6.8e+23)
t_0
(if (<= f 4.2e-88)
t_1
(if (<= f 8e-46) (/ f (- n f)) (if (<= f 1150000.0) t_1 t_0))))))
double code(double f, double n) {
double t_0 = -1.0 - (n / f);
double t_1 = 1.0 + ((f * 2.0) / n);
double tmp;
if (f <= -6.8e+23) {
tmp = t_0;
} else if (f <= 4.2e-88) {
tmp = t_1;
} else if (f <= 8e-46) {
tmp = f / (n - f);
} else if (f <= 1150000.0) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = (-1.0d0) - (n / f)
t_1 = 1.0d0 + ((f * 2.0d0) / n)
if (f <= (-6.8d+23)) then
tmp = t_0
else if (f <= 4.2d-88) then
tmp = t_1
else if (f <= 8d-46) then
tmp = f / (n - f)
else if (f <= 1150000.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double f, double n) {
double t_0 = -1.0 - (n / f);
double t_1 = 1.0 + ((f * 2.0) / n);
double tmp;
if (f <= -6.8e+23) {
tmp = t_0;
} else if (f <= 4.2e-88) {
tmp = t_1;
} else if (f <= 8e-46) {
tmp = f / (n - f);
} else if (f <= 1150000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(f, n): t_0 = -1.0 - (n / f) t_1 = 1.0 + ((f * 2.0) / n) tmp = 0 if f <= -6.8e+23: tmp = t_0 elif f <= 4.2e-88: tmp = t_1 elif f <= 8e-46: tmp = f / (n - f) elif f <= 1150000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(f, n) t_0 = Float64(-1.0 - Float64(n / f)) t_1 = Float64(1.0 + Float64(Float64(f * 2.0) / n)) tmp = 0.0 if (f <= -6.8e+23) tmp = t_0; elseif (f <= 4.2e-88) tmp = t_1; elseif (f <= 8e-46) tmp = Float64(f / Float64(n - f)); elseif (f <= 1150000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(f, n) t_0 = -1.0 - (n / f); t_1 = 1.0 + ((f * 2.0) / n); tmp = 0.0; if (f <= -6.8e+23) tmp = t_0; elseif (f <= 4.2e-88) tmp = t_1; elseif (f <= 8e-46) tmp = f / (n - f); elseif (f <= 1150000.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[f_, n_] := Block[{t$95$0 = N[(-1.0 - N[(n / f), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(f * 2.0), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[f, -6.8e+23], t$95$0, If[LessEqual[f, 4.2e-88], t$95$1, If[LessEqual[f, 8e-46], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision], If[LessEqual[f, 1150000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 - \frac{n}{f}\\
t_1 := 1 + \frac{f \cdot 2}{n}\\
\mathbf{if}\;f \leq -6.8 \cdot 10^{+23}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;f \leq 4.2 \cdot 10^{-88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;f \leq 8 \cdot 10^{-46}:\\
\;\;\;\;\frac{f}{n - f}\\
\mathbf{elif}\;f \leq 1150000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if f < -6.79999999999999983e23 or 1.15e6 < f Initial 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 80.3%
Taylor expanded in f around inf 80.6%
sub-neg80.6%
metadata-eval80.6%
+-commutative80.6%
mul-1-neg80.6%
sub-neg80.6%
Simplified80.6%
if -6.79999999999999983e23 < f < 4.1999999999999999e-88 or 8.00000000000000018e-46 < f < 1.15e6Initial 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 80.2%
associate-*r/80.2%
Simplified80.2%
if 4.1999999999999999e-88 < f < 8.00000000000000018e-46Initial 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 71.2%
Final simplification79.8%
(FPCore (f n)
:precision binary64
(if (or (<= f -6e+27)
(and (not (<= f 4e-88)) (or (<= f 7.8e-46) (not (<= f 1550.0)))))
(- -1.0 (/ n f))
(+ 1.0 (/ f n))))
double code(double f, double n) {
double tmp;
if ((f <= -6e+27) || (!(f <= 4e-88) && ((f <= 7.8e-46) || !(f <= 1550.0)))) {
tmp = -1.0 - (n / f);
} else {
tmp = 1.0 + (f / n);
}
return tmp;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
real(8) :: tmp
if ((f <= (-6d+27)) .or. (.not. (f <= 4d-88)) .and. (f <= 7.8d-46) .or. (.not. (f <= 1550.0d0))) then
tmp = (-1.0d0) - (n / f)
else
tmp = 1.0d0 + (f / n)
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if ((f <= -6e+27) || (!(f <= 4e-88) && ((f <= 7.8e-46) || !(f <= 1550.0)))) {
tmp = -1.0 - (n / f);
} else {
tmp = 1.0 + (f / n);
}
return tmp;
}
def code(f, n): tmp = 0 if (f <= -6e+27) or (not (f <= 4e-88) and ((f <= 7.8e-46) or not (f <= 1550.0))): tmp = -1.0 - (n / f) else: tmp = 1.0 + (f / n) return tmp
function code(f, n) tmp = 0.0 if ((f <= -6e+27) || (!(f <= 4e-88) && ((f <= 7.8e-46) || !(f <= 1550.0)))) tmp = Float64(-1.0 - Float64(n / f)); else tmp = Float64(1.0 + Float64(f / n)); end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if ((f <= -6e+27) || (~((f <= 4e-88)) && ((f <= 7.8e-46) || ~((f <= 1550.0))))) tmp = -1.0 - (n / f); else tmp = 1.0 + (f / n); end tmp_2 = tmp; end
code[f_, n_] := If[Or[LessEqual[f, -6e+27], And[N[Not[LessEqual[f, 4e-88]], $MachinePrecision], Or[LessEqual[f, 7.8e-46], N[Not[LessEqual[f, 1550.0]], $MachinePrecision]]]], N[(-1.0 - N[(n / f), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(f / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -6 \cdot 10^{+27} \lor \neg \left(f \leq 4 \cdot 10^{-88}\right) \land \left(f \leq 7.8 \cdot 10^{-46} \lor \neg \left(f \leq 1550\right)\right):\\
\;\;\;\;-1 - \frac{n}{f}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{f}{n}\\
\end{array}
\end{array}
if f < -5.99999999999999953e27 or 3.99999999999999974e-88 < f < 7.8000000000000005e-46 or 1550 < f Initial 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 79.1%
Taylor expanded in f around inf 79.3%
sub-neg79.3%
metadata-eval79.3%
+-commutative79.3%
mul-1-neg79.3%
sub-neg79.3%
Simplified79.3%
if -5.99999999999999953e27 < f < 3.99999999999999974e-88 or 7.8000000000000005e-46 < f < 1550Initial 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 79.7%
Taylor expanded in n around inf 79.2%
+-commutative79.2%
Simplified79.2%
Final simplification79.3%
(FPCore (f n)
:precision binary64
(if (<= f -2.5e+31)
-1.0
(if (or (<= f 4.2e-88) (and (not (<= f 6.8e-46)) (<= f 280000.0)))
(+ 1.0 (/ f n))
-1.0)))
double code(double f, double n) {
double tmp;
if (f <= -2.5e+31) {
tmp = -1.0;
} else if ((f <= 4.2e-88) || (!(f <= 6.8e-46) && (f <= 280000.0))) {
tmp = 1.0 + (f / 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+31)) then
tmp = -1.0d0
else if ((f <= 4.2d-88) .or. (.not. (f <= 6.8d-46)) .and. (f <= 280000.0d0)) then
tmp = 1.0d0 + (f / 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+31) {
tmp = -1.0;
} else if ((f <= 4.2e-88) || (!(f <= 6.8e-46) && (f <= 280000.0))) {
tmp = 1.0 + (f / n);
} else {
tmp = -1.0;
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -2.5e+31: tmp = -1.0 elif (f <= 4.2e-88) or (not (f <= 6.8e-46) and (f <= 280000.0)): tmp = 1.0 + (f / n) else: tmp = -1.0 return tmp
function code(f, n) tmp = 0.0 if (f <= -2.5e+31) tmp = -1.0; elseif ((f <= 4.2e-88) || (!(f <= 6.8e-46) && (f <= 280000.0))) tmp = Float64(1.0 + Float64(f / n)); else tmp = -1.0; end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -2.5e+31) tmp = -1.0; elseif ((f <= 4.2e-88) || (~((f <= 6.8e-46)) && (f <= 280000.0))) tmp = 1.0 + (f / n); else tmp = -1.0; end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -2.5e+31], -1.0, If[Or[LessEqual[f, 4.2e-88], And[N[Not[LessEqual[f, 6.8e-46]], $MachinePrecision], LessEqual[f, 280000.0]]], N[(1.0 + N[(f / n), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -2.5 \cdot 10^{+31}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq 4.2 \cdot 10^{-88} \lor \neg \left(f \leq 6.8 \cdot 10^{-46}\right) \land f \leq 280000:\\
\;\;\;\;1 + \frac{f}{n}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if f < -2.50000000000000013e31 or 4.1999999999999999e-88 < f < 6.79999999999999992e-46 or 2.8e5 < f Initial 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.6%
if -2.50000000000000013e31 < f < 4.1999999999999999e-88 or 6.79999999999999992e-46 < f < 2.8e5Initial 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 79.7%
Taylor expanded in n around inf 79.2%
+-commutative79.2%
Simplified79.2%
Final simplification78.9%
(FPCore (f n)
:precision binary64
(let* ((t_0 (- -1.0 (/ n f))) (t_1 (/ n (- n f))))
(if (<= f -1.05e+31)
t_0
(if (<= f 6.6e-77)
t_1
(if (<= f 6.8e-46) (/ f (- n f)) (if (<= f 12000.0) t_1 t_0))))))
double code(double f, double n) {
double t_0 = -1.0 - (n / f);
double t_1 = n / (n - f);
double tmp;
if (f <= -1.05e+31) {
tmp = t_0;
} else if (f <= 6.6e-77) {
tmp = t_1;
} else if (f <= 6.8e-46) {
tmp = f / (n - f);
} else if (f <= 12000.0) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = (-1.0d0) - (n / f)
t_1 = n / (n - f)
if (f <= (-1.05d+31)) then
tmp = t_0
else if (f <= 6.6d-77) then
tmp = t_1
else if (f <= 6.8d-46) then
tmp = f / (n - f)
else if (f <= 12000.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double f, double n) {
double t_0 = -1.0 - (n / f);
double t_1 = n / (n - f);
double tmp;
if (f <= -1.05e+31) {
tmp = t_0;
} else if (f <= 6.6e-77) {
tmp = t_1;
} else if (f <= 6.8e-46) {
tmp = f / (n - f);
} else if (f <= 12000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(f, n): t_0 = -1.0 - (n / f) t_1 = n / (n - f) tmp = 0 if f <= -1.05e+31: tmp = t_0 elif f <= 6.6e-77: tmp = t_1 elif f <= 6.8e-46: tmp = f / (n - f) elif f <= 12000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(f, n) t_0 = Float64(-1.0 - Float64(n / f)) t_1 = Float64(n / Float64(n - f)) tmp = 0.0 if (f <= -1.05e+31) tmp = t_0; elseif (f <= 6.6e-77) tmp = t_1; elseif (f <= 6.8e-46) tmp = Float64(f / Float64(n - f)); elseif (f <= 12000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(f, n) t_0 = -1.0 - (n / f); t_1 = n / (n - f); tmp = 0.0; if (f <= -1.05e+31) tmp = t_0; elseif (f <= 6.6e-77) tmp = t_1; elseif (f <= 6.8e-46) tmp = f / (n - f); elseif (f <= 12000.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[f_, n_] := Block[{t$95$0 = N[(-1.0 - N[(n / f), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(n / N[(n - f), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[f, -1.05e+31], t$95$0, If[LessEqual[f, 6.6e-77], t$95$1, If[LessEqual[f, 6.8e-46], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision], If[LessEqual[f, 12000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 - \frac{n}{f}\\
t_1 := \frac{n}{n - f}\\
\mathbf{if}\;f \leq -1.05 \cdot 10^{+31}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;f \leq 6.6 \cdot 10^{-77}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;f \leq 6.8 \cdot 10^{-46}:\\
\;\;\;\;\frac{f}{n - f}\\
\mathbf{elif}\;f \leq 12000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if f < -1.04999999999999989e31 or 12000 < f Initial 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 80.3%
Taylor expanded in f around inf 80.6%
sub-neg80.6%
metadata-eval80.6%
+-commutative80.6%
mul-1-neg80.6%
sub-neg80.6%
Simplified80.6%
if -1.04999999999999989e31 < f < 6.59999999999999982e-77 or 6.79999999999999992e-46 < f < 12000Initial 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 78.9%
if 6.59999999999999982e-77 < f < 6.79999999999999992e-46Initial 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 77.8%
(FPCore (f n)
:precision binary64
(let* ((t_0 (- -1.0 (/ n f))) (t_1 (+ 1.0 (/ f n))))
(if (<= f -2.2e+27)
t_0
(if (<= f 4.2e-88)
t_1
(if (<= f 7.8e-46) (/ f (- n f)) (if (<= f 225000.0) t_1 t_0))))))
double code(double f, double n) {
double t_0 = -1.0 - (n / f);
double t_1 = 1.0 + (f / n);
double tmp;
if (f <= -2.2e+27) {
tmp = t_0;
} else if (f <= 4.2e-88) {
tmp = t_1;
} else if (f <= 7.8e-46) {
tmp = f / (n - f);
} else if (f <= 225000.0) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = (-1.0d0) - (n / f)
t_1 = 1.0d0 + (f / n)
if (f <= (-2.2d+27)) then
tmp = t_0
else if (f <= 4.2d-88) then
tmp = t_1
else if (f <= 7.8d-46) then
tmp = f / (n - f)
else if (f <= 225000.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double f, double n) {
double t_0 = -1.0 - (n / f);
double t_1 = 1.0 + (f / n);
double tmp;
if (f <= -2.2e+27) {
tmp = t_0;
} else if (f <= 4.2e-88) {
tmp = t_1;
} else if (f <= 7.8e-46) {
tmp = f / (n - f);
} else if (f <= 225000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(f, n): t_0 = -1.0 - (n / f) t_1 = 1.0 + (f / n) tmp = 0 if f <= -2.2e+27: tmp = t_0 elif f <= 4.2e-88: tmp = t_1 elif f <= 7.8e-46: tmp = f / (n - f) elif f <= 225000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(f, n) t_0 = Float64(-1.0 - Float64(n / f)) t_1 = Float64(1.0 + Float64(f / n)) tmp = 0.0 if (f <= -2.2e+27) tmp = t_0; elseif (f <= 4.2e-88) tmp = t_1; elseif (f <= 7.8e-46) tmp = Float64(f / Float64(n - f)); elseif (f <= 225000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(f, n) t_0 = -1.0 - (n / f); t_1 = 1.0 + (f / n); tmp = 0.0; if (f <= -2.2e+27) tmp = t_0; elseif (f <= 4.2e-88) tmp = t_1; elseif (f <= 7.8e-46) tmp = f / (n - f); elseif (f <= 225000.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[f_, n_] := Block[{t$95$0 = N[(-1.0 - N[(n / f), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(f / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[f, -2.2e+27], t$95$0, If[LessEqual[f, 4.2e-88], t$95$1, If[LessEqual[f, 7.8e-46], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision], If[LessEqual[f, 225000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 - \frac{n}{f}\\
t_1 := 1 + \frac{f}{n}\\
\mathbf{if}\;f \leq -2.2 \cdot 10^{+27}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;f \leq 4.2 \cdot 10^{-88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;f \leq 7.8 \cdot 10^{-46}:\\
\;\;\;\;\frac{f}{n - f}\\
\mathbf{elif}\;f \leq 225000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if f < -2.1999999999999999e27 or 225000 < f Initial 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 80.3%
Taylor expanded in f around inf 80.6%
sub-neg80.6%
metadata-eval80.6%
+-commutative80.6%
mul-1-neg80.6%
sub-neg80.6%
Simplified80.6%
if -2.1999999999999999e27 < f < 4.1999999999999999e-88 or 7.8000000000000005e-46 < f < 225000Initial 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 79.7%
Taylor expanded in n around inf 79.2%
+-commutative79.2%
Simplified79.2%
if 4.1999999999999999e-88 < f < 7.8000000000000005e-46Initial 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 71.2%
Final simplification79.3%
(FPCore (f n)
:precision binary64
(if (<= f -7e+24)
-1.0
(if (<= f 1e-88)
1.0
(if (<= f 6.8e-46) -1.0 (if (<= f 50000.0) 1.0 -1.0)))))
double code(double f, double n) {
double tmp;
if (f <= -7e+24) {
tmp = -1.0;
} else if (f <= 1e-88) {
tmp = 1.0;
} else if (f <= 6.8e-46) {
tmp = -1.0;
} else if (f <= 50000.0) {
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 <= (-7d+24)) then
tmp = -1.0d0
else if (f <= 1d-88) then
tmp = 1.0d0
else if (f <= 6.8d-46) then
tmp = -1.0d0
else if (f <= 50000.0d0) 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 <= -7e+24) {
tmp = -1.0;
} else if (f <= 1e-88) {
tmp = 1.0;
} else if (f <= 6.8e-46) {
tmp = -1.0;
} else if (f <= 50000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -7e+24: tmp = -1.0 elif f <= 1e-88: tmp = 1.0 elif f <= 6.8e-46: tmp = -1.0 elif f <= 50000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(f, n) tmp = 0.0 if (f <= -7e+24) tmp = -1.0; elseif (f <= 1e-88) tmp = 1.0; elseif (f <= 6.8e-46) tmp = -1.0; elseif (f <= 50000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -7e+24) tmp = -1.0; elseif (f <= 1e-88) tmp = 1.0; elseif (f <= 6.8e-46) tmp = -1.0; elseif (f <= 50000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -7e+24], -1.0, If[LessEqual[f, 1e-88], 1.0, If[LessEqual[f, 6.8e-46], -1.0, If[LessEqual[f, 50000.0], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -7 \cdot 10^{+24}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq 10^{-88}:\\
\;\;\;\;1\\
\mathbf{elif}\;f \leq 6.8 \cdot 10^{-46}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq 50000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if f < -7.0000000000000004e24 or 9.99999999999999934e-89 < f < 6.79999999999999992e-46 or 5e4 < f Initial 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.6%
if -7.0000000000000004e24 < f < 9.99999999999999934e-89 or 6.79999999999999992e-46 < f < 5e4Initial 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 78.8%
(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 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 47.8%
herbie shell --seed 2024111
(FPCore (f n)
:name "subtraction fraction"
:precision binary64
(/ (- (+ f n)) (- f n)))