
(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 -7.5e-56) (/ f (- n f)) (if (<= f 4.6e+14) (+ 1.0 (/ (* f 2.0) n)) (+ (* -2.0 (/ n f)) -1.0))))
double code(double f, double n) {
double tmp;
if (f <= -7.5e-56) {
tmp = f / (n - f);
} else if (f <= 4.6e+14) {
tmp = 1.0 + ((f * 2.0) / n);
} else {
tmp = (-2.0 * (n / f)) + -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 <= (-7.5d-56)) then
tmp = f / (n - f)
else if (f <= 4.6d+14) then
tmp = 1.0d0 + ((f * 2.0d0) / n)
else
tmp = ((-2.0d0) * (n / f)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if (f <= -7.5e-56) {
tmp = f / (n - f);
} else if (f <= 4.6e+14) {
tmp = 1.0 + ((f * 2.0) / n);
} else {
tmp = (-2.0 * (n / f)) + -1.0;
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -7.5e-56: tmp = f / (n - f) elif f <= 4.6e+14: tmp = 1.0 + ((f * 2.0) / n) else: tmp = (-2.0 * (n / f)) + -1.0 return tmp
function code(f, n) tmp = 0.0 if (f <= -7.5e-56) tmp = Float64(f / Float64(n - f)); elseif (f <= 4.6e+14) tmp = Float64(1.0 + Float64(Float64(f * 2.0) / n)); else tmp = Float64(Float64(-2.0 * Float64(n / f)) + -1.0); end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -7.5e-56) tmp = f / (n - f); elseif (f <= 4.6e+14) tmp = 1.0 + ((f * 2.0) / n); else tmp = (-2.0 * (n / f)) + -1.0; end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -7.5e-56], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision], If[LessEqual[f, 4.6e+14], N[(1.0 + N[(N[(f * 2.0), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(n / f), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -7.5 \cdot 10^{-56}:\\
\;\;\;\;\frac{f}{n - f}\\
\mathbf{elif}\;f \leq 4.6 \cdot 10^{+14}:\\
\;\;\;\;1 + \frac{f \cdot 2}{n}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{n}{f} + -1\\
\end{array}
\end{array}
if f < -7.50000000000000041e-56Initial 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.7%
if -7.50000000000000041e-56 < f < 4.6e14Initial 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 80.5%
associate-*r/80.5%
Simplified80.5%
if 4.6e14 < 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 81.6%
Final simplification80.8%
(FPCore (f n) :precision binary64 (if (<= f -7.5e-56) (/ f (- n f)) (if (<= f 8.6e+14) (+ 1.0 (/ (* f 2.0) n)) (- -1.0 (/ n f)))))
double code(double f, double n) {
double tmp;
if (f <= -7.5e-56) {
tmp = f / (n - f);
} else if (f <= 8.6e+14) {
tmp = 1.0 + ((f * 2.0) / n);
} else {
tmp = -1.0 - (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 <= (-7.5d-56)) then
tmp = f / (n - f)
else if (f <= 8.6d+14) then
tmp = 1.0d0 + ((f * 2.0d0) / n)
else
tmp = (-1.0d0) - (n / f)
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if (f <= -7.5e-56) {
tmp = f / (n - f);
} else if (f <= 8.6e+14) {
tmp = 1.0 + ((f * 2.0) / n);
} else {
tmp = -1.0 - (n / f);
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -7.5e-56: tmp = f / (n - f) elif f <= 8.6e+14: tmp = 1.0 + ((f * 2.0) / n) else: tmp = -1.0 - (n / f) return tmp
function code(f, n) tmp = 0.0 if (f <= -7.5e-56) tmp = Float64(f / Float64(n - f)); elseif (f <= 8.6e+14) tmp = Float64(1.0 + Float64(Float64(f * 2.0) / n)); else tmp = Float64(-1.0 - Float64(n / f)); end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -7.5e-56) tmp = f / (n - f); elseif (f <= 8.6e+14) tmp = 1.0 + ((f * 2.0) / n); else tmp = -1.0 - (n / f); end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -7.5e-56], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision], If[LessEqual[f, 8.6e+14], N[(1.0 + N[(N[(f * 2.0), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(-1.0 - N[(n / f), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -7.5 \cdot 10^{-56}:\\
\;\;\;\;\frac{f}{n - f}\\
\mathbf{elif}\;f \leq 8.6 \cdot 10^{+14}:\\
\;\;\;\;1 + \frac{f \cdot 2}{n}\\
\mathbf{else}:\\
\;\;\;\;-1 - \frac{n}{f}\\
\end{array}
\end{array}
if f < -7.50000000000000041e-56Initial 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.7%
if -7.50000000000000041e-56 < f < 8.6e14Initial 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 80.5%
associate-*r/80.5%
Simplified80.5%
if 8.6e14 < 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 81.1%
Taylor expanded in f around inf 81.2%
neg-mul-181.2%
neg-sub081.2%
associate--r+81.2%
+-commutative81.2%
associate--r+81.2%
metadata-eval81.2%
Simplified81.2%
Final simplification80.7%
(FPCore (f n) :precision binary64 (if (or (<= f -2.05e-15) (not (<= f 1.35e+16))) (- -1.0 (/ n f)) (+ 1.0 (/ f n))))
double code(double f, double n) {
double tmp;
if ((f <= -2.05e-15) || !(f <= 1.35e+16)) {
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 <= (-2.05d-15)) .or. (.not. (f <= 1.35d+16))) 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 <= -2.05e-15) || !(f <= 1.35e+16)) {
tmp = -1.0 - (n / f);
} else {
tmp = 1.0 + (f / n);
}
return tmp;
}
def code(f, n): tmp = 0 if (f <= -2.05e-15) or not (f <= 1.35e+16): tmp = -1.0 - (n / f) else: tmp = 1.0 + (f / n) return tmp
function code(f, n) tmp = 0.0 if ((f <= -2.05e-15) || !(f <= 1.35e+16)) 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 <= -2.05e-15) || ~((f <= 1.35e+16))) tmp = -1.0 - (n / f); else tmp = 1.0 + (f / n); end tmp_2 = tmp; end
code[f_, n_] := If[Or[LessEqual[f, -2.05e-15], N[Not[LessEqual[f, 1.35e+16]], $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 -2.05 \cdot 10^{-15} \lor \neg \left(f \leq 1.35 \cdot 10^{+16}\right):\\
\;\;\;\;-1 - \frac{n}{f}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{f}{n}\\
\end{array}
\end{array}
if f < -2.05000000000000018e-15 or 1.35e16 < 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 82.5%
Taylor expanded in f around inf 82.2%
neg-mul-182.2%
neg-sub082.2%
associate--r+82.2%
+-commutative82.2%
associate--r+82.2%
metadata-eval82.2%
Simplified82.2%
if -2.05000000000000018e-15 < f < 1.35e16Initial 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 78.5%
Taylor expanded in n around inf 77.9%
+-commutative77.9%
Simplified77.9%
Final simplification80.2%
(FPCore (f n) :precision binary64 (if (<= f -1.55e-56) (/ f (- n f)) (if (<= f 2.1e+14) (/ n (- n f)) (- -1.0 (/ n f)))))
double code(double f, double n) {
double tmp;
if (f <= -1.55e-56) {
tmp = f / (n - f);
} else if (f <= 2.1e+14) {
tmp = n / (n - f);
} else {
tmp = -1.0 - (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.55d-56)) then
tmp = f / (n - f)
else if (f <= 2.1d+14) then
tmp = n / (n - f)
else
tmp = (-1.0d0) - (n / f)
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if (f <= -1.55e-56) {
tmp = f / (n - f);
} else if (f <= 2.1e+14) {
tmp = n / (n - f);
} else {
tmp = -1.0 - (n / f);
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -1.55e-56: tmp = f / (n - f) elif f <= 2.1e+14: tmp = n / (n - f) else: tmp = -1.0 - (n / f) return tmp
function code(f, n) tmp = 0.0 if (f <= -1.55e-56) tmp = Float64(f / Float64(n - f)); elseif (f <= 2.1e+14) tmp = Float64(n / Float64(n - f)); else tmp = Float64(-1.0 - Float64(n / f)); end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -1.55e-56) tmp = f / (n - f); elseif (f <= 2.1e+14) tmp = n / (n - f); else tmp = -1.0 - (n / f); end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -1.55e-56], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision], If[LessEqual[f, 2.1e+14], N[(n / N[(n - f), $MachinePrecision]), $MachinePrecision], N[(-1.0 - N[(n / f), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -1.55 \cdot 10^{-56}:\\
\;\;\;\;\frac{f}{n - f}\\
\mathbf{elif}\;f \leq 2.1 \cdot 10^{+14}:\\
\;\;\;\;\frac{n}{n - f}\\
\mathbf{else}:\\
\;\;\;\;-1 - \frac{n}{f}\\
\end{array}
\end{array}
if f < -1.54999999999999994e-56Initial 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.7%
if -1.54999999999999994e-56 < f < 2.1e14Initial 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 80.5%
if 2.1e14 < 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 81.1%
Taylor expanded in f around inf 81.2%
neg-mul-181.2%
neg-sub081.2%
associate--r+81.2%
+-commutative81.2%
associate--r+81.2%
metadata-eval81.2%
Simplified81.2%
(FPCore (f n) :precision binary64 (if (<= f -6.6e-56) (/ f (- n f)) (if (<= f 5.4e+14) (+ 1.0 (/ f n)) (- -1.0 (/ n f)))))
double code(double f, double n) {
double tmp;
if (f <= -6.6e-56) {
tmp = f / (n - f);
} else if (f <= 5.4e+14) {
tmp = 1.0 + (f / n);
} else {
tmp = -1.0 - (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 <= (-6.6d-56)) then
tmp = f / (n - f)
else if (f <= 5.4d+14) then
tmp = 1.0d0 + (f / n)
else
tmp = (-1.0d0) - (n / f)
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if (f <= -6.6e-56) {
tmp = f / (n - f);
} else if (f <= 5.4e+14) {
tmp = 1.0 + (f / n);
} else {
tmp = -1.0 - (n / f);
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -6.6e-56: tmp = f / (n - f) elif f <= 5.4e+14: tmp = 1.0 + (f / n) else: tmp = -1.0 - (n / f) return tmp
function code(f, n) tmp = 0.0 if (f <= -6.6e-56) tmp = Float64(f / Float64(n - f)); elseif (f <= 5.4e+14) tmp = Float64(1.0 + Float64(f / n)); else tmp = Float64(-1.0 - Float64(n / f)); end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -6.6e-56) tmp = f / (n - f); elseif (f <= 5.4e+14) tmp = 1.0 + (f / n); else tmp = -1.0 - (n / f); end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -6.6e-56], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision], If[LessEqual[f, 5.4e+14], N[(1.0 + N[(f / n), $MachinePrecision]), $MachinePrecision], N[(-1.0 - N[(n / f), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -6.6 \cdot 10^{-56}:\\
\;\;\;\;\frac{f}{n - f}\\
\mathbf{elif}\;f \leq 5.4 \cdot 10^{+14}:\\
\;\;\;\;1 + \frac{f}{n}\\
\mathbf{else}:\\
\;\;\;\;-1 - \frac{n}{f}\\
\end{array}
\end{array}
if f < -6.59999999999999967e-56Initial 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.7%
if -6.59999999999999967e-56 < f < 5.4e14Initial 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 80.5%
Taylor expanded in n around inf 79.9%
+-commutative79.9%
Simplified79.9%
if 5.4e14 < 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 81.1%
Taylor expanded in f around inf 81.2%
neg-mul-181.2%
neg-sub081.2%
associate--r+81.2%
+-commutative81.2%
associate--r+81.2%
metadata-eval81.2%
Simplified81.2%
Final simplification80.4%
(FPCore (f n) :precision binary64 (if (<= f -1.12e-29) -1.0 (if (<= f 2e+14) (+ 1.0 (/ f n)) -1.0)))
double code(double f, double n) {
double tmp;
if (f <= -1.12e-29) {
tmp = -1.0;
} else if (f <= 2e+14) {
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.12d-29)) then
tmp = -1.0d0
else if (f <= 2d+14) 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.12e-29) {
tmp = -1.0;
} else if (f <= 2e+14) {
tmp = 1.0 + (f / n);
} else {
tmp = -1.0;
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -1.12e-29: tmp = -1.0 elif f <= 2e+14: tmp = 1.0 + (f / n) else: tmp = -1.0 return tmp
function code(f, n) tmp = 0.0 if (f <= -1.12e-29) tmp = -1.0; elseif (f <= 2e+14) 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.12e-29) tmp = -1.0; elseif (f <= 2e+14) tmp = 1.0 + (f / n); else tmp = -1.0; end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -1.12e-29], -1.0, If[LessEqual[f, 2e+14], N[(1.0 + N[(f / n), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -1.12 \cdot 10^{-29}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq 2 \cdot 10^{+14}:\\
\;\;\;\;1 + \frac{f}{n}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if f < -1.11999999999999995e-29 or 2e14 < 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 81.4%
if -1.11999999999999995e-29 < f < 2e14Initial 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 78.9%
Taylor expanded in n around inf 78.3%
+-commutative78.3%
Simplified78.3%
Final simplification80.1%
(FPCore (f n) :precision binary64 (if (<= f -2.9e-15) -1.0 (if (<= f 1.95e+14) 1.0 -1.0)))
double code(double f, double n) {
double tmp;
if (f <= -2.9e-15) {
tmp = -1.0;
} else if (f <= 1.95e+14) {
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 <= (-2.9d-15)) then
tmp = -1.0d0
else if (f <= 1.95d+14) 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 <= -2.9e-15) {
tmp = -1.0;
} else if (f <= 1.95e+14) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -2.9e-15: tmp = -1.0 elif f <= 1.95e+14: tmp = 1.0 else: tmp = -1.0 return tmp
function code(f, n) tmp = 0.0 if (f <= -2.9e-15) tmp = -1.0; elseif (f <= 1.95e+14) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -2.9e-15) tmp = -1.0; elseif (f <= 1.95e+14) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -2.9e-15], -1.0, If[LessEqual[f, 1.95e+14], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -2.9 \cdot 10^{-15}:\\
\;\;\;\;-1\\
\mathbf{elif}\;f \leq 1.95 \cdot 10^{+14}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if f < -2.90000000000000019e-15 or 1.95e14 < 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 81.9%
if -2.90000000000000019e-15 < f < 1.95e14Initial 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 77.7%
(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 54.9%
herbie shell --seed 2024139
(FPCore (f n)
:name "subtraction fraction"
:precision binary64
(/ (- (+ f n)) (- f n)))