
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}
(FPCore (a k m) :precision binary64 (let* ((t_0 (* a (pow k m))) (t_1 (/ t_0 (+ (+ 1.0 (* k 10.0)) (* k k))))) (if (<= t_1 5e+269) 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 <= 5e+269) {
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 <= 5d+269) 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 <= 5e+269) {
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 <= 5e+269: 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 <= 5e+269) 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 <= 5e+269) 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, 5e+269], 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 5 \cdot 10^{+269}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k))) < 5.0000000000000002e269Initial program 97.9%
if 5.0000000000000002e269 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k))) Initial program 65.1%
associate-*r/65.1%
*-commutative65.1%
sqr-neg65.1%
associate-+l+65.1%
+-commutative65.1%
sqr-neg65.1%
distribute-rgt-out65.1%
fma-def65.1%
+-commutative65.1%
Simplified65.1%
Taylor expanded in k around 0 100.0%
Final simplification98.2%
(FPCore (a k m) :precision binary64 (if (<= m 1.45e-5) (/ (pow k m) (/ (+ 1.0 (* k (+ k 10.0))) a)) (/ a (pow k (- 2.0 m)))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.45e-5) {
tmp = pow(k, m) / ((1.0 + (k * (k + 10.0))) / a);
} else {
tmp = a / pow(k, (2.0 - 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 <= 1.45d-5) then
tmp = (k ** m) / ((1.0d0 + (k * (k + 10.0d0))) / a)
else
tmp = a / (k ** (2.0d0 - m))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1.45e-5) {
tmp = Math.pow(k, m) / ((1.0 + (k * (k + 10.0))) / a);
} else {
tmp = a / Math.pow(k, (2.0 - m));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1.45e-5: tmp = math.pow(k, m) / ((1.0 + (k * (k + 10.0))) / a) else: tmp = a / math.pow(k, (2.0 - m)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1.45e-5) tmp = Float64((k ^ m) / Float64(Float64(1.0 + Float64(k * Float64(k + 10.0))) / a)); else tmp = Float64(a / (k ^ Float64(2.0 - m))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1.45e-5) tmp = (k ^ m) / ((1.0 + (k * (k + 10.0))) / a); else tmp = a / (k ^ (2.0 - m)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1.45e-5], N[(N[Power[k, m], $MachinePrecision] / N[(N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(a / N[Power[k, N[(2.0 - m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{{k}^{m}}{\frac{1 + k \cdot \left(k + 10\right)}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{{k}^{\left(2 - m\right)}}\\
\end{array}
\end{array}
if m < 1.45e-5Initial program 97.4%
associate-*r/97.3%
*-commutative97.3%
sqr-neg97.3%
associate-+l+97.3%
+-commutative97.3%
sqr-neg97.3%
distribute-rgt-out97.3%
fma-def97.3%
+-commutative97.3%
Simplified97.3%
Taylor expanded in m around inf 97.4%
*-commutative97.4%
+-commutative97.4%
+-commutative97.4%
fma-udef97.4%
associate-/l*97.1%
Simplified97.1%
Taylor expanded in a around 0 97.1%
if 1.45e-5 < m Initial program 82.4%
Taylor expanded in k around inf 56.5%
unpow256.5%
Simplified56.5%
expm1-log1p-u42.4%
expm1-udef42.4%
associate-/l*42.4%
pow242.4%
pow-div76.5%
Applied egg-rr76.5%
expm1-def76.5%
expm1-log1p100.0%
Simplified100.0%
Final simplification98.1%
(FPCore (a k m) :precision binary64 (if (or (<= m -1.25e-5) (not (<= m 0.00046))) (* a (pow k m)) (/ a (+ 1.0 (* k (+ k 10.0))))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -1.25e-5) || !(m <= 0.00046)) {
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 <= (-1.25d-5)) .or. (.not. (m <= 0.00046d0))) 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 <= -1.25e-5) || !(m <= 0.00046)) {
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 <= -1.25e-5) or not (m <= 0.00046): 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 <= -1.25e-5) || !(m <= 0.00046)) 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 <= -1.25e-5) || ~((m <= 0.00046))) 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, -1.25e-5], N[Not[LessEqual[m, 0.00046]], $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 -1.25 \cdot 10^{-5} \lor \neg \left(m \leq 0.00046\right):\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -1.25000000000000006e-5 or 4.6000000000000001e-4 < m Initial program 91.2%
associate-*r/91.2%
*-commutative91.2%
sqr-neg91.2%
associate-+l+91.2%
+-commutative91.2%
sqr-neg91.2%
distribute-rgt-out91.2%
fma-def91.2%
+-commutative91.2%
Simplified91.2%
Taylor expanded in k around 0 100.0%
if -1.25000000000000006e-5 < m < 4.6000000000000001e-4Initial program 94.7%
associate-*r/94.6%
*-commutative94.6%
sqr-neg94.6%
associate-+l+94.6%
+-commutative94.6%
sqr-neg94.6%
distribute-rgt-out94.6%
fma-def94.6%
+-commutative94.6%
Simplified94.6%
Taylor expanded in m around 0 93.3%
Final simplification97.8%
(FPCore (a k m) :precision binary64 (if (<= k 0.0132) (* a (pow k m)) (/ a (pow k (- 2.0 m)))))
double code(double a, double k, double m) {
double tmp;
if (k <= 0.0132) {
tmp = a * pow(k, m);
} else {
tmp = a / pow(k, (2.0 - 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 (k <= 0.0132d0) then
tmp = a * (k ** m)
else
tmp = a / (k ** (2.0d0 - m))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (k <= 0.0132) {
tmp = a * Math.pow(k, m);
} else {
tmp = a / Math.pow(k, (2.0 - m));
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= 0.0132: tmp = a * math.pow(k, m) else: tmp = a / math.pow(k, (2.0 - m)) return tmp
function code(a, k, m) tmp = 0.0 if (k <= 0.0132) tmp = Float64(a * (k ^ m)); else tmp = Float64(a / (k ^ Float64(2.0 - m))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= 0.0132) tmp = a * (k ^ m); else tmp = a / (k ^ (2.0 - m)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, 0.0132], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision], N[(a / N[Power[k, N[(2.0 - m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 0.0132:\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{{k}^{\left(2 - m\right)}}\\
\end{array}
\end{array}
if k < 0.0132Initial program 96.2%
associate-*r/96.2%
*-commutative96.2%
sqr-neg96.2%
associate-+l+96.2%
+-commutative96.2%
sqr-neg96.2%
distribute-rgt-out96.2%
fma-def96.2%
+-commutative96.2%
Simplified96.2%
Taylor expanded in k around 0 99.4%
if 0.0132 < k Initial program 86.1%
Taylor expanded in k around inf 85.5%
unpow285.5%
Simplified85.5%
expm1-log1p-u75.8%
expm1-udef65.5%
associate-/l*65.5%
pow265.5%
pow-div71.7%
Applied egg-rr71.7%
expm1-def82.0%
expm1-log1p94.8%
Simplified94.8%
Final simplification97.7%
(FPCore (a k m) :precision binary64 (if (or (<= k 9.8e-299) (not (<= k 0.0132))) (/ a (* k k)) (* a (+ 1.0 (* k -10.0)))))
double code(double a, double k, double m) {
double tmp;
if ((k <= 9.8e-299) || !(k <= 0.0132)) {
tmp = a / (k * k);
} else {
tmp = a * (1.0 + (k * -10.0));
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if ((k <= 9.8d-299) .or. (.not. (k <= 0.0132d0))) then
tmp = a / (k * k)
else
tmp = a * (1.0d0 + (k * (-10.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if ((k <= 9.8e-299) || !(k <= 0.0132)) {
tmp = a / (k * k);
} else {
tmp = a * (1.0 + (k * -10.0));
}
return tmp;
}
def code(a, k, m): tmp = 0 if (k <= 9.8e-299) or not (k <= 0.0132): tmp = a / (k * k) else: tmp = a * (1.0 + (k * -10.0)) return tmp
function code(a, k, m) tmp = 0.0 if ((k <= 9.8e-299) || !(k <= 0.0132)) tmp = Float64(a / Float64(k * k)); else tmp = Float64(a * Float64(1.0 + Float64(k * -10.0))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((k <= 9.8e-299) || ~((k <= 0.0132))) tmp = a / (k * k); else tmp = a * (1.0 + (k * -10.0)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[k, 9.8e-299], N[Not[LessEqual[k, 0.0132]], $MachinePrecision]], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], N[(a * N[(1.0 + N[(k * -10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 9.8 \cdot 10^{-299} \lor \neg \left(k \leq 0.0132\right):\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(1 + k \cdot -10\right)\\
\end{array}
\end{array}
if k < 9.7999999999999999e-299 or 0.0132 < k Initial program 89.0%
associate-*r/88.9%
*-commutative88.9%
sqr-neg88.9%
associate-+l+88.9%
+-commutative88.9%
sqr-neg88.9%
distribute-rgt-out88.9%
fma-def88.9%
+-commutative88.9%
Simplified88.9%
Taylor expanded in m around 0 49.7%
Taylor expanded in k around inf 52.6%
unpow252.6%
Simplified52.6%
if 9.7999999999999999e-299 < k < 0.0132Initial program 99.9%
associate-*r/100.0%
*-commutative100.0%
sqr-neg100.0%
associate-+l+100.0%
+-commutative100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 69.3%
associate-*r*69.3%
distribute-lft1-in99.3%
*-commutative99.3%
fma-def99.3%
Simplified99.3%
Taylor expanded in m around 0 40.0%
Final simplification48.7%
(FPCore (a k m) :precision binary64 (if (<= k 4.2e-298) (/ a (* k k)) (if (<= k 0.0132) (* a (+ 1.0 (* k -10.0))) (* (/ 1.0 k) (/ a k)))))
double code(double a, double k, double m) {
double tmp;
if (k <= 4.2e-298) {
tmp = a / (k * k);
} else if (k <= 0.0132) {
tmp = a * (1.0 + (k * -10.0));
} else {
tmp = (1.0 / k) * (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 (k <= 4.2d-298) then
tmp = a / (k * k)
else if (k <= 0.0132d0) then
tmp = a * (1.0d0 + (k * (-10.0d0)))
else
tmp = (1.0d0 / k) * (a / k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (k <= 4.2e-298) {
tmp = a / (k * k);
} else if (k <= 0.0132) {
tmp = a * (1.0 + (k * -10.0));
} else {
tmp = (1.0 / k) * (a / k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= 4.2e-298: tmp = a / (k * k) elif k <= 0.0132: tmp = a * (1.0 + (k * -10.0)) else: tmp = (1.0 / k) * (a / k) return tmp
function code(a, k, m) tmp = 0.0 if (k <= 4.2e-298) tmp = Float64(a / Float64(k * k)); elseif (k <= 0.0132) tmp = Float64(a * Float64(1.0 + Float64(k * -10.0))); else tmp = Float64(Float64(1.0 / k) * Float64(a / k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= 4.2e-298) tmp = a / (k * k); elseif (k <= 0.0132) tmp = a * (1.0 + (k * -10.0)); else tmp = (1.0 / k) * (a / k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, 4.2e-298], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 0.0132], N[(a * N[(1.0 + N[(k * -10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / k), $MachinePrecision] * N[(a / k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 4.2 \cdot 10^{-298}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 0.0132:\\
\;\;\;\;a \cdot \left(1 + k \cdot -10\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{k} \cdot \frac{a}{k}\\
\end{array}
\end{array}
if k < 4.2000000000000001e-298Initial program 92.4%
associate-*r/92.4%
*-commutative92.4%
sqr-neg92.4%
associate-+l+92.4%
+-commutative92.4%
sqr-neg92.4%
distribute-rgt-out92.4%
fma-def92.4%
+-commutative92.4%
Simplified92.4%
Taylor expanded in m around 0 32.9%
Taylor expanded in k around inf 39.8%
unpow239.8%
Simplified39.8%
if 4.2000000000000001e-298 < k < 0.0132Initial program 99.9%
associate-*r/100.0%
*-commutative100.0%
sqr-neg100.0%
associate-+l+100.0%
+-commutative100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 69.3%
associate-*r*69.3%
distribute-lft1-in99.3%
*-commutative99.3%
fma-def99.3%
Simplified99.3%
Taylor expanded in m around 0 40.0%
if 0.0132 < k Initial program 86.1%
Taylor expanded in k around inf 85.5%
unpow285.5%
Simplified85.5%
*-commutative85.5%
times-frac93.1%
Applied egg-rr93.1%
Taylor expanded in m around 0 66.6%
Final simplification50.0%
(FPCore (a k m) :precision binary64 (if (<= k 1.15e-297) (/ a (* k k)) (if (<= k 0.0132) (/ a (+ 1.0 (* k 10.0))) (* (/ 1.0 k) (/ a k)))))
double code(double a, double k, double m) {
double tmp;
if (k <= 1.15e-297) {
tmp = a / (k * k);
} else if (k <= 0.0132) {
tmp = a / (1.0 + (k * 10.0));
} else {
tmp = (1.0 / k) * (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 (k <= 1.15d-297) then
tmp = a / (k * k)
else if (k <= 0.0132d0) then
tmp = a / (1.0d0 + (k * 10.0d0))
else
tmp = (1.0d0 / k) * (a / k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (k <= 1.15e-297) {
tmp = a / (k * k);
} else if (k <= 0.0132) {
tmp = a / (1.0 + (k * 10.0));
} else {
tmp = (1.0 / k) * (a / k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= 1.15e-297: tmp = a / (k * k) elif k <= 0.0132: tmp = a / (1.0 + (k * 10.0)) else: tmp = (1.0 / k) * (a / k) return tmp
function code(a, k, m) tmp = 0.0 if (k <= 1.15e-297) tmp = Float64(a / Float64(k * k)); elseif (k <= 0.0132) tmp = Float64(a / Float64(1.0 + Float64(k * 10.0))); else tmp = Float64(Float64(1.0 / k) * Float64(a / k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= 1.15e-297) tmp = a / (k * k); elseif (k <= 0.0132) tmp = a / (1.0 + (k * 10.0)); else tmp = (1.0 / k) * (a / k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, 1.15e-297], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 0.0132], N[(a / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / k), $MachinePrecision] * N[(a / k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.15 \cdot 10^{-297}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 0.0132:\\
\;\;\;\;\frac{a}{1 + k \cdot 10}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{k} \cdot \frac{a}{k}\\
\end{array}
\end{array}
if k < 1.15e-297Initial program 92.4%
associate-*r/92.4%
*-commutative92.4%
sqr-neg92.4%
associate-+l+92.4%
+-commutative92.4%
sqr-neg92.4%
distribute-rgt-out92.4%
fma-def92.4%
+-commutative92.4%
Simplified92.4%
Taylor expanded in m around 0 32.9%
Taylor expanded in k around inf 39.8%
unpow239.8%
Simplified39.8%
if 1.15e-297 < k < 0.0132Initial program 99.9%
associate-*r/100.0%
*-commutative100.0%
sqr-neg100.0%
associate-+l+100.0%
+-commutative100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 40.6%
Taylor expanded in k around 0 40.0%
*-commutative40.0%
Simplified40.0%
if 0.0132 < k Initial program 86.1%
Taylor expanded in k around inf 85.5%
unpow285.5%
Simplified85.5%
*-commutative85.5%
times-frac93.1%
Applied egg-rr93.1%
Taylor expanded in m around 0 66.6%
Final simplification50.0%
(FPCore (a k m) :precision binary64 (if (<= m -0.24) (* a (/ 1.0 (* 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 * (1.0 / (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 * (1.0d0 / (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 * (1.0 / (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 * (1.0 / (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(1.0 / 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 * (1.0 / (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[(1.0 / N[(k * k), $MachinePrecision]), $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:\\
\;\;\;\;a \cdot \frac{1}{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%
*-commutative100.0%
sqr-neg100.0%
associate-+l+100.0%
+-commutative100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 43.6%
Taylor expanded in k around inf 68.2%
unpow268.2%
Simplified68.2%
associate-/r*62.8%
div-inv62.8%
*-un-lft-identity62.8%
times-frac68.2%
Applied egg-rr68.2%
/-rgt-identity68.2%
associate-/l/69.3%
Simplified69.3%
if -0.23999999999999999 < m Initial program 88.5%
associate-*r/88.5%
*-commutative88.5%
sqr-neg88.5%
associate-+l+88.5%
+-commutative88.5%
sqr-neg88.5%
distribute-rgt-out88.5%
fma-def88.5%
+-commutative88.5%
Simplified88.5%
Taylor expanded in m around 0 48.5%
Final simplification55.5%
(FPCore (a k m) :precision binary64 (if (or (<= k 2.05e-299) (not (<= k 0.0132))) (/ a (* k k)) a))
double code(double a, double k, double m) {
double tmp;
if ((k <= 2.05e-299) || !(k <= 0.0132)) {
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 <= 2.05d-299) .or. (.not. (k <= 0.0132d0))) 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 <= 2.05e-299) || !(k <= 0.0132)) {
tmp = a / (k * k);
} else {
tmp = a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if (k <= 2.05e-299) or not (k <= 0.0132): tmp = a / (k * k) else: tmp = a return tmp
function code(a, k, m) tmp = 0.0 if ((k <= 2.05e-299) || !(k <= 0.0132)) 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 <= 2.05e-299) || ~((k <= 0.0132))) tmp = a / (k * k); else tmp = a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[k, 2.05e-299], N[Not[LessEqual[k, 0.0132]], $MachinePrecision]], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], a]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.05 \cdot 10^{-299} \lor \neg \left(k \leq 0.0132\right):\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if k < 2.05e-299 or 0.0132 < k Initial program 89.0%
associate-*r/88.9%
*-commutative88.9%
sqr-neg88.9%
associate-+l+88.9%
+-commutative88.9%
sqr-neg88.9%
distribute-rgt-out88.9%
fma-def88.9%
+-commutative88.9%
Simplified88.9%
Taylor expanded in m around 0 49.7%
Taylor expanded in k around inf 52.6%
unpow252.6%
Simplified52.6%
if 2.05e-299 < k < 0.0132Initial program 99.9%
associate-*r/100.0%
*-commutative100.0%
sqr-neg100.0%
associate-+l+100.0%
+-commutative100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 40.6%
Taylor expanded in k around 0 39.6%
Final simplification48.6%
(FPCore (a k m) :precision binary64 (if (<= m -0.86) (* a (/ 1.0 (* k k))) (/ a (+ 1.0 (* k k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.86) {
tmp = a * (1.0 / (k * k));
} else {
tmp = a / (1.0 + (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 (m <= (-0.86d0)) then
tmp = a * (1.0d0 / (k * k))
else
tmp = a / (1.0d0 + (k * k))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -0.86) {
tmp = a * (1.0 / (k * k));
} else {
tmp = a / (1.0 + (k * k));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.86: tmp = a * (1.0 / (k * k)) else: tmp = a / (1.0 + (k * k)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.86) tmp = Float64(a * Float64(1.0 / Float64(k * k))); else tmp = Float64(a / Float64(1.0 + Float64(k * k))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -0.86) tmp = a * (1.0 / (k * k)); else tmp = a / (1.0 + (k * k)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.86], N[(a * N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.86:\\
\;\;\;\;a \cdot \frac{1}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\
\end{array}
\end{array}
if m < -0.859999999999999987Initial program 100.0%
associate-*r/100.0%
*-commutative100.0%
sqr-neg100.0%
associate-+l+100.0%
+-commutative100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 43.6%
Taylor expanded in k around inf 68.2%
unpow268.2%
Simplified68.2%
associate-/r*62.8%
div-inv62.8%
*-un-lft-identity62.8%
times-frac68.2%
Applied egg-rr68.2%
/-rgt-identity68.2%
associate-/l/69.3%
Simplified69.3%
if -0.859999999999999987 < m Initial program 88.5%
associate-*r/88.5%
*-commutative88.5%
sqr-neg88.5%
associate-+l+88.5%
+-commutative88.5%
sqr-neg88.5%
distribute-rgt-out88.5%
fma-def88.5%
+-commutative88.5%
Simplified88.5%
Taylor expanded in m around 0 48.5%
Taylor expanded in k around inf 47.8%
unpow247.8%
Simplified47.8%
Final simplification55.1%
(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-*r/92.4%
*-commutative92.4%
sqr-neg92.4%
associate-+l+92.4%
+-commutative92.4%
sqr-neg92.4%
distribute-rgt-out92.4%
fma-def92.4%
+-commutative92.4%
Simplified92.4%
Taylor expanded in m around 0 46.9%
Taylor expanded in k around 0 15.7%
Final simplification15.7%
herbie shell --seed 2023278
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))