
(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 12 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 (/ 1.0 t_0))) (if (<= k 2e-54) t_0 (/ 1.0 (+ t_1 (* k (+ (* 10.0 t_1) (/ k t_0))))))))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double t_1 = 1.0 / t_0;
double tmp;
if (k <= 2e-54) {
tmp = t_0;
} else {
tmp = 1.0 / (t_1 + (k * ((10.0 * t_1) + (k / 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 = 1.0d0 / t_0
if (k <= 2d-54) then
tmp = t_0
else
tmp = 1.0d0 / (t_1 + (k * ((10.0d0 * t_1) + (k / 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 = 1.0 / t_0;
double tmp;
if (k <= 2e-54) {
tmp = t_0;
} else {
tmp = 1.0 / (t_1 + (k * ((10.0 * t_1) + (k / t_0))));
}
return tmp;
}
def code(a, k, m): t_0 = a * math.pow(k, m) t_1 = 1.0 / t_0 tmp = 0 if k <= 2e-54: tmp = t_0 else: tmp = 1.0 / (t_1 + (k * ((10.0 * t_1) + (k / t_0)))) return tmp
function code(a, k, m) t_0 = Float64(a * (k ^ m)) t_1 = Float64(1.0 / t_0) tmp = 0.0 if (k <= 2e-54) tmp = t_0; else tmp = Float64(1.0 / Float64(t_1 + Float64(k * Float64(Float64(10.0 * t_1) + Float64(k / t_0))))); end return tmp end
function tmp_2 = code(a, k, m) t_0 = a * (k ^ m); t_1 = 1.0 / t_0; tmp = 0.0; if (k <= 2e-54) tmp = t_0; else tmp = 1.0 / (t_1 + (k * ((10.0 * t_1) + (k / 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[(1.0 / t$95$0), $MachinePrecision]}, If[LessEqual[k, 2e-54], t$95$0, N[(1.0 / N[(t$95$1 + N[(k * N[(N[(10.0 * t$95$1), $MachinePrecision] + N[(k / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
t_1 := \frac{1}{t\_0}\\
\mathbf{if}\;k \leq 2 \cdot 10^{-54}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_1 + k \cdot \left(10 \cdot t\_1 + \frac{k}{t\_0}\right)}\\
\end{array}
\end{array}
if k < 2.0000000000000001e-54Initial program 96.7%
associate-/l*96.7%
remove-double-neg96.7%
distribute-frac-neg296.7%
distribute-neg-frac296.7%
remove-double-neg96.7%
sqr-neg96.7%
associate-+l+96.7%
sqr-neg96.7%
distribute-rgt-out96.7%
Simplified96.7%
Taylor expanded in k around 0 99.3%
if 2.0000000000000001e-54 < k Initial program 86.5%
associate-/l*86.5%
remove-double-neg86.5%
distribute-frac-neg286.5%
distribute-neg-frac286.5%
remove-double-neg86.5%
sqr-neg86.5%
associate-+l+86.5%
sqr-neg86.5%
distribute-rgt-out86.5%
Simplified86.5%
distribute-lft-in86.5%
associate-+l+86.5%
associate-*r/86.5%
clear-num86.5%
associate-+l+86.5%
distribute-lft-in86.5%
+-commutative86.5%
fma-define86.5%
+-commutative86.5%
*-commutative86.5%
Applied egg-rr86.5%
Taylor expanded in k around 0 99.4%
Final simplification99.4%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* a (pow k m))))
(if (<= (/ t_0 (+ (+ 1.0 (* k 10.0)) (* k k))) 2e+259)
(/ 1.0 (+ (/ 1.0 t_0) (* k (+ (/ k t_0) (/ 10.0 a)))))
t_0)))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double tmp;
if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 2e+259) {
tmp = 1.0 / ((1.0 / t_0) + (k * ((k / t_0) + (10.0 / a))));
} 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) :: tmp
t_0 = a * (k ** m)
if ((t_0 / ((1.0d0 + (k * 10.0d0)) + (k * k))) <= 2d+259) then
tmp = 1.0d0 / ((1.0d0 / t_0) + (k * ((k / t_0) + (10.0d0 / a))))
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 tmp;
if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 2e+259) {
tmp = 1.0 / ((1.0 / t_0) + (k * ((k / t_0) + (10.0 / a))));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a * math.pow(k, m) tmp = 0 if (t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 2e+259: tmp = 1.0 / ((1.0 / t_0) + (k * ((k / t_0) + (10.0 / a)))) else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a * (k ^ m)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(1.0 + Float64(k * 10.0)) + Float64(k * k))) <= 2e+259) tmp = Float64(1.0 / Float64(Float64(1.0 / t_0) + Float64(k * Float64(Float64(k / t_0) + Float64(10.0 / a))))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a * (k ^ m); tmp = 0.0; if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 2e+259) tmp = 1.0 / ((1.0 / t_0) + (k * ((k / t_0) + (10.0 / a)))); 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]}, If[LessEqual[N[(t$95$0 / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+259], N[(1.0 / N[(N[(1.0 / t$95$0), $MachinePrecision] + N[(k * N[(N[(k / t$95$0), $MachinePrecision] + N[(10.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;\frac{t\_0}{\left(1 + k \cdot 10\right) + k \cdot k} \leq 2 \cdot 10^{+259}:\\
\;\;\;\;\frac{1}{\frac{1}{t\_0} + k \cdot \left(\frac{k}{t\_0} + \frac{10}{a}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 2e259Initial program 97.0%
associate-/l*97.0%
remove-double-neg97.0%
distribute-frac-neg297.0%
distribute-neg-frac297.0%
remove-double-neg97.0%
sqr-neg97.0%
associate-+l+97.0%
sqr-neg97.0%
distribute-rgt-out97.0%
Simplified97.0%
distribute-lft-in97.0%
associate-+l+97.0%
associate-*r/97.0%
clear-num96.9%
associate-+l+96.9%
distribute-lft-in96.9%
+-commutative96.9%
fma-define96.9%
+-commutative96.9%
*-commutative96.9%
Applied egg-rr96.9%
Taylor expanded in k around 0 76.2%
Taylor expanded in m around 0 87.1%
if 2e259 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 72.3%
associate-/l*72.3%
remove-double-neg72.3%
distribute-frac-neg272.3%
distribute-neg-frac272.3%
remove-double-neg72.3%
sqr-neg72.3%
associate-+l+72.3%
sqr-neg72.3%
distribute-rgt-out72.3%
Simplified72.3%
Taylor expanded in k around 0 100.0%
Final simplification89.5%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* a (pow k m))))
(if (<= (/ t_0 (+ (+ 1.0 (* k 10.0)) (* k k))) 2e+259)
(/ 1.0 (+ (* k (+ (/ k t_0) (/ 10.0 a))) (/ 1.0 a)))
t_0)))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double tmp;
if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 2e+259) {
tmp = 1.0 / ((k * ((k / t_0) + (10.0 / a))) + (1.0 / a));
} 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) :: tmp
t_0 = a * (k ** m)
if ((t_0 / ((1.0d0 + (k * 10.0d0)) + (k * k))) <= 2d+259) then
tmp = 1.0d0 / ((k * ((k / t_0) + (10.0d0 / a))) + (1.0d0 / a))
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 tmp;
if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 2e+259) {
tmp = 1.0 / ((k * ((k / t_0) + (10.0 / a))) + (1.0 / a));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a * math.pow(k, m) tmp = 0 if (t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 2e+259: tmp = 1.0 / ((k * ((k / t_0) + (10.0 / a))) + (1.0 / a)) else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a * (k ^ m)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(1.0 + Float64(k * 10.0)) + Float64(k * k))) <= 2e+259) tmp = Float64(1.0 / Float64(Float64(k * Float64(Float64(k / t_0) + Float64(10.0 / a))) + Float64(1.0 / a))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a * (k ^ m); tmp = 0.0; if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 2e+259) tmp = 1.0 / ((k * ((k / t_0) + (10.0 / a))) + (1.0 / a)); 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]}, If[LessEqual[N[(t$95$0 / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+259], N[(1.0 / N[(N[(k * N[(N[(k / t$95$0), $MachinePrecision] + N[(10.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;\frac{t\_0}{\left(1 + k \cdot 10\right) + k \cdot k} \leq 2 \cdot 10^{+259}:\\
\;\;\;\;\frac{1}{k \cdot \left(\frac{k}{t\_0} + \frac{10}{a}\right) + \frac{1}{a}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 2e259Initial program 97.0%
associate-/l*97.0%
remove-double-neg97.0%
distribute-frac-neg297.0%
distribute-neg-frac297.0%
remove-double-neg97.0%
sqr-neg97.0%
associate-+l+97.0%
sqr-neg97.0%
distribute-rgt-out97.0%
Simplified97.0%
distribute-lft-in97.0%
associate-+l+97.0%
associate-*r/97.0%
clear-num96.9%
associate-+l+96.9%
distribute-lft-in96.9%
+-commutative96.9%
fma-define96.9%
+-commutative96.9%
*-commutative96.9%
Applied egg-rr96.9%
Taylor expanded in k around 0 76.2%
Taylor expanded in m around 0 87.1%
Taylor expanded in m around 0 86.5%
if 2e259 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 72.3%
associate-/l*72.3%
remove-double-neg72.3%
distribute-frac-neg272.3%
distribute-neg-frac272.3%
remove-double-neg72.3%
sqr-neg72.3%
associate-+l+72.3%
sqr-neg72.3%
distribute-rgt-out72.3%
Simplified72.3%
Taylor expanded in k around 0 100.0%
Final simplification89.0%
(FPCore (a k m)
:precision binary64
(if (<= m -5e-15)
(* a (/ (pow k m) (+ 1.0 (* k 10.0))))
(if (<= m 1.22e-14)
(/ 1.0 (+ (/ 1.0 a) (* (/ k a) (+ k 10.0))))
(* a (pow k m)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -5e-15) {
tmp = a * (pow(k, m) / (1.0 + (k * 10.0)));
} else if (m <= 1.22e-14) {
tmp = 1.0 / ((1.0 / a) + ((k / a) * (k + 10.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 <= (-5d-15)) then
tmp = a * ((k ** m) / (1.0d0 + (k * 10.0d0)))
else if (m <= 1.22d-14) then
tmp = 1.0d0 / ((1.0d0 / a) + ((k / a) * (k + 10.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 <= -5e-15) {
tmp = a * (Math.pow(k, m) / (1.0 + (k * 10.0)));
} else if (m <= 1.22e-14) {
tmp = 1.0 / ((1.0 / a) + ((k / a) * (k + 10.0)));
} else {
tmp = a * Math.pow(k, m);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -5e-15: tmp = a * (math.pow(k, m) / (1.0 + (k * 10.0))) elif m <= 1.22e-14: tmp = 1.0 / ((1.0 / a) + ((k / a) * (k + 10.0))) else: tmp = a * math.pow(k, m) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -5e-15) tmp = Float64(a * Float64((k ^ m) / Float64(1.0 + Float64(k * 10.0)))); elseif (m <= 1.22e-14) tmp = Float64(1.0 / Float64(Float64(1.0 / a) + Float64(Float64(k / a) * Float64(k + 10.0)))); else tmp = Float64(a * (k ^ m)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -5e-15) tmp = a * ((k ^ m) / (1.0 + (k * 10.0))); elseif (m <= 1.22e-14) tmp = 1.0 / ((1.0 / a) + ((k / a) * (k + 10.0))); else tmp = a * (k ^ m); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -5e-15], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.22e-14], N[(1.0 / N[(N[(1.0 / a), $MachinePrecision] + N[(N[(k / a), $MachinePrecision] * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -5 \cdot 10^{-15}:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{1 + k \cdot 10}\\
\mathbf{elif}\;m \leq 1.22 \cdot 10^{-14}:\\
\;\;\;\;\frac{1}{\frac{1}{a} + \frac{k}{a} \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a \cdot {k}^{m}\\
\end{array}
\end{array}
if m < -4.99999999999999999e-15Initial 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 k around 0 100.0%
*-commutative100.0%
Simplified100.0%
if -4.99999999999999999e-15 < m < 1.21999999999999994e-14Initial program 92.6%
associate-/l*92.6%
remove-double-neg92.6%
distribute-frac-neg292.6%
distribute-neg-frac292.6%
remove-double-neg92.6%
sqr-neg92.6%
associate-+l+92.6%
sqr-neg92.6%
distribute-rgt-out92.6%
Simplified92.6%
distribute-lft-in92.6%
associate-+l+92.6%
associate-*r/92.6%
clear-num92.5%
associate-+l+92.5%
distribute-lft-in92.5%
+-commutative92.5%
fma-define92.5%
+-commutative92.5%
*-commutative92.5%
Applied egg-rr92.5%
Taylor expanded in k around 0 99.1%
Taylor expanded in m around 0 99.1%
Taylor expanded in m around 0 98.8%
+-commutative98.8%
distribute-rgt-in98.8%
associate-*r/98.8%
metadata-eval98.8%
associate-*l/98.8%
associate-*r/98.8%
*-commutative98.8%
distribute-lft-out98.8%
Simplified98.8%
if 1.21999999999999994e-14 < m Initial program 85.2%
associate-/l*85.2%
remove-double-neg85.2%
distribute-frac-neg285.2%
distribute-neg-frac285.2%
remove-double-neg85.2%
sqr-neg85.2%
associate-+l+85.2%
sqr-neg85.2%
distribute-rgt-out85.2%
Simplified85.2%
Taylor expanded in k around 0 98.7%
Final simplification99.2%
(FPCore (a k m) :precision binary64 (if (or (<= m -1.7e-5) (not (<= m 1.22e-14))) (* a (pow k m)) (/ 1.0 (+ (/ 1.0 a) (* (/ k a) (+ k 10.0))))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -1.7e-5) || !(m <= 1.22e-14)) {
tmp = a * pow(k, m);
} else {
tmp = 1.0 / ((1.0 / a) + ((k / a) * (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 ((m <= (-1.7d-5)) .or. (.not. (m <= 1.22d-14))) then
tmp = a * (k ** m)
else
tmp = 1.0d0 / ((1.0d0 / a) + ((k / a) * (k + 10.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if ((m <= -1.7e-5) || !(m <= 1.22e-14)) {
tmp = a * Math.pow(k, m);
} else {
tmp = 1.0 / ((1.0 / a) + ((k / a) * (k + 10.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if (m <= -1.7e-5) or not (m <= 1.22e-14): tmp = a * math.pow(k, m) else: tmp = 1.0 / ((1.0 / a) + ((k / a) * (k + 10.0))) return tmp
function code(a, k, m) tmp = 0.0 if ((m <= -1.7e-5) || !(m <= 1.22e-14)) tmp = Float64(a * (k ^ m)); else tmp = Float64(1.0 / Float64(Float64(1.0 / a) + Float64(Float64(k / a) * Float64(k + 10.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((m <= -1.7e-5) || ~((m <= 1.22e-14))) tmp = a * (k ^ m); else tmp = 1.0 / ((1.0 / a) + ((k / a) * (k + 10.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[m, -1.7e-5], N[Not[LessEqual[m, 1.22e-14]], $MachinePrecision]], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(1.0 / a), $MachinePrecision] + N[(N[(k / a), $MachinePrecision] * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.7 \cdot 10^{-5} \lor \neg \left(m \leq 1.22 \cdot 10^{-14}\right):\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{a} + \frac{k}{a} \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -1.7e-5 or 1.21999999999999994e-14 < m Initial program 92.3%
associate-/l*92.3%
remove-double-neg92.3%
distribute-frac-neg292.3%
distribute-neg-frac292.3%
remove-double-neg92.3%
sqr-neg92.3%
associate-+l+92.3%
sqr-neg92.3%
distribute-rgt-out92.3%
Simplified92.3%
Taylor expanded in k around 0 99.3%
if -1.7e-5 < m < 1.21999999999999994e-14Initial program 92.8%
associate-/l*92.8%
remove-double-neg92.8%
distribute-frac-neg292.8%
distribute-neg-frac292.8%
remove-double-neg92.8%
sqr-neg92.8%
associate-+l+92.8%
sqr-neg92.8%
distribute-rgt-out92.8%
Simplified92.8%
distribute-lft-in92.8%
associate-+l+92.8%
associate-*r/92.8%
clear-num92.7%
associate-+l+92.7%
distribute-lft-in92.7%
+-commutative92.7%
fma-define92.7%
+-commutative92.7%
*-commutative92.7%
Applied egg-rr92.7%
Taylor expanded in k around 0 99.1%
Taylor expanded in m around 0 99.1%
Taylor expanded in m around 0 98.6%
+-commutative98.6%
distribute-rgt-in98.6%
associate-*r/98.6%
metadata-eval98.6%
associate-*l/98.6%
associate-*r/98.6%
*-commutative98.6%
distribute-lft-out98.6%
Simplified98.6%
Final simplification99.1%
(FPCore (a k m)
:precision binary64
(if (<= m -6e+21)
(/ a (+ 1.0 (* k k)))
(if (<= m 8.8e+22)
(/ 1.0 (+ (/ 1.0 a) (* (/ k a) (+ k 10.0))))
(* a (+ 1.0 (* k (* k 99.0)))))))
double code(double a, double k, double m) {
double tmp;
if (m <= -6e+21) {
tmp = a / (1.0 + (k * k));
} else if (m <= 8.8e+22) {
tmp = 1.0 / ((1.0 / a) + ((k / a) * (k + 10.0)));
} else {
tmp = a * (1.0 + (k * (k * 99.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 <= (-6d+21)) then
tmp = a / (1.0d0 + (k * k))
else if (m <= 8.8d+22) then
tmp = 1.0d0 / ((1.0d0 / a) + ((k / a) * (k + 10.0d0)))
else
tmp = a * (1.0d0 + (k * (k * 99.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -6e+21) {
tmp = a / (1.0 + (k * k));
} else if (m <= 8.8e+22) {
tmp = 1.0 / ((1.0 / a) + ((k / a) * (k + 10.0)));
} else {
tmp = a * (1.0 + (k * (k * 99.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -6e+21: tmp = a / (1.0 + (k * k)) elif m <= 8.8e+22: tmp = 1.0 / ((1.0 / a) + ((k / a) * (k + 10.0))) else: tmp = a * (1.0 + (k * (k * 99.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -6e+21) tmp = Float64(a / Float64(1.0 + Float64(k * k))); elseif (m <= 8.8e+22) tmp = Float64(1.0 / Float64(Float64(1.0 / a) + Float64(Float64(k / a) * Float64(k + 10.0)))); else tmp = Float64(a * Float64(1.0 + Float64(k * Float64(k * 99.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -6e+21) tmp = a / (1.0 + (k * k)); elseif (m <= 8.8e+22) tmp = 1.0 / ((1.0 / a) + ((k / a) * (k + 10.0))); else tmp = a * (1.0 + (k * (k * 99.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -6e+21], N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 8.8e+22], N[(1.0 / N[(N[(1.0 / a), $MachinePrecision] + N[(N[(k / a), $MachinePrecision] * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[(1.0 + N[(k * N[(k * 99.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -6 \cdot 10^{+21}:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\
\mathbf{elif}\;m \leq 8.8 \cdot 10^{+22}:\\
\;\;\;\;\frac{1}{\frac{1}{a} + \frac{k}{a} \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(1 + k \cdot \left(k \cdot 99\right)\right)\\
\end{array}
\end{array}
if m < -6e21Initial 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 35.0%
Taylor expanded in k around inf 35.0%
if -6e21 < m < 8.8e22Initial program 93.9%
associate-/l*93.9%
remove-double-neg93.9%
distribute-frac-neg293.9%
distribute-neg-frac293.9%
remove-double-neg93.9%
sqr-neg93.9%
associate-+l+93.9%
sqr-neg93.9%
distribute-rgt-out93.9%
Simplified93.9%
distribute-lft-in93.9%
associate-+l+93.9%
associate-*r/93.9%
clear-num93.8%
associate-+l+93.8%
distribute-lft-in93.8%
+-commutative93.8%
fma-define93.8%
+-commutative93.8%
*-commutative93.8%
Applied egg-rr93.8%
Taylor expanded in k around 0 98.3%
Taylor expanded in m around 0 94.6%
Taylor expanded in m around 0 85.9%
+-commutative85.9%
distribute-rgt-in85.9%
associate-*r/85.9%
metadata-eval85.9%
associate-*l/85.9%
associate-*r/85.9%
*-commutative85.9%
distribute-lft-out85.9%
Simplified85.9%
if 8.8e22 < m Initial program 83.8%
associate-/l*83.8%
remove-double-neg83.8%
distribute-frac-neg283.8%
distribute-neg-frac283.8%
remove-double-neg83.8%
sqr-neg83.8%
associate-+l+83.8%
sqr-neg83.8%
distribute-rgt-out83.8%
Simplified83.8%
Taylor expanded in m around 0 3.0%
Taylor expanded in k around 0 25.3%
cancel-sign-sub-inv25.3%
associate-*r*25.3%
metadata-eval25.3%
mul-1-neg25.3%
distribute-rgt1-in25.3%
metadata-eval25.3%
*-commutative25.3%
Simplified25.3%
Taylor expanded in a around 0 30.1%
Taylor expanded in k around inf 30.1%
*-commutative30.1%
Simplified30.1%
Final simplification54.2%
(FPCore (a k m) :precision binary64 (if (<= m 8.8e+22) (/ a (+ 1.0 (* k (+ k 10.0)))) (* a (+ 1.0 (* k (* k 99.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 8.8e+22) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a * (1.0 + (k * (k * 99.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 <= 8.8d+22) then
tmp = a / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = a * (1.0d0 + (k * (k * 99.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 8.8e+22) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a * (1.0 + (k * (k * 99.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 8.8e+22: tmp = a / (1.0 + (k * (k + 10.0))) else: tmp = a * (1.0 + (k * (k * 99.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 8.8e+22) tmp = Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0)))); else tmp = Float64(a * Float64(1.0 + Float64(k * Float64(k * 99.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 8.8e+22) tmp = a / (1.0 + (k * (k + 10.0))); else tmp = a * (1.0 + (k * (k * 99.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 8.8e+22], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[(1.0 + N[(k * N[(k * 99.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 8.8 \cdot 10^{+22}:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(1 + k \cdot \left(k \cdot 99\right)\right)\\
\end{array}
\end{array}
if m < 8.8e22Initial program 96.4%
associate-/l*96.4%
remove-double-neg96.4%
distribute-frac-neg296.4%
distribute-neg-frac296.4%
remove-double-neg96.4%
sqr-neg96.4%
associate-+l+96.4%
sqr-neg96.4%
distribute-rgt-out96.4%
Simplified96.4%
Taylor expanded in m around 0 62.1%
if 8.8e22 < m Initial program 83.8%
associate-/l*83.8%
remove-double-neg83.8%
distribute-frac-neg283.8%
distribute-neg-frac283.8%
remove-double-neg83.8%
sqr-neg83.8%
associate-+l+83.8%
sqr-neg83.8%
distribute-rgt-out83.8%
Simplified83.8%
Taylor expanded in m around 0 3.0%
Taylor expanded in k around 0 25.3%
cancel-sign-sub-inv25.3%
associate-*r*25.3%
metadata-eval25.3%
mul-1-neg25.3%
distribute-rgt1-in25.3%
metadata-eval25.3%
*-commutative25.3%
Simplified25.3%
Taylor expanded in a around 0 30.1%
Taylor expanded in k around inf 30.1%
*-commutative30.1%
Simplified30.1%
Final simplification52.1%
(FPCore (a k m) :precision binary64 (if (<= m 8.8e+22) (/ a (+ 1.0 (* k k))) (* a (+ 1.0 (* k (* k 99.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 8.8e+22) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a * (1.0 + (k * (k * 99.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 <= 8.8d+22) then
tmp = a / (1.0d0 + (k * k))
else
tmp = a * (1.0d0 + (k * (k * 99.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 8.8e+22) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a * (1.0 + (k * (k * 99.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 8.8e+22: tmp = a / (1.0 + (k * k)) else: tmp = a * (1.0 + (k * (k * 99.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 8.8e+22) tmp = Float64(a / Float64(1.0 + Float64(k * k))); else tmp = Float64(a * Float64(1.0 + Float64(k * Float64(k * 99.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 8.8e+22) tmp = a / (1.0 + (k * k)); else tmp = a * (1.0 + (k * (k * 99.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 8.8e+22], N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[(1.0 + N[(k * N[(k * 99.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 8.8 \cdot 10^{+22}:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(1 + k \cdot \left(k \cdot 99\right)\right)\\
\end{array}
\end{array}
if m < 8.8e22Initial program 96.4%
associate-/l*96.4%
remove-double-neg96.4%
distribute-frac-neg296.4%
distribute-neg-frac296.4%
remove-double-neg96.4%
sqr-neg96.4%
associate-+l+96.4%
sqr-neg96.4%
distribute-rgt-out96.4%
Simplified96.4%
Taylor expanded in m around 0 62.1%
Taylor expanded in k around inf 61.5%
if 8.8e22 < m Initial program 83.8%
associate-/l*83.8%
remove-double-neg83.8%
distribute-frac-neg283.8%
distribute-neg-frac283.8%
remove-double-neg83.8%
sqr-neg83.8%
associate-+l+83.8%
sqr-neg83.8%
distribute-rgt-out83.8%
Simplified83.8%
Taylor expanded in m around 0 3.0%
Taylor expanded in k around 0 25.3%
cancel-sign-sub-inv25.3%
associate-*r*25.3%
metadata-eval25.3%
mul-1-neg25.3%
distribute-rgt1-in25.3%
metadata-eval25.3%
*-commutative25.3%
Simplified25.3%
Taylor expanded in a around 0 30.1%
Taylor expanded in k around inf 30.1%
*-commutative30.1%
Simplified30.1%
(FPCore (a k m) :precision binary64 (/ a (+ 1.0 (* k k))))
double code(double a, double k, double m) {
return a / (1.0 + (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 / (1.0d0 + (k * k))
end function
public static double code(double a, double k, double m) {
return a / (1.0 + (k * k));
}
def code(a, k, m): return a / (1.0 + (k * k))
function code(a, k, m) return Float64(a / Float64(1.0 + Float64(k * k))) end
function tmp = code(a, k, m) tmp = a / (1.0 + (k * k)); end
code[a_, k_, m_] := N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{1 + k \cdot k}
\end{array}
Initial program 92.4%
associate-/l*92.4%
remove-double-neg92.4%
distribute-frac-neg292.4%
distribute-neg-frac292.4%
remove-double-neg92.4%
sqr-neg92.4%
associate-+l+92.4%
sqr-neg92.4%
distribute-rgt-out92.4%
Simplified92.4%
Taylor expanded in m around 0 43.6%
Taylor expanded in k around inf 43.3%
(FPCore (a k m) :precision binary64 (/ a (+ 1.0 (* k 10.0))))
double code(double a, double k, double m) {
return a / (1.0 + (k * 10.0));
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a / (1.0d0 + (k * 10.0d0))
end function
public static double code(double a, double k, double m) {
return a / (1.0 + (k * 10.0));
}
def code(a, k, m): return a / (1.0 + (k * 10.0))
function code(a, k, m) return Float64(a / Float64(1.0 + Float64(k * 10.0))) end
function tmp = code(a, k, m) tmp = a / (1.0 + (k * 10.0)); end
code[a_, k_, m_] := N[(a / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{1 + k \cdot 10}
\end{array}
Initial program 92.4%
associate-/l*92.4%
remove-double-neg92.4%
distribute-frac-neg292.4%
distribute-neg-frac292.4%
remove-double-neg92.4%
sqr-neg92.4%
associate-+l+92.4%
sqr-neg92.4%
distribute-rgt-out92.4%
Simplified92.4%
Taylor expanded in m around 0 43.6%
Taylor expanded in k around 0 24.0%
*-commutative79.3%
Simplified24.0%
(FPCore (a k m) :precision binary64 (* a (+ 1.0 (* k -10.0))))
double code(double a, double k, double m) {
return a * (1.0 + (k * -10.0));
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a * (1.0d0 + (k * (-10.0d0)))
end function
public static double code(double a, double k, double m) {
return a * (1.0 + (k * -10.0));
}
def code(a, k, m): return a * (1.0 + (k * -10.0))
function code(a, k, m) return Float64(a * Float64(1.0 + Float64(k * -10.0))) end
function tmp = code(a, k, m) tmp = a * (1.0 + (k * -10.0)); end
code[a_, k_, m_] := N[(a * N[(1.0 + N[(k * -10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot \left(1 + k \cdot -10\right)
\end{array}
Initial program 92.4%
associate-/l*92.4%
remove-double-neg92.4%
distribute-frac-neg292.4%
distribute-neg-frac292.4%
remove-double-neg92.4%
sqr-neg92.4%
associate-+l+92.4%
sqr-neg92.4%
distribute-rgt-out92.4%
Simplified92.4%
Taylor expanded in m around 0 43.6%
Taylor expanded in k around 0 24.6%
cancel-sign-sub-inv24.6%
associate-*r*24.6%
metadata-eval24.6%
mul-1-neg24.6%
distribute-rgt1-in24.6%
metadata-eval24.6%
*-commutative24.6%
Simplified24.6%
Taylor expanded in a around 0 25.7%
Taylor expanded in k around 0 18.6%
*-commutative18.6%
Simplified18.6%
(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 92.4%
associate-/l*92.4%
remove-double-neg92.4%
distribute-frac-neg292.4%
distribute-neg-frac292.4%
remove-double-neg92.4%
sqr-neg92.4%
associate-+l+92.4%
sqr-neg92.4%
distribute-rgt-out92.4%
Simplified92.4%
Taylor expanded in m around 0 43.6%
Taylor expanded in k around 0 18.1%
herbie shell --seed 2024150
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))