
(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-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
(FPCore (f n) :precision binary64 (if (<= f -7.5e-56) (/ f (- n f)) (if (<= f 4.6e+14) (+ 1.0 (* 2.0 (/ f n))) (+ -1.0 (/ (* n -2.0) f)))))
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 + (2.0 * (f / n));
} else {
tmp = -1.0 + ((n * -2.0) / 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 <= 4.6d+14) then
tmp = 1.0d0 + (2.0d0 * (f / n))
else
tmp = (-1.0d0) + ((n * (-2.0d0)) / 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 <= 4.6e+14) {
tmp = 1.0 + (2.0 * (f / n));
} else {
tmp = -1.0 + ((n * -2.0) / f);
}
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 + (2.0 * (f / n)) else: tmp = -1.0 + ((n * -2.0) / f) 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(2.0 * Float64(f / n))); else tmp = Float64(-1.0 + Float64(Float64(n * -2.0) / 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 <= 4.6e+14) tmp = 1.0 + (2.0 * (f / n)); else tmp = -1.0 + ((n * -2.0) / 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, 4.6e+14], N[(1.0 + N[(2.0 * N[(f / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(n * -2.0), $MachinePrecision] / 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 4.6 \cdot 10^{+14}:\\
\;\;\;\;1 + 2 \cdot \frac{f}{n}\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{n \cdot -2}{f}\\
\end{array}
\end{array}
if f < -7.50000000000000041e-56Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around inf
Simplified80.7%
if -7.50000000000000041e-56 < f < 4.6e14Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around 0
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
+-lowering-+.f64N/A
associate-*l*N/A
associate-*l/N/A
*-lft-identityN/A
*-lowering-*.f64N/A
/-lowering-/.f6480.5%
Simplified80.5%
if 4.6e14 < f Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around inf
+-commutativeN/A
associate--r+N/A
associate-*r/N/A
div-subN/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lft-identityN/A
distribute-rgt-out--N/A
metadata-evalN/A
*-lowering-*.f6481.6%
Simplified81.6%
(FPCore (f n) :precision binary64 (if (<= f -3.7e-56) (/ f (- n f)) (if (<= f 2.3e+14) (/ n (- n f)) (+ -1.0 (/ (* n -2.0) f)))))
double code(double f, double n) {
double tmp;
if (f <= -3.7e-56) {
tmp = f / (n - f);
} else if (f <= 2.3e+14) {
tmp = n / (n - f);
} else {
tmp = -1.0 + ((n * -2.0) / f);
}
return tmp;
}
real(8) function code(f, n)
real(8), intent (in) :: f
real(8), intent (in) :: n
real(8) :: tmp
if (f <= (-3.7d-56)) then
tmp = f / (n - f)
else if (f <= 2.3d+14) then
tmp = n / (n - f)
else
tmp = (-1.0d0) + ((n * (-2.0d0)) / f)
end if
code = tmp
end function
public static double code(double f, double n) {
double tmp;
if (f <= -3.7e-56) {
tmp = f / (n - f);
} else if (f <= 2.3e+14) {
tmp = n / (n - f);
} else {
tmp = -1.0 + ((n * -2.0) / f);
}
return tmp;
}
def code(f, n): tmp = 0 if f <= -3.7e-56: tmp = f / (n - f) elif f <= 2.3e+14: tmp = n / (n - f) else: tmp = -1.0 + ((n * -2.0) / f) return tmp
function code(f, n) tmp = 0.0 if (f <= -3.7e-56) tmp = Float64(f / Float64(n - f)); elseif (f <= 2.3e+14) tmp = Float64(n / Float64(n - f)); else tmp = Float64(-1.0 + Float64(Float64(n * -2.0) / f)); end return tmp end
function tmp_2 = code(f, n) tmp = 0.0; if (f <= -3.7e-56) tmp = f / (n - f); elseif (f <= 2.3e+14) tmp = n / (n - f); else tmp = -1.0 + ((n * -2.0) / f); end tmp_2 = tmp; end
code[f_, n_] := If[LessEqual[f, -3.7e-56], N[(f / N[(n - f), $MachinePrecision]), $MachinePrecision], If[LessEqual[f, 2.3e+14], N[(n / N[(n - f), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(n * -2.0), $MachinePrecision] / f), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq -3.7 \cdot 10^{-56}:\\
\;\;\;\;\frac{f}{n - f}\\
\mathbf{elif}\;f \leq 2.3 \cdot 10^{+14}:\\
\;\;\;\;\frac{n}{n - f}\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{n \cdot -2}{f}\\
\end{array}
\end{array}
if f < -3.7000000000000002e-56Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around inf
Simplified80.7%
if -3.7000000000000002e-56 < f < 2.3e14Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around 0
Simplified80.5%
if 2.3e14 < f Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around inf
+-commutativeN/A
associate--r+N/A
associate-*r/N/A
div-subN/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lft-identityN/A
distribute-rgt-out--N/A
metadata-evalN/A
*-lowering-*.f6481.6%
Simplified81.6%
(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-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around inf
Simplified80.7%
if -1.54999999999999994e-56 < f < 2.1e14Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around 0
Simplified80.5%
if 2.1e14 < f Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around inf
Simplified81.1%
Taylor expanded in f around inf
sub-negN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
--lowering--.f64N/A
/-lowering-/.f6481.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-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around inf
Simplified80.7%
if -6.59999999999999967e-56 < f < 5.4e14Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in n around inf
Simplified79.9%
Taylor expanded in f around 0
+-lowering-+.f64N/A
/-lowering-/.f6479.9%
Simplified79.9%
if 5.4e14 < f Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around inf
Simplified81.1%
Taylor expanded in f around inf
sub-negN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
--lowering--.f64N/A
/-lowering-/.f6481.2%
Simplified81.2%
(FPCore (f n) :precision binary64 (let* ((t_0 (- -1.0 (/ n f)))) (if (<= f -2.05e-15) t_0 (if (<= f 1.35e+16) (+ 1.0 (/ f n)) t_0))))
double code(double f, double n) {
double t_0 = -1.0 - (n / f);
double tmp;
if (f <= -2.05e-15) {
tmp = t_0;
} else if (f <= 1.35e+16) {
tmp = 1.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 = (-1.0d0) - (n / f)
if (f <= (-2.05d-15)) then
tmp = t_0
else if (f <= 1.35d+16) then
tmp = 1.0d0 + (f / n)
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 tmp;
if (f <= -2.05e-15) {
tmp = t_0;
} else if (f <= 1.35e+16) {
tmp = 1.0 + (f / n);
} else {
tmp = t_0;
}
return tmp;
}
def code(f, n): t_0 = -1.0 - (n / f) tmp = 0 if f <= -2.05e-15: tmp = t_0 elif f <= 1.35e+16: tmp = 1.0 + (f / n) else: tmp = t_0 return tmp
function code(f, n) t_0 = Float64(-1.0 - Float64(n / f)) tmp = 0.0 if (f <= -2.05e-15) tmp = t_0; elseif (f <= 1.35e+16) tmp = Float64(1.0 + Float64(f / n)); else tmp = t_0; end return tmp end
function tmp_2 = code(f, n) t_0 = -1.0 - (n / f); tmp = 0.0; if (f <= -2.05e-15) tmp = t_0; elseif (f <= 1.35e+16) tmp = 1.0 + (f / n); else tmp = t_0; end tmp_2 = tmp; end
code[f_, n_] := Block[{t$95$0 = N[(-1.0 - N[(n / f), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[f, -2.05e-15], t$95$0, If[LessEqual[f, 1.35e+16], N[(1.0 + N[(f / n), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 - \frac{n}{f}\\
\mathbf{if}\;f \leq -2.05 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;f \leq 1.35 \cdot 10^{+16}:\\
\;\;\;\;1 + \frac{f}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if f < -2.05000000000000018e-15 or 1.35e16 < f Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around inf
Simplified82.5%
Taylor expanded in f around inf
sub-negN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
--lowering--.f64N/A
/-lowering-/.f6482.2%
Simplified82.2%
if -2.05000000000000018e-15 < f < 1.35e16Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in n around inf
Simplified77.9%
Taylor expanded in f around 0
+-lowering-+.f64N/A
/-lowering-/.f6477.9%
Simplified77.9%
(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-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around inf
Simplified81.4%
if -1.11999999999999995e-29 < f < 2e14Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in n around inf
Simplified78.3%
Taylor expanded in f around 0
+-lowering-+.f64N/A
/-lowering-/.f6478.3%
Simplified78.3%
(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-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around inf
Simplified81.9%
if -2.90000000000000019e-15 < f < 1.95e14Initial program 100.0%
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around 0
Simplified77.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-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in f around inf
Simplified54.9%
herbie shell --seed 2024139
(FPCore (f n)
:name "subtraction fraction"
:precision binary64
(/ (- (+ f n)) (- f n)))