
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}
(FPCore (a k m) :precision binary64 (let* ((t_0 (* a (pow k m))) (t_1 (/ t_0 (+ (+ (* k 10.0) 1.0) (* k k))))) (if (<= t_1 2e+274) t_1 t_0)))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double t_1 = t_0 / (((k * 10.0) + 1.0) + (k * k));
double tmp;
if (t_1 <= 2e+274) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = a * (k ** m)
t_1 = t_0 / (((k * 10.0d0) + 1.0d0) + (k * k))
if (t_1 <= 2d+274) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double t_0 = a * Math.pow(k, m);
double t_1 = t_0 / (((k * 10.0) + 1.0) + (k * k));
double tmp;
if (t_1 <= 2e+274) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a * math.pow(k, m) t_1 = t_0 / (((k * 10.0) + 1.0) + (k * k)) tmp = 0 if t_1 <= 2e+274: tmp = t_1 else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a * (k ^ m)) t_1 = Float64(t_0 / Float64(Float64(Float64(k * 10.0) + 1.0) + Float64(k * k))) tmp = 0.0 if (t_1 <= 2e+274) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a * (k ^ m); t_1 = t_0 / (((k * 10.0) + 1.0) + (k * k)); tmp = 0.0; if (t_1 <= 2e+274) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(N[(k * 10.0), $MachinePrecision] + 1.0), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+274], t$95$1, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
t_1 := \frac{t\_0}{\left(k \cdot 10 + 1\right) + k \cdot k}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{+274}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k))) < 1.99999999999999984e274Initial program 97.1%
if 1.99999999999999984e274 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k))) Initial program 49.1%
associate-/l*49.1%
remove-double-neg49.1%
distribute-frac-neg249.1%
distribute-neg-frac249.1%
remove-double-neg49.1%
sqr-neg49.1%
associate-+l+49.1%
sqr-neg49.1%
distribute-rgt-out49.1%
Simplified49.1%
Taylor expanded in k around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification97.8%
(FPCore (a k m) :precision binary64 (if (<= m 3.3) (* a (/ (pow k m) (+ (* k (+ k 10.0)) 1.0))) (* a (pow k m))))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.3) {
tmp = a * (pow(k, m) / ((k * (k + 10.0)) + 1.0));
} else {
tmp = a * pow(k, m);
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 3.3d0) then
tmp = a * ((k ** m) / ((k * (k + 10.0d0)) + 1.0d0))
else
tmp = a * (k ** m)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 3.3) {
tmp = a * (Math.pow(k, m) / ((k * (k + 10.0)) + 1.0));
} else {
tmp = a * Math.pow(k, m);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 3.3: tmp = a * (math.pow(k, m) / ((k * (k + 10.0)) + 1.0)) else: tmp = a * math.pow(k, m) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 3.3) tmp = Float64(a * Float64((k ^ m) / Float64(Float64(k * Float64(k + 10.0)) + 1.0))); else tmp = Float64(a * (k ^ m)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 3.3) tmp = a * ((k ^ m) / ((k * (k + 10.0)) + 1.0)); else tmp = a * (k ^ m); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 3.3], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.3:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{k \cdot \left(k + 10\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;a \cdot {k}^{m}\\
\end{array}
\end{array}
if m < 3.2999999999999998Initial program 96.3%
associate-/l*96.2%
remove-double-neg96.2%
distribute-frac-neg296.2%
distribute-neg-frac296.2%
remove-double-neg96.2%
sqr-neg96.2%
associate-+l+96.2%
sqr-neg96.2%
distribute-rgt-out96.3%
Simplified96.3%
if 3.2999999999999998 < m Initial program 71.6%
associate-/l*71.6%
remove-double-neg71.6%
distribute-frac-neg271.6%
distribute-neg-frac271.6%
remove-double-neg71.6%
sqr-neg71.6%
associate-+l+71.6%
sqr-neg71.6%
distribute-rgt-out71.6%
Simplified71.6%
Taylor expanded in k around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification97.7%
(FPCore (a k m) :precision binary64 (if (or (<= m -7.5) (not (<= m 1.95e-7))) (* a (pow k m)) (/ a (+ (* k (+ k 10.0)) 1.0))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -7.5) || !(m <= 1.95e-7)) {
tmp = a * pow(k, m);
} else {
tmp = a / ((k * (k + 10.0)) + 1.0);
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if ((m <= (-7.5d0)) .or. (.not. (m <= 1.95d-7))) then
tmp = a * (k ** m)
else
tmp = a / ((k * (k + 10.0d0)) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if ((m <= -7.5) || !(m <= 1.95e-7)) {
tmp = a * Math.pow(k, m);
} else {
tmp = a / ((k * (k + 10.0)) + 1.0);
}
return tmp;
}
def code(a, k, m): tmp = 0 if (m <= -7.5) or not (m <= 1.95e-7): tmp = a * math.pow(k, m) else: tmp = a / ((k * (k + 10.0)) + 1.0) return tmp
function code(a, k, m) tmp = 0.0 if ((m <= -7.5) || !(m <= 1.95e-7)) tmp = Float64(a * (k ^ m)); else tmp = Float64(a / Float64(Float64(k * Float64(k + 10.0)) + 1.0)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((m <= -7.5) || ~((m <= 1.95e-7))) tmp = a * (k ^ m); else tmp = a / ((k * (k + 10.0)) + 1.0); end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[m, -7.5], N[Not[LessEqual[m, 1.95e-7]], $MachinePrecision]], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision], N[(a / N[(N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -7.5 \lor \neg \left(m \leq 1.95 \cdot 10^{-7}\right):\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{k \cdot \left(k + 10\right) + 1}\\
\end{array}
\end{array}
if m < -7.5 or 1.95000000000000012e-7 < m Initial program 81.5%
associate-/l*81.5%
remove-double-neg81.5%
distribute-frac-neg281.5%
distribute-neg-frac281.5%
remove-double-neg81.5%
sqr-neg81.5%
associate-+l+81.5%
sqr-neg81.5%
distribute-rgt-out81.5%
Simplified81.5%
Taylor expanded in k around 0 100.0%
*-commutative100.0%
Simplified100.0%
if -7.5 < m < 1.95000000000000012e-7Initial program 94.2%
associate-/l*94.2%
remove-double-neg94.2%
distribute-frac-neg294.2%
distribute-neg-frac294.2%
remove-double-neg94.2%
sqr-neg94.2%
associate-+l+94.1%
sqr-neg94.1%
distribute-rgt-out94.2%
Simplified94.2%
Taylor expanded in m around 0 93.5%
Final simplification97.5%
(FPCore (a k m)
:precision binary64
(if (<= k -1.3e+117)
(* a (+ (* k -10.0) 1.0))
(if (or (<= k 1.9e-306) (not (<= k 10.0)))
(/ (/ a k) k)
(* a (/ -1.0 (- -1.0 (* k 10.0)))))))
double code(double a, double k, double m) {
double tmp;
if (k <= -1.3e+117) {
tmp = a * ((k * -10.0) + 1.0);
} else if ((k <= 1.9e-306) || !(k <= 10.0)) {
tmp = (a / k) / k;
} else {
tmp = a * (-1.0 / (-1.0 - (k * 10.0)));
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (k <= (-1.3d+117)) then
tmp = a * ((k * (-10.0d0)) + 1.0d0)
else if ((k <= 1.9d-306) .or. (.not. (k <= 10.0d0))) then
tmp = (a / k) / k
else
tmp = a * ((-1.0d0) / ((-1.0d0) - (k * 10.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (k <= -1.3e+117) {
tmp = a * ((k * -10.0) + 1.0);
} else if ((k <= 1.9e-306) || !(k <= 10.0)) {
tmp = (a / k) / k;
} else {
tmp = a * (-1.0 / (-1.0 - (k * 10.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= -1.3e+117: tmp = a * ((k * -10.0) + 1.0) elif (k <= 1.9e-306) or not (k <= 10.0): tmp = (a / k) / k else: tmp = a * (-1.0 / (-1.0 - (k * 10.0))) return tmp
function code(a, k, m) tmp = 0.0 if (k <= -1.3e+117) tmp = Float64(a * Float64(Float64(k * -10.0) + 1.0)); elseif ((k <= 1.9e-306) || !(k <= 10.0)) tmp = Float64(Float64(a / k) / k); else tmp = Float64(a * Float64(-1.0 / Float64(-1.0 - Float64(k * 10.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= -1.3e+117) tmp = a * ((k * -10.0) + 1.0); elseif ((k <= 1.9e-306) || ~((k <= 10.0))) tmp = (a / k) / k; else tmp = a * (-1.0 / (-1.0 - (k * 10.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, -1.3e+117], N[(a * N[(N[(k * -10.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[k, 1.9e-306], N[Not[LessEqual[k, 10.0]], $MachinePrecision]], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision], N[(a * N[(-1.0 / N[(-1.0 - N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq -1.3 \cdot 10^{+117}:\\
\;\;\;\;a \cdot \left(k \cdot -10 + 1\right)\\
\mathbf{elif}\;k \leq 1.9 \cdot 10^{-306} \lor \neg \left(k \leq 10\right):\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \frac{-1}{-1 - k \cdot 10}\\
\end{array}
\end{array}
if k < -1.3e117Initial program 42.3%
associate-/l*42.3%
remove-double-neg42.3%
distribute-frac-neg242.3%
distribute-neg-frac242.3%
remove-double-neg42.3%
sqr-neg42.3%
associate-+l+42.3%
sqr-neg42.3%
distribute-rgt-out42.3%
Simplified42.3%
Taylor expanded in k around 0 26.9%
*-commutative26.9%
Simplified26.9%
Taylor expanded in m around 0 9.0%
Taylor expanded in k around 0 30.8%
*-commutative30.8%
Simplified30.8%
if -1.3e117 < k < 1.9e-306 or 10 < k Initial program 86.4%
associate-/l*86.4%
remove-double-neg86.4%
distribute-frac-neg286.4%
distribute-neg-frac286.4%
remove-double-neg86.4%
sqr-neg86.4%
associate-+l+86.4%
sqr-neg86.4%
distribute-rgt-out86.4%
Simplified86.4%
Taylor expanded in m around 0 40.7%
Taylor expanded in k around inf 43.4%
*-un-lft-identity43.4%
unpow243.4%
times-frac45.9%
Applied egg-rr45.9%
associate-*l/46.0%
*-lft-identity46.0%
Simplified46.0%
if 1.9e-306 < k < 10Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
distribute-frac-neg2100.0%
distribute-neg-frac2100.0%
remove-double-neg100.0%
sqr-neg100.0%
associate-+l+99.9%
sqr-neg99.9%
distribute-rgt-out99.9%
Simplified99.9%
Taylor expanded in k around 0 97.0%
*-commutative97.0%
Simplified97.0%
Taylor expanded in m around 0 52.7%
Final simplification46.6%
(FPCore (a k m) :precision binary64 (if (or (<= k -7e+117) (and (not (<= k 1.9e-306)) (<= k 0.1))) (* a (+ (* k -10.0) 1.0)) (/ (/ a k) k)))
double code(double a, double k, double m) {
double tmp;
if ((k <= -7e+117) || (!(k <= 1.9e-306) && (k <= 0.1))) {
tmp = a * ((k * -10.0) + 1.0);
} else {
tmp = (a / k) / k;
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if ((k <= (-7d+117)) .or. (.not. (k <= 1.9d-306)) .and. (k <= 0.1d0)) then
tmp = a * ((k * (-10.0d0)) + 1.0d0)
else
tmp = (a / k) / k
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if ((k <= -7e+117) || (!(k <= 1.9e-306) && (k <= 0.1))) {
tmp = a * ((k * -10.0) + 1.0);
} else {
tmp = (a / k) / k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if (k <= -7e+117) or (not (k <= 1.9e-306) and (k <= 0.1)): tmp = a * ((k * -10.0) + 1.0) else: tmp = (a / k) / k return tmp
function code(a, k, m) tmp = 0.0 if ((k <= -7e+117) || (!(k <= 1.9e-306) && (k <= 0.1))) tmp = Float64(a * Float64(Float64(k * -10.0) + 1.0)); else tmp = Float64(Float64(a / k) / k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((k <= -7e+117) || (~((k <= 1.9e-306)) && (k <= 0.1))) tmp = a * ((k * -10.0) + 1.0); else tmp = (a / k) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[k, -7e+117], And[N[Not[LessEqual[k, 1.9e-306]], $MachinePrecision], LessEqual[k, 0.1]]], N[(a * N[(N[(k * -10.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq -7 \cdot 10^{+117} \lor \neg \left(k \leq 1.9 \cdot 10^{-306}\right) \land k \leq 0.1:\\
\;\;\;\;a \cdot \left(k \cdot -10 + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\end{array}
\end{array}
if k < -6.99999999999999965e117 or 1.9e-306 < k < 0.10000000000000001Initial program 86.1%
associate-/l*86.1%
remove-double-neg86.1%
distribute-frac-neg286.1%
distribute-neg-frac286.1%
remove-double-neg86.1%
sqr-neg86.1%
associate-+l+86.1%
sqr-neg86.1%
distribute-rgt-out86.1%
Simplified86.1%
Taylor expanded in k around 0 81.5%
*-commutative81.5%
Simplified81.5%
Taylor expanded in m around 0 43.1%
Taylor expanded in k around 0 48.1%
*-commutative48.1%
Simplified48.1%
if -6.99999999999999965e117 < k < 1.9e-306 or 0.10000000000000001 < k Initial program 86.7%
associate-/l*86.6%
remove-double-neg86.6%
distribute-frac-neg286.6%
distribute-neg-frac286.6%
remove-double-neg86.6%
sqr-neg86.6%
associate-+l+86.6%
sqr-neg86.6%
distribute-rgt-out86.7%
Simplified86.7%
Taylor expanded in m around 0 41.2%
Taylor expanded in k around inf 42.7%
*-un-lft-identity42.7%
unpow242.7%
times-frac45.2%
Applied egg-rr45.2%
associate-*l/45.3%
*-lft-identity45.3%
Simplified45.3%
Final simplification46.5%
(FPCore (a k m)
:precision binary64
(if (<= k -3.9e+118)
(* a (+ (* k -10.0) 1.0))
(if (or (<= k 1.9e-306) (not (<= k 10.0)))
(/ (/ a k) k)
(/ a (+ (* k 10.0) 1.0)))))
double code(double a, double k, double m) {
double tmp;
if (k <= -3.9e+118) {
tmp = a * ((k * -10.0) + 1.0);
} else if ((k <= 1.9e-306) || !(k <= 10.0)) {
tmp = (a / k) / k;
} else {
tmp = a / ((k * 10.0) + 1.0);
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (k <= (-3.9d+118)) then
tmp = a * ((k * (-10.0d0)) + 1.0d0)
else if ((k <= 1.9d-306) .or. (.not. (k <= 10.0d0))) then
tmp = (a / k) / k
else
tmp = a / ((k * 10.0d0) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (k <= -3.9e+118) {
tmp = a * ((k * -10.0) + 1.0);
} else if ((k <= 1.9e-306) || !(k <= 10.0)) {
tmp = (a / k) / k;
} else {
tmp = a / ((k * 10.0) + 1.0);
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= -3.9e+118: tmp = a * ((k * -10.0) + 1.0) elif (k <= 1.9e-306) or not (k <= 10.0): tmp = (a / k) / k else: tmp = a / ((k * 10.0) + 1.0) return tmp
function code(a, k, m) tmp = 0.0 if (k <= -3.9e+118) tmp = Float64(a * Float64(Float64(k * -10.0) + 1.0)); elseif ((k <= 1.9e-306) || !(k <= 10.0)) tmp = Float64(Float64(a / k) / k); else tmp = Float64(a / Float64(Float64(k * 10.0) + 1.0)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= -3.9e+118) tmp = a * ((k * -10.0) + 1.0); elseif ((k <= 1.9e-306) || ~((k <= 10.0))) tmp = (a / k) / k; else tmp = a / ((k * 10.0) + 1.0); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, -3.9e+118], N[(a * N[(N[(k * -10.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[k, 1.9e-306], N[Not[LessEqual[k, 10.0]], $MachinePrecision]], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision], N[(a / N[(N[(k * 10.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq -3.9 \cdot 10^{+118}:\\
\;\;\;\;a \cdot \left(k \cdot -10 + 1\right)\\
\mathbf{elif}\;k \leq 1.9 \cdot 10^{-306} \lor \neg \left(k \leq 10\right):\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{k \cdot 10 + 1}\\
\end{array}
\end{array}
if k < -3.9e118Initial program 42.3%
associate-/l*42.3%
remove-double-neg42.3%
distribute-frac-neg242.3%
distribute-neg-frac242.3%
remove-double-neg42.3%
sqr-neg42.3%
associate-+l+42.3%
sqr-neg42.3%
distribute-rgt-out42.3%
Simplified42.3%
Taylor expanded in k around 0 26.9%
*-commutative26.9%
Simplified26.9%
Taylor expanded in m around 0 9.0%
Taylor expanded in k around 0 30.8%
*-commutative30.8%
Simplified30.8%
if -3.9e118 < k < 1.9e-306 or 10 < k Initial program 86.4%
associate-/l*86.4%
remove-double-neg86.4%
distribute-frac-neg286.4%
distribute-neg-frac286.4%
remove-double-neg86.4%
sqr-neg86.4%
associate-+l+86.4%
sqr-neg86.4%
distribute-rgt-out86.4%
Simplified86.4%
Taylor expanded in m around 0 40.7%
Taylor expanded in k around inf 43.4%
*-un-lft-identity43.4%
unpow243.4%
times-frac45.9%
Applied egg-rr45.9%
associate-*l/46.0%
*-lft-identity46.0%
Simplified46.0%
if 1.9e-306 < k < 10Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
distribute-frac-neg2100.0%
distribute-neg-frac2100.0%
remove-double-neg100.0%
sqr-neg100.0%
associate-+l+99.9%
sqr-neg99.9%
distribute-rgt-out99.9%
Simplified99.9%
Taylor expanded in m around 0 55.6%
Taylor expanded in k around 0 52.7%
*-commutative97.0%
Simplified52.7%
Final simplification46.6%
(FPCore (a k m)
:precision binary64
(if (<= m -7.2e-16)
(/ 1.0 (* k (/ k a)))
(if (<= m 2.65e+45)
(/ a (+ (* k (+ k 10.0)) 1.0))
(* a (+ (* k -10.0) 1.0)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -7.2e-16) {
tmp = 1.0 / (k * (k / a));
} else if (m <= 2.65e+45) {
tmp = a / ((k * (k + 10.0)) + 1.0);
} else {
tmp = a * ((k * -10.0) + 1.0);
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= (-7.2d-16)) then
tmp = 1.0d0 / (k * (k / a))
else if (m <= 2.65d+45) then
tmp = a / ((k * (k + 10.0d0)) + 1.0d0)
else
tmp = a * ((k * (-10.0d0)) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -7.2e-16) {
tmp = 1.0 / (k * (k / a));
} else if (m <= 2.65e+45) {
tmp = a / ((k * (k + 10.0)) + 1.0);
} else {
tmp = a * ((k * -10.0) + 1.0);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -7.2e-16: tmp = 1.0 / (k * (k / a)) elif m <= 2.65e+45: tmp = a / ((k * (k + 10.0)) + 1.0) else: tmp = a * ((k * -10.0) + 1.0) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -7.2e-16) tmp = Float64(1.0 / Float64(k * Float64(k / a))); elseif (m <= 2.65e+45) tmp = Float64(a / Float64(Float64(k * Float64(k + 10.0)) + 1.0)); else tmp = Float64(a * Float64(Float64(k * -10.0) + 1.0)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -7.2e-16) tmp = 1.0 / (k * (k / a)); elseif (m <= 2.65e+45) tmp = a / ((k * (k + 10.0)) + 1.0); else tmp = a * ((k * -10.0) + 1.0); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -7.2e-16], N[(1.0 / N[(k * N[(k / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 2.65e+45], N[(a / N[(N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(a * N[(N[(k * -10.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -7.2 \cdot 10^{-16}:\\
\;\;\;\;\frac{1}{k \cdot \frac{k}{a}}\\
\mathbf{elif}\;m \leq 2.65 \cdot 10^{+45}:\\
\;\;\;\;\frac{a}{k \cdot \left(k + 10\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(k \cdot -10 + 1\right)\\
\end{array}
\end{array}
if m < -7.19999999999999965e-16Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
distribute-frac-neg2100.0%
distribute-neg-frac2100.0%
remove-double-neg100.0%
sqr-neg100.0%
associate-+l+100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
Simplified100.0%
Taylor expanded in m around 0 31.5%
Taylor expanded in k around inf 56.4%
*-un-lft-identity56.4%
unpow256.4%
times-frac51.3%
Applied egg-rr51.3%
clear-num51.3%
frac-times51.6%
metadata-eval51.6%
Applied egg-rr51.6%
if -7.19999999999999965e-16 < m < 2.64999999999999996e45Initial program 92.7%
associate-/l*92.7%
remove-double-neg92.7%
distribute-frac-neg292.7%
distribute-neg-frac292.7%
remove-double-neg92.7%
sqr-neg92.7%
associate-+l+92.7%
sqr-neg92.7%
distribute-rgt-out92.7%
Simplified92.7%
Taylor expanded in m around 0 85.1%
if 2.64999999999999996e45 < m Initial program 70.7%
associate-/l*70.7%
remove-double-neg70.7%
distribute-frac-neg270.7%
distribute-neg-frac270.7%
remove-double-neg70.7%
sqr-neg70.7%
associate-+l+70.7%
sqr-neg70.7%
distribute-rgt-out70.7%
Simplified70.7%
Taylor expanded in k around 0 69.6%
*-commutative69.6%
Simplified69.6%
Taylor expanded in m around 0 2.3%
Taylor expanded in k around 0 10.4%
*-commutative10.4%
Simplified10.4%
Final simplification50.7%
(FPCore (a k m)
:precision binary64
(if (<= m -7.5)
(/ a (* k k))
(if (<= m 2.6e+45)
(/ a (+ (* k (+ k 10.0)) 1.0))
(* a (+ (* k -10.0) 1.0)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -7.5) {
tmp = a / (k * k);
} else if (m <= 2.6e+45) {
tmp = a / ((k * (k + 10.0)) + 1.0);
} else {
tmp = a * ((k * -10.0) + 1.0);
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= (-7.5d0)) then
tmp = a / (k * k)
else if (m <= 2.6d+45) then
tmp = a / ((k * (k + 10.0d0)) + 1.0d0)
else
tmp = a * ((k * (-10.0d0)) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -7.5) {
tmp = a / (k * k);
} else if (m <= 2.6e+45) {
tmp = a / ((k * (k + 10.0)) + 1.0);
} else {
tmp = a * ((k * -10.0) + 1.0);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -7.5: tmp = a / (k * k) elif m <= 2.6e+45: tmp = a / ((k * (k + 10.0)) + 1.0) else: tmp = a * ((k * -10.0) + 1.0) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -7.5) tmp = Float64(a / Float64(k * k)); elseif (m <= 2.6e+45) tmp = Float64(a / Float64(Float64(k * Float64(k + 10.0)) + 1.0)); else tmp = Float64(a * Float64(Float64(k * -10.0) + 1.0)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -7.5) tmp = a / (k * k); elseif (m <= 2.6e+45) tmp = a / ((k * (k + 10.0)) + 1.0); else tmp = a * ((k * -10.0) + 1.0); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -7.5], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 2.6e+45], N[(a / N[(N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(a * N[(N[(k * -10.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -7.5:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 2.6 \cdot 10^{+45}:\\
\;\;\;\;\frac{a}{k \cdot \left(k + 10\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(k \cdot -10 + 1\right)\\
\end{array}
\end{array}
if m < -7.5Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
distribute-frac-neg2100.0%
distribute-neg-frac2100.0%
remove-double-neg100.0%
sqr-neg100.0%
associate-+l+100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
Simplified100.0%
Taylor expanded in m around 0 28.4%
Taylor expanded in k around inf 54.7%
*-un-lft-identity54.7%
unpow254.7%
times-frac49.3%
Applied egg-rr49.3%
frac-times54.7%
*-commutative54.7%
frac-times49.3%
frac-2neg49.3%
frac-2neg49.3%
metadata-eval49.3%
frac-times54.7%
Applied egg-rr54.7%
if -7.5 < m < 2.60000000000000007e45Initial program 92.9%
associate-/l*92.9%
remove-double-neg92.9%
distribute-frac-neg292.9%
distribute-neg-frac292.9%
remove-double-neg92.9%
sqr-neg92.9%
associate-+l+92.8%
sqr-neg92.8%
distribute-rgt-out92.9%
Simplified92.9%
Taylor expanded in m around 0 85.2%
if 2.60000000000000007e45 < m Initial program 70.7%
associate-/l*70.7%
remove-double-neg70.7%
distribute-frac-neg270.7%
distribute-neg-frac270.7%
remove-double-neg70.7%
sqr-neg70.7%
associate-+l+70.7%
sqr-neg70.7%
distribute-rgt-out70.7%
Simplified70.7%
Taylor expanded in k around 0 69.6%
*-commutative69.6%
Simplified69.6%
Taylor expanded in m around 0 2.3%
Taylor expanded in k around 0 10.4%
*-commutative10.4%
Simplified10.4%
Final simplification51.8%
(FPCore (a k m) :precision binary64 (if (or (<= k 1.9e-306) (not (<= k 0.5))) (/ (/ a k) k) a))
double code(double a, double k, double m) {
double tmp;
if ((k <= 1.9e-306) || !(k <= 0.5)) {
tmp = (a / k) / k;
} else {
tmp = a;
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if ((k <= 1.9d-306) .or. (.not. (k <= 0.5d0))) then
tmp = (a / k) / k
else
tmp = a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if ((k <= 1.9e-306) || !(k <= 0.5)) {
tmp = (a / k) / k;
} else {
tmp = a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if (k <= 1.9e-306) or not (k <= 0.5): tmp = (a / k) / k else: tmp = a return tmp
function code(a, k, m) tmp = 0.0 if ((k <= 1.9e-306) || !(k <= 0.5)) tmp = Float64(Float64(a / k) / k); else tmp = a; end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((k <= 1.9e-306) || ~((k <= 0.5))) tmp = (a / k) / k; else tmp = a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[k, 1.9e-306], N[Not[LessEqual[k, 0.5]], $MachinePrecision]], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision], a]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.9 \cdot 10^{-306} \lor \neg \left(k \leq 0.5\right):\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if k < 1.9e-306 or 0.5 < k Initial program 79.9%
associate-/l*79.9%
remove-double-neg79.9%
distribute-frac-neg279.9%
distribute-neg-frac279.9%
remove-double-neg79.9%
sqr-neg79.9%
associate-+l+79.9%
sqr-neg79.9%
distribute-rgt-out79.9%
Simplified79.9%
Taylor expanded in m around 0 37.3%
Taylor expanded in k around inf 39.0%
*-un-lft-identity39.0%
unpow239.0%
times-frac40.6%
Applied egg-rr40.6%
associate-*l/40.6%
*-lft-identity40.6%
Simplified40.6%
if 1.9e-306 < k < 0.5Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
distribute-frac-neg2100.0%
distribute-neg-frac2100.0%
remove-double-neg100.0%
sqr-neg100.0%
associate-+l+99.9%
sqr-neg99.9%
distribute-rgt-out99.9%
Simplified99.9%
Taylor expanded in m around 0 55.7%
Taylor expanded in k around 0 52.5%
Final simplification44.4%
(FPCore (a k m) :precision binary64 (if (<= k 0.1) a (/ (* a 0.1) k)))
double code(double a, double k, double m) {
double tmp;
if (k <= 0.1) {
tmp = a;
} else {
tmp = (a * 0.1) / k;
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (k <= 0.1d0) then
tmp = a
else
tmp = (a * 0.1d0) / k
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (k <= 0.1) {
tmp = a;
} else {
tmp = (a * 0.1) / k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= 0.1: tmp = a else: tmp = (a * 0.1) / k return tmp
function code(a, k, m) tmp = 0.0 if (k <= 0.1) tmp = a; else tmp = Float64(Float64(a * 0.1) / k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= 0.1) tmp = a; else tmp = (a * 0.1) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, 0.1], a, N[(N[(a * 0.1), $MachinePrecision] / k), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 0.1:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\frac{a \cdot 0.1}{k}\\
\end{array}
\end{array}
if k < 0.10000000000000001Initial program 90.8%
associate-/l*90.8%
remove-double-neg90.8%
distribute-frac-neg290.8%
distribute-neg-frac290.8%
remove-double-neg90.8%
sqr-neg90.8%
associate-+l+90.8%
sqr-neg90.8%
distribute-rgt-out90.8%
Simplified90.8%
Taylor expanded in m around 0 32.0%
Taylor expanded in k around 0 28.3%
if 0.10000000000000001 < k Initial program 78.6%
associate-/l*78.5%
remove-double-neg78.5%
distribute-frac-neg278.5%
distribute-neg-frac278.5%
remove-double-neg78.5%
sqr-neg78.5%
associate-+l+78.5%
sqr-neg78.5%
distribute-rgt-out78.5%
Simplified78.5%
Taylor expanded in k around 0 61.3%
*-commutative61.3%
Simplified61.3%
Taylor expanded in m around 0 27.6%
Taylor expanded in k around inf 27.5%
associate-*r/27.5%
Simplified27.5%
Final simplification28.0%
(FPCore (a k m) :precision binary64 a)
double code(double a, double k, double m) {
return a;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a
end function
public static double code(double a, double k, double m) {
return a;
}
def code(a, k, m): return a
function code(a, k, m) return a end
function tmp = code(a, k, m) tmp = a; end
code[a_, k_, m_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 86.4%
associate-/l*86.4%
remove-double-neg86.4%
distribute-frac-neg286.4%
distribute-neg-frac286.4%
remove-double-neg86.4%
sqr-neg86.4%
associate-+l+86.4%
sqr-neg86.4%
distribute-rgt-out86.4%
Simplified86.4%
Taylor expanded in m around 0 43.3%
Taylor expanded in k around 0 19.9%
Final simplification19.9%
herbie shell --seed 2024052
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))