
(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))))
(if (<= (/ t_0 (+ (+ 1.0 (* k 10.0)) (* k k))) 4e+180)
(* (/ (pow k m) (hypot 1.0 k)) (/ a (hypot 1.0 k)))
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))) <= 4e+180) {
tmp = (pow(k, m) / hypot(1.0, k)) * (a / hypot(1.0, k));
} else {
tmp = t_0;
}
return tmp;
}
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))) <= 4e+180) {
tmp = (Math.pow(k, m) / Math.hypot(1.0, k)) * (a / Math.hypot(1.0, k));
} 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))) <= 4e+180: tmp = (math.pow(k, m) / math.hypot(1.0, k)) * (a / math.hypot(1.0, k)) 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))) <= 4e+180) tmp = Float64(Float64((k ^ m) / hypot(1.0, k)) * Float64(a / hypot(1.0, k))); 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))) <= 4e+180) tmp = ((k ^ m) / hypot(1.0, k)) * (a / hypot(1.0, k)); 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], 4e+180], N[(N[(N[Power[k, m], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + k ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[1.0 ^ 2 + k ^ 2], $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 4 \cdot 10^{+180}:\\
\;\;\;\;\frac{{k}^{m}}{\mathsf{hypot}\left(1, k\right)} \cdot \frac{a}{\mathsf{hypot}\left(1, k\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))) < 4e180Initial program 96.6%
*-commutative96.6%
Simplified96.6%
Taylor expanded in k around 0 95.8%
*-commutative95.8%
add-sqr-sqrt95.8%
times-frac95.8%
hypot-1-def95.8%
hypot-1-def99.2%
Applied egg-rr99.2%
if 4e180 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 54.0%
associate-/l*54.0%
remove-double-neg54.0%
distribute-frac-neg254.0%
distribute-neg-frac254.0%
remove-double-neg54.0%
sqr-neg54.0%
associate-+l+54.0%
sqr-neg54.0%
distribute-rgt-out54.0%
Simplified54.0%
Taylor expanded in k around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification99.3%
(FPCore (a k m) :precision binary64 (let* ((t_0 (* a (pow k m))) (t_1 (/ t_0 (+ (+ 1.0 (* k 10.0)) (* k k))))) (if (<= t_1 4e+180) t_1 t_0)))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double t_1 = t_0 / ((1.0 + (k * 10.0)) + (k * k));
double tmp;
if (t_1 <= 4e+180) {
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 / ((1.0d0 + (k * 10.0d0)) + (k * k))
if (t_1 <= 4d+180) 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 / ((1.0 + (k * 10.0)) + (k * k));
double tmp;
if (t_1 <= 4e+180) {
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 / ((1.0 + (k * 10.0)) + (k * k)) tmp = 0 if t_1 <= 4e+180: 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(1.0 + Float64(k * 10.0)) + Float64(k * k))) tmp = 0.0 if (t_1 <= 4e+180) 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 / ((1.0 + (k * 10.0)) + (k * k)); tmp = 0.0; if (t_1 <= 4e+180) 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[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 4e+180], t$95$1, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
t_1 := \frac{t\_0}{\left(1 + k \cdot 10\right) + k \cdot k}\\
\mathbf{if}\;t\_1 \leq 4 \cdot 10^{+180}:\\
\;\;\;\;t\_1\\
\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))) < 4e180Initial program 96.6%
if 4e180 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 54.0%
associate-/l*54.0%
remove-double-neg54.0%
distribute-frac-neg254.0%
distribute-neg-frac254.0%
remove-double-neg54.0%
sqr-neg54.0%
associate-+l+54.0%
sqr-neg54.0%
distribute-rgt-out54.0%
Simplified54.0%
Taylor expanded in k around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification97.3%
(FPCore (a k m) :precision binary64 (if (<= m 3.4) (* a (/ (pow k m) (+ 1.0 (* k (+ k 10.0))))) (* a (pow k m))))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.4) {
tmp = a * (pow(k, m) / (1.0 + (k * (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 <= 3.4d0) then
tmp = a * ((k ** m) / (1.0d0 + (k * (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 <= 3.4) {
tmp = a * (Math.pow(k, m) / (1.0 + (k * (k + 10.0))));
} else {
tmp = a * Math.pow(k, m);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 3.4: tmp = a * (math.pow(k, m) / (1.0 + (k * (k + 10.0)))) else: tmp = a * math.pow(k, m) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 3.4) tmp = Float64(a * Float64((k ^ m) / Float64(1.0 + Float64(k * 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 <= 3.4) tmp = a * ((k ^ m) / (1.0 + (k * (k + 10.0)))); else tmp = a * (k ^ m); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 3.4], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.4:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a \cdot {k}^{m}\\
\end{array}
\end{array}
if m < 3.39999999999999991Initial program 96.0%
associate-/l*95.9%
remove-double-neg95.9%
distribute-frac-neg295.9%
distribute-neg-frac295.9%
remove-double-neg95.9%
sqr-neg95.9%
associate-+l+95.9%
sqr-neg95.9%
distribute-rgt-out95.9%
Simplified95.9%
if 3.39999999999999991 < m Initial program 72.6%
associate-/l*72.6%
remove-double-neg72.6%
distribute-frac-neg272.6%
distribute-neg-frac272.6%
remove-double-neg72.6%
sqr-neg72.6%
associate-+l+72.6%
sqr-neg72.6%
distribute-rgt-out72.6%
Simplified72.6%
Taylor expanded in k around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification97.3%
(FPCore (a k m) :precision binary64 (let* ((t_0 (* a (pow k m)))) (if (<= m 0.002) (/ t_0 (+ 1.0 (* k k))) t_0)))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double tmp;
if (m <= 0.002) {
tmp = t_0 / (1.0 + (k * k));
} 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 (m <= 0.002d0) then
tmp = t_0 / (1.0d0 + (k * k))
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 (m <= 0.002) {
tmp = t_0 / (1.0 + (k * k));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a * math.pow(k, m) tmp = 0 if m <= 0.002: tmp = t_0 / (1.0 + (k * k)) else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a * (k ^ m)) tmp = 0.0 if (m <= 0.002) tmp = Float64(t_0 / Float64(1.0 + Float64(k * k))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a * (k ^ m); tmp = 0.0; if (m <= 0.002) tmp = t_0 / (1.0 + (k * k)); 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[m, 0.002], N[(t$95$0 / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;m \leq 0.002:\\
\;\;\;\;\frac{t\_0}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < 2e-3Initial program 96.0%
*-commutative96.0%
Simplified96.0%
Taylor expanded in k around 0 95.0%
if 2e-3 < m Initial program 72.6%
associate-/l*72.6%
remove-double-neg72.6%
distribute-frac-neg272.6%
distribute-neg-frac272.6%
remove-double-neg72.6%
sqr-neg72.6%
associate-+l+72.6%
sqr-neg72.6%
distribute-rgt-out72.6%
Simplified72.6%
Taylor expanded in k around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification96.6%
(FPCore (a k m) :precision binary64 (if (or (<= m -4.2e-15) (not (<= m 2.9e-12))) (* a (pow k m)) (/ a (+ 1.0 (* k (+ k 10.0))))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -4.2e-15) || !(m <= 2.9e-12)) {
tmp = a * pow(k, m);
} else {
tmp = a / (1.0 + (k * (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 <= (-4.2d-15)) .or. (.not. (m <= 2.9d-12))) then
tmp = a * (k ** m)
else
tmp = a / (1.0d0 + (k * (k + 10.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if ((m <= -4.2e-15) || !(m <= 2.9e-12)) {
tmp = a * Math.pow(k, m);
} else {
tmp = a / (1.0 + (k * (k + 10.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if (m <= -4.2e-15) or not (m <= 2.9e-12): tmp = a * math.pow(k, m) else: tmp = a / (1.0 + (k * (k + 10.0))) return tmp
function code(a, k, m) tmp = 0.0 if ((m <= -4.2e-15) || !(m <= 2.9e-12)) tmp = Float64(a * (k ^ m)); else tmp = Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((m <= -4.2e-15) || ~((m <= 2.9e-12))) tmp = a * (k ^ m); else tmp = a / (1.0 + (k * (k + 10.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[m, -4.2e-15], N[Not[LessEqual[m, 2.9e-12]], $MachinePrecision]], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -4.2 \cdot 10^{-15} \lor \neg \left(m \leq 2.9 \cdot 10^{-12}\right):\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -4.19999999999999962e-15 or 2.9000000000000002e-12 < m Initial program 86.2%
associate-/l*86.2%
remove-double-neg86.2%
distribute-frac-neg286.2%
distribute-neg-frac286.2%
remove-double-neg86.2%
sqr-neg86.2%
associate-+l+86.2%
sqr-neg86.2%
distribute-rgt-out86.2%
Simplified86.2%
Taylor expanded in k around 0 99.4%
*-commutative99.4%
Simplified99.4%
if -4.19999999999999962e-15 < m < 2.9000000000000002e-12Initial program 92.2%
associate-/l*92.2%
remove-double-neg92.2%
distribute-frac-neg292.2%
distribute-neg-frac292.2%
remove-double-neg92.2%
sqr-neg92.2%
associate-+l+92.2%
sqr-neg92.2%
distribute-rgt-out92.2%
Simplified92.2%
Taylor expanded in m around 0 92.0%
Final simplification96.8%
(FPCore (a k m) :precision binary64 (if (<= m 1.75) (/ a (+ 1.0 (* k (+ k 10.0)))) (+ a (* a (* k (- (* k 99.0) 10.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.75) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (a * (k * ((k * 99.0) - 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.75d0) then
tmp = a / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = a + (a * (k * ((k * 99.0d0) - 10.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1.75) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (a * (k * ((k * 99.0) - 10.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1.75: tmp = a / (1.0 + (k * (k + 10.0))) else: tmp = a + (a * (k * ((k * 99.0) - 10.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1.75) tmp = Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0)))); else tmp = Float64(a + Float64(a * Float64(k * Float64(Float64(k * 99.0) - 10.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1.75) tmp = a / (1.0 + (k * (k + 10.0))); else tmp = a + (a * (k * ((k * 99.0) - 10.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1.75], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(a * N[(k * N[(N[(k * 99.0), $MachinePrecision] - 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.75:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a + a \cdot \left(k \cdot \left(k \cdot 99 - 10\right)\right)\\
\end{array}
\end{array}
if m < 1.75Initial program 96.0%
associate-/l*95.9%
remove-double-neg95.9%
distribute-frac-neg295.9%
distribute-neg-frac295.9%
remove-double-neg95.9%
sqr-neg95.9%
associate-+l+95.9%
sqr-neg95.9%
distribute-rgt-out95.9%
Simplified95.9%
Taylor expanded in m around 0 70.3%
if 1.75 < m Initial program 72.6%
associate-/l*72.6%
remove-double-neg72.6%
distribute-frac-neg272.6%
distribute-neg-frac272.6%
remove-double-neg72.6%
sqr-neg72.6%
associate-+l+72.6%
sqr-neg72.6%
distribute-rgt-out72.6%
Simplified72.6%
Taylor expanded in m around 0 3.2%
Taylor expanded in k around 0 30.7%
cancel-sign-sub-inv30.7%
metadata-eval30.7%
mul-1-neg30.7%
distribute-rgt1-in30.7%
metadata-eval30.7%
*-commutative30.7%
Simplified30.7%
Taylor expanded in k around 0 30.7%
Taylor expanded in a around 0 36.2%
Final simplification59.1%
(FPCore (a k m) :precision binary64 (if (<= m 2.3) (/ a (+ 1.0 (* k k))) (+ a (* k (* a (* k 99.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 2.3) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a + (k * (a * (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 <= 2.3d0) then
tmp = a / (1.0d0 + (k * k))
else
tmp = a + (k * (a * (k * 99.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 2.3) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a + (k * (a * (k * 99.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 2.3: tmp = a / (1.0 + (k * k)) else: tmp = a + (k * (a * (k * 99.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 2.3) tmp = Float64(a / Float64(1.0 + Float64(k * k))); else tmp = Float64(a + Float64(k * Float64(a * Float64(k * 99.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 2.3) tmp = a / (1.0 + (k * k)); else tmp = a + (k * (a * (k * 99.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 2.3], N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(k * N[(a * N[(k * 99.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.3:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a + k \cdot \left(a \cdot \left(k \cdot 99\right)\right)\\
\end{array}
\end{array}
if m < 2.2999999999999998Initial program 96.0%
*-commutative96.0%
Simplified96.0%
Taylor expanded in k around 0 95.0%
Taylor expanded in m around 0 69.3%
if 2.2999999999999998 < m Initial program 72.6%
associate-/l*72.6%
remove-double-neg72.6%
distribute-frac-neg272.6%
distribute-neg-frac272.6%
remove-double-neg72.6%
sqr-neg72.6%
associate-+l+72.6%
sqr-neg72.6%
distribute-rgt-out72.6%
Simplified72.6%
Taylor expanded in m around 0 3.2%
Taylor expanded in k around 0 30.7%
cancel-sign-sub-inv30.7%
metadata-eval30.7%
mul-1-neg30.7%
distribute-rgt1-in30.7%
metadata-eval30.7%
*-commutative30.7%
Simplified30.7%
Taylor expanded in k around inf 30.7%
*-commutative30.7%
associate-*l*30.7%
Simplified30.7%
Final simplification56.6%
(FPCore (a k m) :precision binary64 (if (<= m 1.95) (/ a (+ 1.0 (* k (+ k 10.0)))) (+ a (* k (* a (* k 99.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.95) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (k * (a * (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 <= 1.95d0) then
tmp = a / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = a + (k * (a * (k * 99.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1.95) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (k * (a * (k * 99.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1.95: tmp = a / (1.0 + (k * (k + 10.0))) else: tmp = a + (k * (a * (k * 99.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1.95) tmp = Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0)))); else tmp = Float64(a + Float64(k * Float64(a * Float64(k * 99.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1.95) tmp = a / (1.0 + (k * (k + 10.0))); else tmp = a + (k * (a * (k * 99.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1.95], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(k * N[(a * N[(k * 99.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.95:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a + k \cdot \left(a \cdot \left(k \cdot 99\right)\right)\\
\end{array}
\end{array}
if m < 1.94999999999999996Initial program 96.0%
associate-/l*95.9%
remove-double-neg95.9%
distribute-frac-neg295.9%
distribute-neg-frac295.9%
remove-double-neg95.9%
sqr-neg95.9%
associate-+l+95.9%
sqr-neg95.9%
distribute-rgt-out95.9%
Simplified95.9%
Taylor expanded in m around 0 70.3%
if 1.94999999999999996 < m Initial program 72.6%
associate-/l*72.6%
remove-double-neg72.6%
distribute-frac-neg272.6%
distribute-neg-frac272.6%
remove-double-neg72.6%
sqr-neg72.6%
associate-+l+72.6%
sqr-neg72.6%
distribute-rgt-out72.6%
Simplified72.6%
Taylor expanded in m around 0 3.2%
Taylor expanded in k around 0 30.7%
cancel-sign-sub-inv30.7%
metadata-eval30.7%
mul-1-neg30.7%
distribute-rgt1-in30.7%
metadata-eval30.7%
*-commutative30.7%
Simplified30.7%
Taylor expanded in k around inf 30.7%
*-commutative30.7%
associate-*l*30.7%
Simplified30.7%
Final simplification57.3%
(FPCore (a k m) :precision binary64 (if (<= m 3.3e+22) (/ a (+ 1.0 (* k 10.0))) (* -10.0 (* a k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.3e+22) {
tmp = a / (1.0 + (k * 10.0));
} else {
tmp = -10.0 * (a * 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 (m <= 3.3d+22) then
tmp = a / (1.0d0 + (k * 10.0d0))
else
tmp = (-10.0d0) * (a * k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 3.3e+22) {
tmp = a / (1.0 + (k * 10.0));
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 3.3e+22: tmp = a / (1.0 + (k * 10.0)) else: tmp = -10.0 * (a * k) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 3.3e+22) tmp = Float64(a / Float64(1.0 + Float64(k * 10.0))); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 3.3e+22) tmp = a / (1.0 + (k * 10.0)); else tmp = -10.0 * (a * k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 3.3e+22], N[(a / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.3 \cdot 10^{+22}:\\
\;\;\;\;\frac{a}{1 + k \cdot 10}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < 3.2999999999999998e22Initial program 96.0%
associate-/l*96.0%
remove-double-neg96.0%
distribute-frac-neg296.0%
distribute-neg-frac296.0%
remove-double-neg96.0%
sqr-neg96.0%
associate-+l+96.0%
sqr-neg96.0%
distribute-rgt-out96.0%
Simplified96.0%
Taylor expanded in k around 0 83.0%
*-commutative83.0%
Simplified83.0%
Taylor expanded in m around 0 45.8%
if 3.2999999999999998e22 < m 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 m around 0 3.2%
Taylor expanded in k around 0 10.0%
Taylor expanded in k around inf 23.9%
Final simplification38.7%
(FPCore (a k m) :precision binary64 (if (<= m 3.3e+22) (/ a (+ 1.0 (* k k))) (* -10.0 (* a k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.3e+22) {
tmp = a / (1.0 + (k * k));
} else {
tmp = -10.0 * (a * 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 (m <= 3.3d+22) then
tmp = a / (1.0d0 + (k * k))
else
tmp = (-10.0d0) * (a * k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 3.3e+22) {
tmp = a / (1.0 + (k * k));
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 3.3e+22: tmp = a / (1.0 + (k * k)) else: tmp = -10.0 * (a * k) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 3.3e+22) tmp = Float64(a / Float64(1.0 + Float64(k * k))); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 3.3e+22) tmp = a / (1.0 + (k * k)); else tmp = -10.0 * (a * k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 3.3e+22], N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.3 \cdot 10^{+22}:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < 3.2999999999999998e22Initial program 96.0%
*-commutative96.0%
Simplified96.0%
Taylor expanded in k around 0 95.0%
Taylor expanded in m around 0 68.9%
if 3.2999999999999998e22 < m 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 m around 0 3.2%
Taylor expanded in k around 0 10.0%
Taylor expanded in k around inf 23.9%
Final simplification54.3%
(FPCore (a k m) :precision binary64 (if (<= m 3.6e+23) a (* -10.0 (* a k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.6e+23) {
tmp = a;
} else {
tmp = -10.0 * (a * 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 (m <= 3.6d+23) then
tmp = a
else
tmp = (-10.0d0) * (a * k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 3.6e+23) {
tmp = a;
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 3.6e+23: tmp = a else: tmp = -10.0 * (a * k) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 3.6e+23) tmp = a; else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 3.6e+23) tmp = a; else tmp = -10.0 * (a * k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 3.6e+23], a, N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.6 \cdot 10^{+23}:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < 3.5999999999999998e23Initial program 96.0%
associate-/l*96.0%
remove-double-neg96.0%
distribute-frac-neg296.0%
distribute-neg-frac296.0%
remove-double-neg96.0%
sqr-neg96.0%
associate-+l+96.0%
sqr-neg96.0%
distribute-rgt-out96.0%
Simplified96.0%
Taylor expanded in k around 0 76.9%
*-commutative76.9%
Simplified76.9%
Taylor expanded in m around 0 32.4%
if 3.5999999999999998e23 < m 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 m around 0 3.2%
Taylor expanded in k around 0 10.0%
Taylor expanded in k around inf 23.9%
Final simplification29.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 88.3%
associate-/l*88.3%
remove-double-neg88.3%
distribute-frac-neg288.3%
distribute-neg-frac288.3%
remove-double-neg88.3%
sqr-neg88.3%
associate-+l+88.3%
sqr-neg88.3%
distribute-rgt-out88.3%
Simplified88.3%
Taylor expanded in k around 0 84.4%
*-commutative84.4%
Simplified84.4%
Taylor expanded in m around 0 23.2%
Final simplification23.2%
herbie shell --seed 2024072
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))