
(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 (<= f -1.35e-21) (+ (* -2.0 (/ n f)) -1.0) (if (<= f 2.6e+63) (+ 1.0 (/ (* f 2.0) n)) (/ f (- n f)))))
double code(double f, double n) {
double tmp;
if (f <= -1.35e-21) {
tmp = (-2.0 * (n / f)) + -1.0;
} else if (f <= 2.6e+63) {
tmp = 1.0 + ((f * 2.0) / n);
} else {
tmp = f / (n - f);
}
return tmp;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
real(8) :: tmp
if (f <= (-1.35d-21)) then
tmp = ((-2.0d0) * (n / f)) + (-1.0d0)
else if (f <= 2.6d+63) then
tmp = 1.0d0 + ((f * 2.0d0) / n)
else
tmp = f / (n - f)
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if (f <= -1.35e-21) {
tmp = (-2.0 * (n / f)) + -1.0;
} else if (f <= 2.6e+63) {
tmp = 1.0 + ((f * 2.0) / n);
} else {
tmp = f / (n - f);
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -1.35e-21: tmp = (-2.0 * (n / f)) + -1.0 elif f <= 2.6e+63: tmp = 1.0 + ((f * 2.0) / n) else: tmp = f / (n - f) return tmp
function code(f, n) tmp = 0.0 if (f <= -1.35e-21) tmp = Float64(Float64(-2.0 * Float64(n / f)) + -1.0); elseif (f <= 2.6e+63) tmp = Float64(1.0 + Float64(Float64(f * 2.0) / n)); else tmp = Float64(f / Float64(n - f)); end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -1.35e-21) tmp = (-2.0 * (n / f)) + -1.0; elseif (f <= 2.6e+63) tmp = 1.0 + ((f * 2.0) / n); else tmp = f / (n - f); end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -1.35e-21], N[(N[(-2.0 * N[(n / f), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[f, 2.6e+63], N[(1.0 + N[(N[(f * 2.0), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -1.35 \cdot 10^{-21}:\\
\;\;\;\;-2 \cdot \frac{n}{f} + -1\\
\mathbf{elif}\;f \leq 2.6 \cdot 10^{+63}:\\
\;\;\;\;1 + \frac{f \cdot 2}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{f}{n - f}\\
\end{array}
\end{array}
if f < -1.3500000000000001e-21Initial 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 85.9%
if -1.3500000000000001e-21 < f < 2.6000000000000001e63Initial 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 83.2%
associate-*r/83.2%
Simplified83.2%
if 2.6000000000000001e63 < 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 90.7%
Final simplification85.4%
(FPCore (f n) :precision binary64 (if (<= f -1.25e-21) (/ (+ f n) (- f)) (if (<= f 6.6e+62) (+ 1.0 (/ (* f 2.0) n)) (/ f (- n f)))))
double code(double f, double n) {
double tmp;
if (f <= -1.25e-21) {
tmp = (f + n) / -f;
} else if (f <= 6.6e+62) {
tmp = 1.0 + ((f * 2.0) / n);
} else {
tmp = f / (n - f);
}
return tmp;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
real(8) :: tmp
if (f <= (-1.25d-21)) then
tmp = (f + n) / -f
else if (f <= 6.6d+62) then
tmp = 1.0d0 + ((f * 2.0d0) / n)
else
tmp = f / (n - f)
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if (f <= -1.25e-21) {
tmp = (f + n) / -f;
} else if (f <= 6.6e+62) {
tmp = 1.0 + ((f * 2.0) / n);
} else {
tmp = f / (n - f);
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -1.25e-21: tmp = (f + n) / -f elif f <= 6.6e+62: tmp = 1.0 + ((f * 2.0) / n) else: tmp = f / (n - f) return tmp
function code(f, n) tmp = 0.0 if (f <= -1.25e-21) tmp = Float64(Float64(f + n) / Float64(-f)); elseif (f <= 6.6e+62) tmp = Float64(1.0 + Float64(Float64(f * 2.0) / n)); else tmp = Float64(f / Float64(n - f)); end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -1.25e-21) tmp = (f + n) / -f; elseif (f <= 6.6e+62) tmp = 1.0 + ((f * 2.0) / n); else tmp = f / (n - f); end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -1.25e-21], N[(N[(f + n), $MachinePrecision] / (-f)), $MachinePrecision], If[LessEqual[f, 6.6e+62], N[(1.0 + N[(N[(f * 2.0), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -1.25 \cdot 10^{-21}:\\
\;\;\;\;\frac{f + n}{-f}\\
\mathbf{elif}\;f \leq 6.6 \cdot 10^{+62}:\\
\;\;\;\;1 + \frac{f \cdot 2}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{f}{n - f}\\
\end{array}
\end{array}
if f < -1.24999999999999993e-21Initial 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 85.3%
neg-mul-185.3%
Simplified85.3%
if -1.24999999999999993e-21 < f < 6.6e62Initial 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 83.2%
associate-*r/83.2%
Simplified83.2%
if 6.6e62 < 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 90.7%
Final simplification85.2%
(FPCore (f n) :precision binary64 (if (or (<= f -1.3e-21) (not (<= f 5.6e+69))) (/ f (- n f)) (/ n (- n f))))
double code(double f, double n) {
double tmp;
if ((f <= -1.3e-21) || !(f <= 5.6e+69)) {
tmp = f / (n - f);
} else {
tmp = n / (n - f);
}
return tmp;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
real(8) :: tmp
if ((f <= (-1.3d-21)) .or. (.not. (f <= 5.6d+69))) then
tmp = f / (n - f)
else
tmp = n / (n - f)
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if ((f <= -1.3e-21) || !(f <= 5.6e+69)) {
tmp = f / (n - f);
} else {
tmp = n / (n - f);
}
return tmp;
}
def code(f, n): tmp = 0 if (f <= -1.3e-21) or not (f <= 5.6e+69): tmp = f / (n - f) else: tmp = n / (n - f) return tmp
function code(f, n) tmp = 0.0 if ((f <= -1.3e-21) || !(f <= 5.6e+69)) tmp = Float64(f / Float64(n - f)); else tmp = Float64(n / Float64(n - f)); end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if ((f <= -1.3e-21) || ~((f <= 5.6e+69))) tmp = f / (n - f); else tmp = n / (n - f); end tmp_2 = tmp; end
code[f_, n_] := If[Or[LessEqual[f, -1.3e-21], N[Not[LessEqual[f, 5.6e+69]], $MachinePrecision]], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision], N[(n / N[(n - f), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -1.3 \cdot 10^{-21} \lor \neg \left(f \leq 5.6 \cdot 10^{+69}\right):\\
\;\;\;\;\frac{f}{n - f}\\
\mathbf{else}:\\
\;\;\;\;\frac{n}{n - f}\\
\end{array}
\end{array}
if f < -1.30000000000000009e-21 or 5.59999999999999964e69 < 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 88.2%
if -1.30000000000000009e-21 < f < 5.59999999999999964e69Initial 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 82.2%
Final simplification84.9%
(FPCore (f n) :precision binary64 (if (or (<= f -1e-21) (not (<= f 8.5e+62))) (/ f (- n f)) (+ 1.0 (/ f n))))
double code(double f, double n) {
double tmp;
if ((f <= -1e-21) || !(f <= 8.5e+62)) {
tmp = f / (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 <= (-1d-21)) .or. (.not. (f <= 8.5d+62))) then
tmp = f / (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 <= -1e-21) || !(f <= 8.5e+62)) {
tmp = f / (n - f);
} else {
tmp = 1.0 + (f / n);
}
return tmp;
}
def code(f, n): tmp = 0 if (f <= -1e-21) or not (f <= 8.5e+62): tmp = f / (n - f) else: tmp = 1.0 + (f / n) return tmp
function code(f, n) tmp = 0.0 if ((f <= -1e-21) || !(f <= 8.5e+62)) tmp = Float64(f / 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 <= -1e-21) || ~((f <= 8.5e+62))) tmp = f / (n - f); else tmp = 1.0 + (f / n); end tmp_2 = tmp; end
code[f_, n_] := If[Or[LessEqual[f, -1e-21], N[Not[LessEqual[f, 8.5e+62]], $MachinePrecision]], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(f / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -1 \cdot 10^{-21} \lor \neg \left(f \leq 8.5 \cdot 10^{+62}\right):\\
\;\;\;\;\frac{f}{n - f}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{f}{n}\\
\end{array}
\end{array}
if f < -9.99999999999999908e-22 or 8.4999999999999997e62 < 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 87.6%
if -9.99999999999999908e-22 < f < 8.4999999999999997e62Initial 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 82.7%
Taylor expanded in n around inf 82.5%
Final simplification84.8%
(FPCore (f n) :precision binary64 (if (<= f -1.1e-21) (/ (+ f n) (- f)) (if (<= f 9.2e+75) (/ n (- n f)) (/ f (- n f)))))
double code(double f, double n) {
double tmp;
if (f <= -1.1e-21) {
tmp = (f + n) / -f;
} else if (f <= 9.2e+75) {
tmp = n / (n - f);
} else {
tmp = f / (n - f);
}
return tmp;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
real(8) :: tmp
if (f <= (-1.1d-21)) then
tmp = (f + n) / -f
else if (f <= 9.2d+75) then
tmp = n / (n - f)
else
tmp = f / (n - f)
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if (f <= -1.1e-21) {
tmp = (f + n) / -f;
} else if (f <= 9.2e+75) {
tmp = n / (n - f);
} else {
tmp = f / (n - f);
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -1.1e-21: tmp = (f + n) / -f elif f <= 9.2e+75: tmp = n / (n - f) else: tmp = f / (n - f) return tmp
function code(f, n) tmp = 0.0 if (f <= -1.1e-21) tmp = Float64(Float64(f + n) / Float64(-f)); elseif (f <= 9.2e+75) tmp = Float64(n / Float64(n - f)); else tmp = Float64(f / Float64(n - f)); end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -1.1e-21) tmp = (f + n) / -f; elseif (f <= 9.2e+75) tmp = n / (n - f); else tmp = f / (n - f); end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -1.1e-21], N[(N[(f + n), $MachinePrecision] / (-f)), $MachinePrecision], If[LessEqual[f, 9.2e+75], N[(n / N[(n - f), $MachinePrecision]), $MachinePrecision], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -1.1 \cdot 10^{-21}:\\
\;\;\;\;\frac{f + n}{-f}\\
\mathbf{elif}\;f \leq 9.2 \cdot 10^{+75}:\\
\;\;\;\;\frac{n}{n - f}\\
\mathbf{else}:\\
\;\;\;\;\frac{f}{n - f}\\
\end{array}
\end{array}
if f < -1.1e-21Initial 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 85.3%
neg-mul-185.3%
Simplified85.3%
if -1.1e-21 < f < 9.1999999999999994e75Initial 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 82.2%
if 9.1999999999999994e75 < 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 92.3%
(FPCore (f n) :precision binary64 (if (<= f -1.4e-21) -1.0 (if (<= f 5.8e+63) (+ 1.0 (/ f n)) -1.0)))
double code(double f, double n) {
double tmp;
if (f <= -1.4e-21) {
tmp = -1.0;
} else if (f <= 5.8e+63) {
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 <= (-1.4d-21)) then
tmp = -1.0d0
else if (f <= 5.8d+63) 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 <= -1.4e-21) {
tmp = -1.0;
} else if (f <= 5.8e+63) {
tmp = 1.0 + (f / n);
} else {
tmp = -1.0;
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -1.4e-21: tmp = -1.0 elif f <= 5.8e+63: tmp = 1.0 + (f / n) else: tmp = -1.0 return tmp
function code(f, n) tmp = 0.0 if (f <= -1.4e-21) tmp = -1.0; elseif (f <= 5.8e+63) 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 <= -1.4e-21) tmp = -1.0; elseif (f <= 5.8e+63) tmp = 1.0 + (f / n); else tmp = -1.0; end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -1.4e-21], -1.0, If[LessEqual[f, 5.8e+63], N[(1.0 + N[(f / n), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -1.4 \cdot 10^{-21}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq 5.8 \cdot 10^{+63}:\\
\;\;\;\;1 + \frac{f}{n}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if f < -1.40000000000000002e-21 or 5.7999999999999999e63 < 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 87.2%
if -1.40000000000000002e-21 < f < 5.7999999999999999e63Initial 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 82.7%
Taylor expanded in n around inf 82.5%
(FPCore (f n) :precision binary64 (if (<= f -1e-21) -1.0 (if (<= f 5.5e+64) 1.0 -1.0)))
double code(double f, double n) {
double tmp;
if (f <= -1e-21) {
tmp = -1.0;
} else if (f <= 5.5e+64) {
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 <= (-1d-21)) then
tmp = -1.0d0
else if (f <= 5.5d+64) 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 <= -1e-21) {
tmp = -1.0;
} else if (f <= 5.5e+64) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -1e-21: tmp = -1.0 elif f <= 5.5e+64: tmp = 1.0 else: tmp = -1.0 return tmp
function code(f, n) tmp = 0.0 if (f <= -1e-21) tmp = -1.0; elseif (f <= 5.5e+64) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -1e-21) tmp = -1.0; elseif (f <= 5.5e+64) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -1e-21], -1.0, If[LessEqual[f, 5.5e+64], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -1 \cdot 10^{-21}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq 5.5 \cdot 10^{+64}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if f < -9.99999999999999908e-22 or 5.4999999999999996e64 < 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 87.2%
if -9.99999999999999908e-22 < f < 5.4999999999999996e64Initial 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 82.1%
(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 49.5%
herbie shell --seed 2024137
(FPCore (f n)
:name "subtraction fraction"
:precision binary64
(/ (- (+ f n)) (- f n)))