
(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 (/ (/ (* (pow k m) a) (hypot 1.0 k)) (hypot 1.0 k)))
double code(double a, double k, double m) {
return ((pow(k, m) * a) / hypot(1.0, k)) / hypot(1.0, k);
}
public static double code(double a, double k, double m) {
return ((Math.pow(k, m) * a) / Math.hypot(1.0, k)) / Math.hypot(1.0, k);
}
def code(a, k, m): return ((math.pow(k, m) * a) / math.hypot(1.0, k)) / math.hypot(1.0, k)
function code(a, k, m) return Float64(Float64(Float64((k ^ m) * a) / hypot(1.0, k)) / hypot(1.0, k)) end
function tmp = code(a, k, m) tmp = (((k ^ m) * a) / hypot(1.0, k)) / hypot(1.0, k); end
code[a_, k_, m_] := N[(N[(N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + k ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + k ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{{k}^{m} \cdot a}{\mathsf{hypot}\left(1, k\right)}}{\mathsf{hypot}\left(1, k\right)}
\end{array}
Initial 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 k around inf 91.6%
associate-*r/91.6%
*-commutative91.6%
add-sqr-sqrt91.6%
associate-/r*91.6%
hypot-1-def91.6%
hypot-1-def99.3%
Applied egg-rr99.3%
(FPCore (a k m) :precision binary64 (let* ((t_0 (/ (* (pow k m) a) (+ (+ 1.0 (* k 10.0)) (* k k))))) (if (<= t_0 INFINITY) t_0 (+ a (* a (* k (* k 99.0)))))))
double code(double a, double k, double m) {
double t_0 = (pow(k, m) * a) / ((1.0 + (k * 10.0)) + (k * k));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0;
} else {
tmp = a + (a * (k * (k * 99.0)));
}
return tmp;
}
public static double code(double a, double k, double m) {
double t_0 = (Math.pow(k, m) * a) / ((1.0 + (k * 10.0)) + (k * k));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0;
} else {
tmp = a + (a * (k * (k * 99.0)));
}
return tmp;
}
def code(a, k, m): t_0 = (math.pow(k, m) * a) / ((1.0 + (k * 10.0)) + (k * k)) tmp = 0 if t_0 <= math.inf: tmp = t_0 else: tmp = a + (a * (k * (k * 99.0))) return tmp
function code(a, k, m) t_0 = Float64(Float64((k ^ m) * a) / Float64(Float64(1.0 + Float64(k * 10.0)) + Float64(k * k))) tmp = 0.0 if (t_0 <= Inf) tmp = t_0; else tmp = Float64(a + Float64(a * Float64(k * Float64(k * 99.0)))); end return tmp end
function tmp_2 = code(a, k, m) t_0 = ((k ^ m) * a) / ((1.0 + (k * 10.0)) + (k * k)); tmp = 0.0; if (t_0 <= Inf) tmp = t_0; else tmp = a + (a * (k * (k * 99.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision] / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], t$95$0, N[(a + N[(a * N[(k * N[(k * 99.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{k}^{m} \cdot a}{\left(1 + k \cdot 10\right) + k \cdot k}\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;a + a \cdot \left(k \cdot \left(k \cdot 99\right)\right)\\
\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))) < +inf.0Initial program 98.8%
if +inf.0 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 0.0%
associate-/l*0.0%
remove-double-neg0.0%
distribute-frac-neg20.0%
distribute-neg-frac20.0%
remove-double-neg0.0%
sqr-neg0.0%
associate-+l+0.0%
sqr-neg0.0%
distribute-rgt-out0.0%
Simplified0.0%
Taylor expanded in m around 0 1.6%
Taylor expanded in k around 0 83.1%
Taylor expanded in a around 0 100.0%
Taylor expanded in k around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification98.9%
(FPCore (a k m) :precision binary64 (let* ((t_0 (* (pow k m) a))) (if (<= k 0.013) t_0 (/ (/ t_0 (hypot 1.0 k)) k))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (k <= 0.013) {
tmp = t_0;
} else {
tmp = (t_0 / hypot(1.0, k)) / k;
}
return tmp;
}
public static double code(double a, double k, double m) {
double t_0 = Math.pow(k, m) * a;
double tmp;
if (k <= 0.013) {
tmp = t_0;
} else {
tmp = (t_0 / Math.hypot(1.0, k)) / k;
}
return tmp;
}
def code(a, k, m): t_0 = math.pow(k, m) * a tmp = 0 if k <= 0.013: tmp = t_0 else: tmp = (t_0 / math.hypot(1.0, k)) / k return tmp
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (k <= 0.013) tmp = t_0; else tmp = Float64(Float64(t_0 / hypot(1.0, k)) / k); end return tmp end
function tmp_2 = code(a, k, m) t_0 = (k ^ m) * a; tmp = 0.0; if (k <= 0.013) tmp = t_0; else tmp = (t_0 / hypot(1.0, k)) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[k, 0.013], t$95$0, N[(N[(t$95$0 / N[Sqrt[1.0 ^ 2 + k ^ 2], $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;k \leq 0.013:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{\mathsf{hypot}\left(1, k\right)}}{k}\\
\end{array}
\end{array}
if k < 0.0129999999999999994Initial 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 k around 0 99.4%
if 0.0129999999999999994 < k Initial program 84.6%
associate-/l*84.6%
remove-double-neg84.6%
distribute-frac-neg284.6%
distribute-neg-frac284.6%
remove-double-neg84.6%
sqr-neg84.6%
associate-+l+84.6%
sqr-neg84.6%
distribute-rgt-out84.6%
Simplified84.6%
Taylor expanded in k around inf 83.8%
associate-*r/83.8%
*-commutative83.8%
add-sqr-sqrt83.8%
associate-/r*83.8%
hypot-1-def83.8%
hypot-1-def99.1%
Applied egg-rr99.1%
Taylor expanded in k around inf 99.1%
Final simplification99.3%
(FPCore (a k m) :precision binary64 (if (<= m 3.3) (* a (/ (pow k m) (+ 1.0 (* k (+ k 10.0))))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.3) {
tmp = a * (pow(k, m) / (1.0 + (k * (k + 10.0))));
} else {
tmp = pow(k, m) * 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 (m <= 3.3d0) then
tmp = a * ((k ** m) / (1.0d0 + (k * (k + 10.0d0))))
else
tmp = (k ** m) * a
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) / (1.0 + (k * (k + 10.0))));
} else {
tmp = Math.pow(k, m) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 3.3: tmp = a * (math.pow(k, m) / (1.0 + (k * (k + 10.0)))) else: tmp = math.pow(k, m) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 3.3) tmp = Float64(a * Float64((k ^ m) / Float64(1.0 + Float64(k * Float64(k + 10.0))))); else tmp = Float64((k ^ m) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 3.3) tmp = a * ((k ^ m) / (1.0 + (k * (k + 10.0)))); else tmp = (k ^ m) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 3.3], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.3:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 3.2999999999999998Initial program 98.4%
associate-/l*98.4%
remove-double-neg98.4%
distribute-frac-neg298.4%
distribute-neg-frac298.4%
remove-double-neg98.4%
sqr-neg98.4%
associate-+l+98.4%
sqr-neg98.4%
distribute-rgt-out98.4%
Simplified98.4%
if 3.2999999999999998 < m Initial program 77.3%
associate-/l*77.3%
remove-double-neg77.3%
distribute-frac-neg277.3%
distribute-neg-frac277.3%
remove-double-neg77.3%
sqr-neg77.3%
associate-+l+77.3%
sqr-neg77.3%
distribute-rgt-out77.3%
Simplified77.3%
Taylor expanded in k around 0 100.0%
Final simplification98.9%
(FPCore (a k m) :precision binary64 (if (<= m 4.5) (* a (/ (pow k m) (+ 1.0 (* k k)))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 4.5) {
tmp = a * (pow(k, m) / (1.0 + (k * k)));
} else {
tmp = pow(k, m) * 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 (m <= 4.5d0) then
tmp = a * ((k ** m) / (1.0d0 + (k * k)))
else
tmp = (k ** m) * a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 4.5) {
tmp = a * (Math.pow(k, m) / (1.0 + (k * k)));
} else {
tmp = Math.pow(k, m) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 4.5: tmp = a * (math.pow(k, m) / (1.0 + (k * k))) else: tmp = math.pow(k, m) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 4.5) tmp = Float64(a * Float64((k ^ m) / Float64(1.0 + Float64(k * k)))); else tmp = Float64((k ^ m) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 4.5) tmp = a * ((k ^ m) / (1.0 + (k * k))); else tmp = (k ^ m) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 4.5], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 4.5:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 4.5Initial program 98.4%
associate-/l*98.4%
remove-double-neg98.4%
distribute-frac-neg298.4%
distribute-neg-frac298.4%
remove-double-neg98.4%
sqr-neg98.4%
associate-+l+98.4%
sqr-neg98.4%
distribute-rgt-out98.4%
Simplified98.4%
Taylor expanded in k around inf 97.4%
if 4.5 < m Initial program 77.3%
associate-/l*77.3%
remove-double-neg77.3%
distribute-frac-neg277.3%
distribute-neg-frac277.3%
remove-double-neg77.3%
sqr-neg77.3%
associate-+l+77.3%
sqr-neg77.3%
distribute-rgt-out77.3%
Simplified77.3%
Taylor expanded in k around 0 100.0%
Final simplification98.2%
(FPCore (a k m) :precision binary64 (if (or (<= m -2.8e-12) (not (<= m 0.00355))) (* (pow k m) a) (/ a (+ 1.0 (* k (+ k 10.0))))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -2.8e-12) || !(m <= 0.00355)) {
tmp = pow(k, m) * a;
} 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 <= (-2.8d-12)) .or. (.not. (m <= 0.00355d0))) then
tmp = (k ** m) * a
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 <= -2.8e-12) || !(m <= 0.00355)) {
tmp = Math.pow(k, m) * a;
} else {
tmp = a / (1.0 + (k * (k + 10.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if (m <= -2.8e-12) or not (m <= 0.00355): tmp = math.pow(k, m) * a else: tmp = a / (1.0 + (k * (k + 10.0))) return tmp
function code(a, k, m) tmp = 0.0 if ((m <= -2.8e-12) || !(m <= 0.00355)) tmp = Float64((k ^ m) * a); 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 <= -2.8e-12) || ~((m <= 0.00355))) tmp = (k ^ m) * a; else tmp = a / (1.0 + (k * (k + 10.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[m, -2.8e-12], N[Not[LessEqual[m, 0.00355]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $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 -2.8 \cdot 10^{-12} \lor \neg \left(m \leq 0.00355\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -2.8000000000000002e-12 or 0.0035500000000000002 < m Initial program 89.9%
associate-/l*89.9%
remove-double-neg89.9%
distribute-frac-neg289.9%
distribute-neg-frac289.9%
remove-double-neg89.9%
sqr-neg89.9%
associate-+l+89.9%
sqr-neg89.9%
distribute-rgt-out89.9%
Simplified89.9%
Taylor expanded in k around 0 100.0%
if -2.8000000000000002e-12 < m < 0.0035500000000000002Initial 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 m around 0 96.0%
Final simplification98.6%
(FPCore (a k m) :precision binary64 (if (<= m 2.2) (/ a (+ 1.0 (* k (+ k 10.0)))) (+ a (* a (* k (* k 99.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 2.2) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (a * (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 <= 2.2d0) then
tmp = a / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = a + (a * (k * (k * 99.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 2.2) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (a * (k * (k * 99.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 2.2: tmp = a / (1.0 + (k * (k + 10.0))) else: tmp = a + (a * (k * (k * 99.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 2.2) tmp = Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0)))); else tmp = Float64(a + Float64(a * Float64(k * Float64(k * 99.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 2.2) tmp = a / (1.0 + (k * (k + 10.0))); else tmp = a + (a * (k * (k * 99.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 2.2], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(a * N[(k * N[(k * 99.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.2:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a + a \cdot \left(k \cdot \left(k \cdot 99\right)\right)\\
\end{array}
\end{array}
if m < 2.2000000000000002Initial program 98.4%
associate-/l*98.4%
remove-double-neg98.4%
distribute-frac-neg298.4%
distribute-neg-frac298.4%
remove-double-neg98.4%
sqr-neg98.4%
associate-+l+98.4%
sqr-neg98.4%
distribute-rgt-out98.4%
Simplified98.4%
Taylor expanded in m around 0 66.6%
if 2.2000000000000002 < m Initial program 77.3%
associate-/l*77.3%
remove-double-neg77.3%
distribute-frac-neg277.3%
distribute-neg-frac277.3%
remove-double-neg77.3%
sqr-neg77.3%
associate-+l+77.3%
sqr-neg77.3%
distribute-rgt-out77.3%
Simplified77.3%
Taylor expanded in m around 0 2.9%
Taylor expanded in k around 0 26.9%
Taylor expanded in a around 0 30.8%
Taylor expanded in k around inf 30.8%
*-commutative30.8%
Simplified30.8%
Final simplification56.1%
(FPCore (a k m) :precision binary64 (if (<= m 2.2) (/ a (+ 1.0 (* k k))) (+ a (* a (* k (* k 99.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 2.2) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a + (a * (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 <= 2.2d0) then
tmp = a / (1.0d0 + (k * k))
else
tmp = a + (a * (k * (k * 99.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 2.2) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a + (a * (k * (k * 99.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 2.2: tmp = a / (1.0 + (k * k)) else: tmp = a + (a * (k * (k * 99.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 2.2) tmp = Float64(a / Float64(1.0 + Float64(k * k))); else tmp = Float64(a + Float64(a * Float64(k * Float64(k * 99.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 2.2) tmp = a / (1.0 + (k * k)); else tmp = a + (a * (k * (k * 99.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 2.2], N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(a * N[(k * N[(k * 99.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.2:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a + a \cdot \left(k \cdot \left(k \cdot 99\right)\right)\\
\end{array}
\end{array}
if m < 2.2000000000000002Initial program 98.4%
associate-/l*98.4%
remove-double-neg98.4%
distribute-frac-neg298.4%
distribute-neg-frac298.4%
remove-double-neg98.4%
sqr-neg98.4%
associate-+l+98.4%
sqr-neg98.4%
distribute-rgt-out98.4%
Simplified98.4%
Taylor expanded in m around 0 66.6%
Taylor expanded in k around inf 65.7%
if 2.2000000000000002 < m Initial program 77.3%
associate-/l*77.3%
remove-double-neg77.3%
distribute-frac-neg277.3%
distribute-neg-frac277.3%
remove-double-neg77.3%
sqr-neg77.3%
associate-+l+77.3%
sqr-neg77.3%
distribute-rgt-out77.3%
Simplified77.3%
Taylor expanded in m around 0 2.9%
Taylor expanded in k around 0 26.9%
Taylor expanded in a around 0 30.8%
Taylor expanded in k around inf 30.8%
*-commutative30.8%
Simplified30.8%
(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.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 47.9%
Taylor expanded in k around inf 47.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.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 47.9%
Taylor expanded in k around 0 30.8%
*-commutative30.8%
Simplified30.8%
(FPCore (a k m) :precision binary64 (+ a (* -10.0 (* k a))))
double code(double a, double k, double m) {
return a + (-10.0 * (k * 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 + ((-10.0d0) * (k * a))
end function
public static double code(double a, double k, double m) {
return a + (-10.0 * (k * a));
}
def code(a, k, m): return a + (-10.0 * (k * a))
function code(a, k, m) return Float64(a + Float64(-10.0 * Float64(k * a))) end
function tmp = code(a, k, m) tmp = a + (-10.0 * (k * a)); end
code[a_, k_, m_] := N[(a + N[(-10.0 * N[(k * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + -10 \cdot \left(k \cdot a\right)
\end{array}
Initial 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 47.9%
Taylor expanded in k around 0 20.0%
Final simplification20.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 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 47.9%
Taylor expanded in k around 0 19.5%
herbie shell --seed 2024185
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))