
(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 10 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))) 1e+246)
(* a (/ (pow k m) (fma k (+ k 10.0) 1.0)))
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))) <= 1e+246) {
tmp = a * (pow(k, m) / fma(k, (k + 10.0), 1.0));
} 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))) <= 1e+246) tmp = Float64(a * Float64((k ^ m) / fma(k, Float64(k + 10.0), 1.0))); else tmp = t_0; end return 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], 1e+246], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(k * N[(k + 10.0), $MachinePrecision] + 1.0), $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 10^{+246}:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{\mathsf{fma}\left(k, k + 10, 1\right)}\\
\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.00000000000000007e246Initial program 98.5%
associate-*r/98.5%
associate-+l+98.5%
+-commutative98.5%
distribute-rgt-out98.6%
fma-def98.6%
+-commutative98.6%
Simplified98.6%
if 1.00000000000000007e246 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k))) Initial program 59.6%
associate-*r/59.6%
associate-+l+59.6%
+-commutative59.6%
distribute-rgt-out59.6%
fma-def59.6%
+-commutative59.6%
Simplified59.6%
Taylor expanded in k around 0 63.5%
exp-to-pow100.0%
Simplified100.0%
Final simplification98.9%
(FPCore (a k m) :precision binary64 (let* ((t_0 (* a (pow k m)))) (if (<= m 3.8e-26) (/ t_0 (+ (+ 1.0 (* k 10.0)) (* k k))) t_0)))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double tmp;
if (m <= 3.8e-26) {
tmp = t_0 / ((1.0 + (k * 10.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 <= 3.8d-26) then
tmp = t_0 / ((1.0d0 + (k * 10.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 <= 3.8e-26) {
tmp = t_0 / ((1.0 + (k * 10.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 <= 3.8e-26: tmp = t_0 / ((1.0 + (k * 10.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 <= 3.8e-26) tmp = Float64(t_0 / Float64(Float64(1.0 + Float64(k * 10.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 <= 3.8e-26) tmp = t_0 / ((1.0 + (k * 10.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, 3.8e-26], N[(t$95$0 / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + 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 3.8 \cdot 10^{-26}:\\
\;\;\;\;\frac{t_0}{\left(1 + k \cdot 10\right) + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if m < 3.80000000000000015e-26Initial program 98.1%
if 3.80000000000000015e-26 < m Initial program 78.1%
associate-*r/78.1%
associate-+l+78.1%
+-commutative78.1%
distribute-rgt-out78.1%
fma-def78.1%
+-commutative78.1%
Simplified78.1%
Taylor expanded in k around 0 57.3%
exp-to-pow100.0%
Simplified100.0%
Final simplification98.8%
(FPCore (a k m) :precision binary64 (if (or (<= m -5.4e-11) (not (<= m 3.8e-26))) (* a (pow k m)) (* a (/ 1.0 (+ 1.0 (* k (+ k 10.0)))))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -5.4e-11) || !(m <= 3.8e-26)) {
tmp = a * pow(k, m);
} else {
tmp = a * (1.0 / (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 <= (-5.4d-11)) .or. (.not. (m <= 3.8d-26))) then
tmp = a * (k ** m)
else
tmp = a * (1.0d0 / (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 <= -5.4e-11) || !(m <= 3.8e-26)) {
tmp = a * Math.pow(k, m);
} else {
tmp = a * (1.0 / (1.0 + (k * (k + 10.0))));
}
return tmp;
}
def code(a, k, m): tmp = 0 if (m <= -5.4e-11) or not (m <= 3.8e-26): tmp = a * math.pow(k, m) else: tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))) return tmp
function code(a, k, m) tmp = 0.0 if ((m <= -5.4e-11) || !(m <= 3.8e-26)) tmp = Float64(a * (k ^ m)); else tmp = Float64(a * Float64(1.0 / 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 <= -5.4e-11) || ~((m <= 3.8e-26))) tmp = a * (k ^ m); else tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[m, -5.4e-11], N[Not[LessEqual[m, 3.8e-26]], $MachinePrecision]], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision], N[(a * N[(1.0 / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -5.4 \cdot 10^{-11} \lor \neg \left(m \leq 3.8 \cdot 10^{-26}\right):\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \frac{1}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -5.40000000000000009e-11 or 3.80000000000000015e-26 < m Initial program 86.9%
associate-*r/86.9%
associate-+l+86.9%
+-commutative86.9%
distribute-rgt-out86.9%
fma-def86.9%
+-commutative86.9%
Simplified86.9%
Taylor expanded in k around 0 57.5%
exp-to-pow100.0%
Simplified100.0%
if -5.40000000000000009e-11 < m < 3.80000000000000015e-26Initial program 96.9%
associate-*r/96.9%
associate-+l+96.9%
+-commutative96.9%
distribute-rgt-out96.9%
fma-def96.9%
+-commutative96.9%
Simplified96.9%
Taylor expanded in m around 0 96.9%
Final simplification98.9%
(FPCore (a k m) :precision binary64 (if (<= m -0.066) (/ a (* k k)) (* a (/ 1.0 (+ 1.0 (* k (+ k 10.0)))))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.066) {
tmp = a / (k * k);
} else {
tmp = a * (1.0 / (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 <= (-0.066d0)) then
tmp = a / (k * k)
else
tmp = a * (1.0d0 / (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 <= -0.066) {
tmp = a / (k * k);
} else {
tmp = a * (1.0 / (1.0 + (k * (k + 10.0))));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.066: tmp = a / (k * k) else: tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.066) tmp = Float64(a / Float64(k * k)); else tmp = Float64(a * Float64(1.0 / 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 <= -0.066) tmp = a / (k * k); else tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.066], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], N[(a * N[(1.0 / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.066:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \frac{1}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -0.066000000000000003Initial program 100.0%
associate-*r/100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 33.2%
Taylor expanded in k around inf 53.2%
unpow253.2%
Simplified53.2%
if -0.066000000000000003 < m Initial program 87.6%
associate-*r/87.6%
associate-+l+87.6%
+-commutative87.6%
distribute-rgt-out87.6%
fma-def87.6%
+-commutative87.6%
Simplified87.6%
Taylor expanded in m around 0 51.4%
Final simplification51.9%
(FPCore (a k m) :precision binary64 (if (<= k 3.9e-308) (/ a (* k k)) (if (<= k 0.1) (* a (+ 1.0 (* k -10.0))) (/ (/ a k) k))))
double code(double a, double k, double m) {
double tmp;
if (k <= 3.9e-308) {
tmp = a / (k * k);
} else if (k <= 0.1) {
tmp = a * (1.0 + (k * -10.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 <= 3.9d-308) then
tmp = a / (k * k)
else if (k <= 0.1d0) then
tmp = a * (1.0d0 + (k * (-10.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 <= 3.9e-308) {
tmp = a / (k * k);
} else if (k <= 0.1) {
tmp = a * (1.0 + (k * -10.0));
} else {
tmp = (a / k) / k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= 3.9e-308: tmp = a / (k * k) elif k <= 0.1: tmp = a * (1.0 + (k * -10.0)) else: tmp = (a / k) / k return tmp
function code(a, k, m) tmp = 0.0 if (k <= 3.9e-308) tmp = Float64(a / Float64(k * k)); elseif (k <= 0.1) tmp = Float64(a * Float64(1.0 + Float64(k * -10.0))); else tmp = Float64(Float64(a / k) / k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= 3.9e-308) tmp = a / (k * k); elseif (k <= 0.1) tmp = a * (1.0 + (k * -10.0)); else tmp = (a / k) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, 3.9e-308], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 0.1], N[(a * N[(1.0 + N[(k * -10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.9 \cdot 10^{-308}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 0.1:\\
\;\;\;\;a \cdot \left(1 + k \cdot -10\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\end{array}
\end{array}
if k < 3.8999999999999999e-308Initial program 89.7%
associate-*r/89.7%
associate-+l+89.7%
+-commutative89.7%
distribute-rgt-out89.7%
fma-def89.7%
+-commutative89.7%
Simplified89.7%
Taylor expanded in m around 0 16.1%
Taylor expanded in k around inf 21.4%
unpow221.4%
Simplified21.4%
if 3.8999999999999999e-308 < k < 0.10000000000000001Initial program 99.9%
associate-*r/99.9%
associate-+l+99.9%
+-commutative99.9%
distribute-rgt-out99.9%
fma-def99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in m around 0 57.1%
Taylor expanded in k around 0 56.7%
if 0.10000000000000001 < k Initial program 82.9%
associate-*r/82.9%
associate-+l+82.9%
+-commutative82.9%
distribute-rgt-out82.9%
fma-def82.9%
+-commutative82.9%
Simplified82.9%
Taylor expanded in m around 0 58.9%
Taylor expanded in k around inf 57.6%
unpow257.6%
Simplified57.6%
div-inv57.6%
associate-/r*57.7%
Applied egg-rr57.7%
Final simplification47.7%
(FPCore (a k m) :precision binary64 (if (<= k 2.1e-308) (/ a (* k k)) (if (<= k 0.1) (+ a (* -10.0 (* a k))) (/ (/ a k) k))))
double code(double a, double k, double m) {
double tmp;
if (k <= 2.1e-308) {
tmp = a / (k * k);
} else if (k <= 0.1) {
tmp = a + (-10.0 * (a * k));
} 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 <= 2.1d-308) then
tmp = a / (k * k)
else if (k <= 0.1d0) then
tmp = a + ((-10.0d0) * (a * k))
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 <= 2.1e-308) {
tmp = a / (k * k);
} else if (k <= 0.1) {
tmp = a + (-10.0 * (a * k));
} else {
tmp = (a / k) / k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= 2.1e-308: tmp = a / (k * k) elif k <= 0.1: tmp = a + (-10.0 * (a * k)) else: tmp = (a / k) / k return tmp
function code(a, k, m) tmp = 0.0 if (k <= 2.1e-308) tmp = Float64(a / Float64(k * k)); elseif (k <= 0.1) tmp = Float64(a + Float64(-10.0 * Float64(a * k))); else tmp = Float64(Float64(a / k) / k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= 2.1e-308) tmp = a / (k * k); elseif (k <= 0.1) tmp = a + (-10.0 * (a * k)); else tmp = (a / k) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, 2.1e-308], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 0.1], N[(a + N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.1 \cdot 10^{-308}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 0.1:\\
\;\;\;\;a + -10 \cdot \left(a \cdot k\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\end{array}
\end{array}
if k < 2.1e-308Initial program 89.7%
associate-*r/89.7%
associate-+l+89.7%
+-commutative89.7%
distribute-rgt-out89.7%
fma-def89.7%
+-commutative89.7%
Simplified89.7%
Taylor expanded in m around 0 16.1%
Taylor expanded in k around inf 21.4%
unpow221.4%
Simplified21.4%
if 2.1e-308 < k < 0.10000000000000001Initial program 99.9%
associate-*r/99.9%
associate-+l+99.9%
+-commutative99.9%
distribute-rgt-out99.9%
fma-def99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in m around 0 57.1%
Taylor expanded in k around 0 56.7%
if 0.10000000000000001 < k Initial program 82.9%
associate-*r/82.9%
associate-+l+82.9%
+-commutative82.9%
distribute-rgt-out82.9%
fma-def82.9%
+-commutative82.9%
Simplified82.9%
Taylor expanded in m around 0 58.9%
Taylor expanded in k around inf 57.6%
unpow257.6%
Simplified57.6%
div-inv57.6%
associate-/r*57.7%
Applied egg-rr57.7%
Final simplification47.7%
(FPCore (a k m) :precision binary64 (if (<= m -0.24) (/ a (* k k)) (/ a (+ 1.0 (* k (+ k 10.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.24) {
tmp = a / (k * k);
} 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 <= (-0.24d0)) then
tmp = a / (k * k)
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 <= -0.24) {
tmp = a / (k * k);
} else {
tmp = a / (1.0 + (k * (k + 10.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.24: tmp = a / (k * k) else: tmp = a / (1.0 + (k * (k + 10.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.24) tmp = Float64(a / Float64(k * k)); 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 <= -0.24) tmp = a / (k * k); else tmp = a / (1.0 + (k * (k + 10.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.24], N[(a / N[(k * k), $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 -0.24:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -0.23999999999999999Initial program 100.0%
associate-*r/100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 33.2%
Taylor expanded in k around inf 53.2%
unpow253.2%
Simplified53.2%
if -0.23999999999999999 < m Initial program 87.6%
associate-*r/87.6%
associate-+l+87.6%
+-commutative87.6%
distribute-rgt-out87.6%
fma-def87.6%
+-commutative87.6%
Simplified87.6%
Taylor expanded in m around 0 51.4%
Final simplification51.8%
(FPCore (a k m) :precision binary64 (if (or (<= k -2e-310) (not (<= k 14500.0))) (/ a (* k k)) a))
double code(double a, double k, double m) {
double tmp;
if ((k <= -2e-310) || !(k <= 14500.0)) {
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 <= (-2d-310)) .or. (.not. (k <= 14500.0d0))) 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 <= -2e-310) || !(k <= 14500.0)) {
tmp = a / (k * k);
} else {
tmp = a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if (k <= -2e-310) or not (k <= 14500.0): tmp = a / (k * k) else: tmp = a return tmp
function code(a, k, m) tmp = 0.0 if ((k <= -2e-310) || !(k <= 14500.0)) tmp = Float64(a / Float64(k * k)); else tmp = a; end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((k <= -2e-310) || ~((k <= 14500.0))) tmp = a / (k * k); else tmp = a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[k, -2e-310], N[Not[LessEqual[k, 14500.0]], $MachinePrecision]], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], a]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq -2 \cdot 10^{-310} \lor \neg \left(k \leq 14500\right):\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if k < -1.999999999999994e-310 or 14500 < k Initial program 85.6%
associate-*r/85.6%
associate-+l+85.6%
+-commutative85.6%
distribute-rgt-out85.6%
fma-def85.6%
+-commutative85.6%
Simplified85.6%
Taylor expanded in m around 0 41.7%
Taylor expanded in k around inf 43.1%
unpow243.1%
Simplified43.1%
if -1.999999999999994e-310 < k < 14500Initial program 99.9%
associate-*r/99.9%
associate-+l+99.9%
+-commutative99.9%
distribute-rgt-out99.9%
fma-def99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in m around 0 56.5%
Taylor expanded in k around 0 55.2%
Final simplification47.4%
(FPCore (a k m) :precision binary64 (if (<= k 5e-309) (/ a (* k k)) (if (<= k 14500.0) a (/ (/ a k) k))))
double code(double a, double k, double m) {
double tmp;
if (k <= 5e-309) {
tmp = a / (k * k);
} else if (k <= 14500.0) {
tmp = a;
} 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 <= 5d-309) then
tmp = a / (k * k)
else if (k <= 14500.0d0) then
tmp = a
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 <= 5e-309) {
tmp = a / (k * k);
} else if (k <= 14500.0) {
tmp = a;
} else {
tmp = (a / k) / k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= 5e-309: tmp = a / (k * k) elif k <= 14500.0: tmp = a else: tmp = (a / k) / k return tmp
function code(a, k, m) tmp = 0.0 if (k <= 5e-309) tmp = Float64(a / Float64(k * k)); elseif (k <= 14500.0) tmp = a; else tmp = Float64(Float64(a / k) / k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= 5e-309) tmp = a / (k * k); elseif (k <= 14500.0) tmp = a; else tmp = (a / k) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, 5e-309], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 14500.0], a, N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 5 \cdot 10^{-309}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 14500:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\end{array}
\end{array}
if k < 4.9999999999999995e-309Initial program 89.7%
associate-*r/89.7%
associate-+l+89.7%
+-commutative89.7%
distribute-rgt-out89.7%
fma-def89.7%
+-commutative89.7%
Simplified89.7%
Taylor expanded in m around 0 16.1%
Taylor expanded in k around inf 21.4%
unpow221.4%
Simplified21.4%
if 4.9999999999999995e-309 < k < 14500Initial program 99.9%
associate-*r/99.9%
associate-+l+99.9%
+-commutative99.9%
distribute-rgt-out99.9%
fma-def99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in m around 0 56.5%
Taylor expanded in k around 0 55.2%
if 14500 < k Initial program 82.7%
associate-*r/82.7%
associate-+l+82.7%
+-commutative82.7%
distribute-rgt-out82.8%
fma-def82.8%
+-commutative82.8%
Simplified82.8%
Taylor expanded in m around 0 59.5%
Taylor expanded in k around inf 58.2%
unpow258.2%
Simplified58.2%
div-inv58.2%
associate-/r*58.2%
Applied egg-rr58.2%
Final simplification47.4%
(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 90.6%
associate-*r/90.6%
associate-+l+90.6%
+-commutative90.6%
distribute-rgt-out90.6%
fma-def90.6%
+-commutative90.6%
Simplified90.6%
Taylor expanded in m around 0 46.9%
Taylor expanded in k around 0 22.1%
Final simplification22.1%
herbie shell --seed 2023189
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))