
(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 13 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 (<= k -2.2e+168)
t_0
(if (<= k 1e+76)
(/ t_0 (+ (+ 1.0 (* k 10.0)) (* k k)))
(/ (* a (/ (pow k m) k)) k)))))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double tmp;
if (k <= -2.2e+168) {
tmp = t_0;
} else if (k <= 1e+76) {
tmp = t_0 / ((1.0 + (k * 10.0)) + (k * k));
} else {
tmp = (a * (pow(k, m) / 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) :: t_0
real(8) :: tmp
t_0 = a * (k ** m)
if (k <= (-2.2d+168)) then
tmp = t_0
else if (k <= 1d+76) then
tmp = t_0 / ((1.0d0 + (k * 10.0d0)) + (k * k))
else
tmp = (a * ((k ** m) / k)) / k
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 (k <= -2.2e+168) {
tmp = t_0;
} else if (k <= 1e+76) {
tmp = t_0 / ((1.0 + (k * 10.0)) + (k * k));
} else {
tmp = (a * (Math.pow(k, m) / k)) / k;
}
return tmp;
}
def code(a, k, m): t_0 = a * math.pow(k, m) tmp = 0 if k <= -2.2e+168: tmp = t_0 elif k <= 1e+76: tmp = t_0 / ((1.0 + (k * 10.0)) + (k * k)) else: tmp = (a * (math.pow(k, m) / k)) / k return tmp
function code(a, k, m) t_0 = Float64(a * (k ^ m)) tmp = 0.0 if (k <= -2.2e+168) tmp = t_0; elseif (k <= 1e+76) tmp = Float64(t_0 / Float64(Float64(1.0 + Float64(k * 10.0)) + Float64(k * k))); else tmp = Float64(Float64(a * Float64((k ^ m) / k)) / k); end return tmp end
function tmp_2 = code(a, k, m) t_0 = a * (k ^ m); tmp = 0.0; if (k <= -2.2e+168) tmp = t_0; elseif (k <= 1e+76) tmp = t_0 / ((1.0 + (k * 10.0)) + (k * k)); else tmp = (a * ((k ^ m) / k)) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k, -2.2e+168], t$95$0, If[LessEqual[k, 1e+76], N[(t$95$0 / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[Power[k, m], $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;k \leq -2.2 \cdot 10^{+168}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;k \leq 10^{+76}:\\
\;\;\;\;\frac{t_0}{\left(1 + k \cdot 10\right) + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\frac{a \cdot \frac{{k}^{m}}{k}}{k}\\
\end{array}
\end{array}
if k < -2.2000000000000002e168Initial program 61.1%
Taylor expanded in k around 0 0.0%
exp-to-pow100.0%
*-commutative100.0%
Simplified100.0%
if -2.2000000000000002e168 < k < 1e76Initial program 99.9%
if 1e76 < k Initial program 79.9%
Taylor expanded in k around inf 79.9%
unpow279.9%
times-frac90.3%
mul-1-neg90.3%
distribute-rgt-neg-in90.3%
exp-to-pow90.3%
Simplified90.3%
associate-*l/100.0%
inv-pow100.0%
pow-pow100.0%
add-sqr-sqrt56.2%
sqrt-unprod73.8%
sqr-neg73.8%
sqrt-unprod17.6%
add-sqr-sqrt48.1%
neg-mul-148.1%
add-sqr-sqrt30.5%
sqrt-unprod74.3%
sqr-neg74.3%
sqrt-unprod43.8%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (a k m) :precision binary64 (if (<= k 0.1) (* (fma k -10.0 1.0) (* a (pow k m))) (/ (* a (/ (pow k m) k)) k)))
double code(double a, double k, double m) {
double tmp;
if (k <= 0.1) {
tmp = fma(k, -10.0, 1.0) * (a * pow(k, m));
} else {
tmp = (a * (pow(k, m) / k)) / k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (k <= 0.1) tmp = Float64(fma(k, -10.0, 1.0) * Float64(a * (k ^ m))); else tmp = Float64(Float64(a * Float64((k ^ m) / k)) / k); end return tmp end
code[a_, k_, m_] := If[LessEqual[k, 0.1], N[(N[(k * -10.0 + 1.0), $MachinePrecision] * N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[Power[k, m], $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 0.1:\\
\;\;\;\;\mathsf{fma}\left(k, -10, 1\right) \cdot \left(a \cdot {k}^{m}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a \cdot \frac{{k}^{m}}{k}}{k}\\
\end{array}
\end{array}
if k < 0.10000000000000001Initial program 95.6%
Taylor expanded in k around 0 42.8%
exp-to-pow42.8%
exp-to-pow42.8%
exp-to-pow42.8%
*-commutative42.8%
associate-*r*42.8%
exp-to-pow89.5%
*-commutative89.5%
distribute-lft1-in99.3%
*-commutative99.3%
fma-def99.3%
Simplified99.3%
if 0.10000000000000001 < k Initial program 84.1%
Taylor expanded in k around inf 82.2%
unpow282.2%
times-frac90.3%
mul-1-neg90.3%
distribute-rgt-neg-in90.3%
exp-to-pow90.3%
Simplified90.3%
associate-*l/97.9%
inv-pow97.9%
pow-pow97.9%
add-sqr-sqrt53.5%
sqrt-unprod72.1%
sqr-neg72.1%
sqrt-unprod18.5%
add-sqr-sqrt47.7%
neg-mul-147.7%
add-sqr-sqrt29.2%
sqrt-unprod73.6%
sqr-neg73.6%
sqrt-unprod44.4%
add-sqr-sqrt97.9%
Applied egg-rr97.9%
Final simplification98.8%
(FPCore (a k m) :precision binary64 (if (<= k 1.0) (* a (pow k m)) (/ (* a (/ (pow k m) k)) k)))
double code(double a, double k, double m) {
double tmp;
if (k <= 1.0) {
tmp = a * pow(k, m);
} else {
tmp = (a * (pow(k, m) / 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 <= 1.0d0) then
tmp = a * (k ** m)
else
tmp = (a * ((k ** m) / k)) / k
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (k <= 1.0) {
tmp = a * Math.pow(k, m);
} else {
tmp = (a * (Math.pow(k, m) / k)) / k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= 1.0: tmp = a * math.pow(k, m) else: tmp = (a * (math.pow(k, m) / k)) / k return tmp
function code(a, k, m) tmp = 0.0 if (k <= 1.0) tmp = Float64(a * (k ^ m)); else tmp = Float64(Float64(a * Float64((k ^ m) / k)) / k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= 1.0) tmp = a * (k ^ m); else tmp = (a * ((k ^ m) / k)) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, 1.0], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[Power[k, m], $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1:\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;\frac{a \cdot \frac{{k}^{m}}{k}}{k}\\
\end{array}
\end{array}
if k < 1Initial program 95.6%
Taylor expanded in k around 0 51.8%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if 1 < k Initial program 84.1%
Taylor expanded in k around inf 82.2%
unpow282.2%
times-frac90.3%
mul-1-neg90.3%
distribute-rgt-neg-in90.3%
exp-to-pow90.3%
Simplified90.3%
associate-*l/97.9%
inv-pow97.9%
pow-pow97.9%
add-sqr-sqrt53.5%
sqrt-unprod72.1%
sqr-neg72.1%
sqrt-unprod18.5%
add-sqr-sqrt47.7%
neg-mul-147.7%
add-sqr-sqrt29.2%
sqrt-unprod73.6%
sqr-neg73.6%
sqrt-unprod44.4%
add-sqr-sqrt97.9%
Applied egg-rr97.9%
Final simplification98.2%
(FPCore (a k m) :precision binary64 (if (or (<= m -0.06) (not (<= m 0.0031))) (* a (pow k m)) (/ a (+ 1.0 (* k (+ k 10.0))))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -0.06) || !(m <= 0.0031)) {
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 <= (-0.06d0)) .or. (.not. (m <= 0.0031d0))) 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 <= -0.06) || !(m <= 0.0031)) {
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 <= -0.06) or not (m <= 0.0031): 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 <= -0.06) || !(m <= 0.0031)) 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 <= -0.06) || ~((m <= 0.0031))) 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, -0.06], N[Not[LessEqual[m, 0.0031]], $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 -0.06 \lor \neg \left(m \leq 0.0031\right):\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -0.059999999999999998 or 0.00309999999999999989 < m Initial program 90.0%
Taylor expanded in k around 0 52.5%
exp-to-pow100.0%
*-commutative100.0%
Simplified100.0%
if -0.059999999999999998 < m < 0.00309999999999999989Initial program 93.9%
+-commutative93.9%
add-cbrt-cube91.9%
cbrt-prod93.8%
associate-*l*93.8%
fma-def93.8%
cbrt-prod93.7%
pow293.7%
+-commutative93.7%
*-commutative93.7%
fma-def93.7%
Applied egg-rr93.7%
fma-udef93.7%
+-commutative93.7%
*-commutative93.7%
associate-*r*93.7%
*-commutative93.7%
associate-*l*93.7%
pow-plus93.8%
metadata-eval93.8%
Simplified93.8%
Taylor expanded in m around 0 93.6%
unpow293.6%
distribute-rgt-in93.6%
Simplified93.6%
Final simplification97.6%
(FPCore (a k m)
:precision binary64
(if (<= m -0.315)
(/ a (* k k))
(if (<= m 160000000000.0)
(/ a (+ 1.0 (* k (+ k 10.0))))
(+ (* 0.1 (/ a k)) (+ (* a -0.01) (* 0.001 (* k a)))))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.315) {
tmp = a / (k * k);
} else if (m <= 160000000000.0) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = (0.1 * (a / k)) + ((a * -0.01) + (0.001 * (k * 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 <= (-0.315d0)) then
tmp = a / (k * k)
else if (m <= 160000000000.0d0) then
tmp = a / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = (0.1d0 * (a / k)) + ((a * (-0.01d0)) + (0.001d0 * (k * a)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -0.315) {
tmp = a / (k * k);
} else if (m <= 160000000000.0) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = (0.1 * (a / k)) + ((a * -0.01) + (0.001 * (k * a)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.315: tmp = a / (k * k) elif m <= 160000000000.0: tmp = a / (1.0 + (k * (k + 10.0))) else: tmp = (0.1 * (a / k)) + ((a * -0.01) + (0.001 * (k * a))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.315) tmp = Float64(a / Float64(k * k)); elseif (m <= 160000000000.0) tmp = Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0)))); else tmp = Float64(Float64(0.1 * Float64(a / k)) + Float64(Float64(a * -0.01) + Float64(0.001 * Float64(k * a)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -0.315) tmp = a / (k * k); elseif (m <= 160000000000.0) tmp = a / (1.0 + (k * (k + 10.0))); else tmp = (0.1 * (a / k)) + ((a * -0.01) + (0.001 * (k * a))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.315], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 160000000000.0], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.1 * N[(a / k), $MachinePrecision]), $MachinePrecision] + N[(N[(a * -0.01), $MachinePrecision] + N[(0.001 * N[(k * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.315:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 160000000000:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;0.1 \cdot \frac{a}{k} + \left(a \cdot -0.01 + 0.001 \cdot \left(k \cdot a\right)\right)\\
\end{array}
\end{array}
if m < -0.315000000000000002Initial program 100.0%
Taylor expanded in m around 0 43.0%
Taylor expanded in k around inf 59.9%
unpow259.9%
Simplified59.9%
if -0.315000000000000002 < m < 1.6e11Initial program 94.0%
+-commutative94.0%
add-cbrt-cube92.1%
cbrt-prod93.9%
associate-*l*93.9%
fma-def93.9%
cbrt-prod93.9%
pow293.9%
+-commutative93.9%
*-commutative93.9%
fma-def93.9%
Applied egg-rr93.9%
fma-udef93.9%
+-commutative93.9%
*-commutative93.9%
associate-*r*93.9%
*-commutative93.9%
associate-*l*93.9%
pow-plus93.9%
metadata-eval93.9%
Simplified93.9%
Taylor expanded in m around 0 91.8%
unpow291.8%
distribute-rgt-in91.8%
Simplified91.8%
if 1.6e11 < m Initial program 80.7%
Taylor expanded in m around 0 3.1%
Taylor expanded in k around inf 2.4%
unpow22.4%
distribute-rgt-in2.4%
Simplified2.4%
Taylor expanded in k around 0 9.5%
Final simplification55.8%
(FPCore (a k m) :precision binary64 (if (or (<= k -3.4e-274) (not (<= k 0.1))) (/ a (* k k)) (* a (+ 1.0 (* k -10.0)))))
double code(double a, double k, double m) {
double tmp;
if ((k <= -3.4e-274) || !(k <= 0.1)) {
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 <= (-3.4d-274)) .or. (.not. (k <= 0.1d0))) 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 <= -3.4e-274) || !(k <= 0.1)) {
tmp = a / (k * k);
} else {
tmp = a * (1.0 + (k * -10.0));
}
return tmp;
}
def code(a, k, m): tmp = 0 if (k <= -3.4e-274) or not (k <= 0.1): tmp = a / (k * k) else: tmp = a * (1.0 + (k * -10.0)) return tmp
function code(a, k, m) tmp = 0.0 if ((k <= -3.4e-274) || !(k <= 0.1)) 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 <= -3.4e-274) || ~((k <= 0.1))) 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, -3.4e-274], N[Not[LessEqual[k, 0.1]], $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 -3.4 \cdot 10^{-274} \lor \neg \left(k \leq 0.1\right):\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(1 + k \cdot -10\right)\\
\end{array}
\end{array}
if k < -3.39999999999999981e-274 or 0.10000000000000001 < k Initial program 87.1%
Taylor expanded in m around 0 43.8%
Taylor expanded in k around inf 46.0%
unpow246.0%
Simplified46.0%
if -3.39999999999999981e-274 < k < 0.10000000000000001Initial program 99.9%
Taylor expanded in k around 0 79.3%
exp-to-pow79.3%
exp-to-pow79.3%
exp-to-pow79.3%
*-commutative79.3%
associate-*r*79.3%
exp-to-pow80.5%
*-commutative80.5%
distribute-lft1-in98.6%
*-commutative98.6%
fma-def98.6%
Simplified98.6%
Taylor expanded in m around 0 56.8%
Final simplification49.7%
(FPCore (a k m) :precision binary64 (if (<= k -3.4e-274) (/ a (* k k)) (if (<= k 0.1) (* a (+ 1.0 (* k -10.0))) (* (/ a k) (/ 1.0 k)))))
double code(double a, double k, double m) {
double tmp;
if (k <= -3.4e-274) {
tmp = a / (k * k);
} else if (k <= 0.1) {
tmp = a * (1.0 + (k * -10.0));
} else {
tmp = (a / k) * (1.0 / 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.4d-274)) then
tmp = a / (k * k)
else if (k <= 0.1d0) then
tmp = a * (1.0d0 + (k * (-10.0d0)))
else
tmp = (a / k) * (1.0d0 / k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (k <= -3.4e-274) {
tmp = a / (k * k);
} else if (k <= 0.1) {
tmp = a * (1.0 + (k * -10.0));
} else {
tmp = (a / k) * (1.0 / k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= -3.4e-274: tmp = a / (k * k) elif k <= 0.1: tmp = a * (1.0 + (k * -10.0)) else: tmp = (a / k) * (1.0 / k) return tmp
function code(a, k, m) tmp = 0.0 if (k <= -3.4e-274) 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) * Float64(1.0 / k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= -3.4e-274) tmp = a / (k * k); elseif (k <= 0.1) tmp = a * (1.0 + (k * -10.0)); else tmp = (a / k) * (1.0 / k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, -3.4e-274], 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] * N[(1.0 / k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq -3.4 \cdot 10^{-274}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 0.1:\\
\;\;\;\;a \cdot \left(1 + k \cdot -10\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{k} \cdot \frac{1}{k}\\
\end{array}
\end{array}
if k < -3.39999999999999981e-274Initial program 90.7%
Taylor expanded in m around 0 22.0%
Taylor expanded in k around inf 29.4%
unpow229.4%
Simplified29.4%
if -3.39999999999999981e-274 < k < 0.10000000000000001Initial program 99.9%
Taylor expanded in k around 0 79.3%
exp-to-pow79.3%
exp-to-pow79.3%
exp-to-pow79.3%
*-commutative79.3%
associate-*r*79.3%
exp-to-pow80.5%
*-commutative80.5%
distribute-lft1-in98.6%
*-commutative98.6%
fma-def98.6%
Simplified98.6%
Taylor expanded in m around 0 56.8%
if 0.10000000000000001 < k Initial program 84.1%
Taylor expanded in m around 0 61.4%
Taylor expanded in k around inf 59.5%
unpow259.5%
Simplified59.5%
associate-/r*61.5%
div-inv61.4%
Applied egg-rr61.4%
Final simplification50.5%
(FPCore (a k m) :precision binary64 (if (<= k -3.4e-274) (/ a (* k k)) (if (<= k 10.0) (/ a (+ 1.0 (* k 10.0))) (* (/ a k) (/ 1.0 k)))))
double code(double a, double k, double m) {
double tmp;
if (k <= -3.4e-274) {
tmp = a / (k * k);
} else if (k <= 10.0) {
tmp = a / (1.0 + (k * 10.0));
} else {
tmp = (a / k) * (1.0 / 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.4d-274)) then
tmp = a / (k * k)
else if (k <= 10.0d0) then
tmp = a / (1.0d0 + (k * 10.0d0))
else
tmp = (a / k) * (1.0d0 / k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (k <= -3.4e-274) {
tmp = a / (k * k);
} else if (k <= 10.0) {
tmp = a / (1.0 + (k * 10.0));
} else {
tmp = (a / k) * (1.0 / k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= -3.4e-274: tmp = a / (k * k) elif k <= 10.0: tmp = a / (1.0 + (k * 10.0)) else: tmp = (a / k) * (1.0 / k) return tmp
function code(a, k, m) tmp = 0.0 if (k <= -3.4e-274) tmp = Float64(a / Float64(k * k)); elseif (k <= 10.0) tmp = Float64(a / Float64(1.0 + Float64(k * 10.0))); else tmp = Float64(Float64(a / k) * Float64(1.0 / k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= -3.4e-274) tmp = a / (k * k); elseif (k <= 10.0) tmp = a / (1.0 + (k * 10.0)); else tmp = (a / k) * (1.0 / k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, -3.4e-274], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 10.0], N[(a / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / k), $MachinePrecision] * N[(1.0 / k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq -3.4 \cdot 10^{-274}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 10:\\
\;\;\;\;\frac{a}{1 + k \cdot 10}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{k} \cdot \frac{1}{k}\\
\end{array}
\end{array}
if k < -3.39999999999999981e-274Initial program 90.7%
Taylor expanded in m around 0 22.0%
Taylor expanded in k around inf 29.4%
unpow229.4%
Simplified29.4%
if -3.39999999999999981e-274 < k < 10Initial program 99.9%
Taylor expanded in k around 0 99.1%
Taylor expanded in m around 0 57.2%
if 10 < k Initial program 84.1%
Taylor expanded in m around 0 61.4%
Taylor expanded in k around inf 59.5%
unpow259.5%
Simplified59.5%
associate-/r*61.5%
div-inv61.4%
Applied egg-rr61.4%
Final simplification50.6%
(FPCore (a k m) :precision binary64 (if (<= m -0.74) (/ a (* k k)) (/ a (+ 1.0 (* k (+ k 10.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.74) {
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.74d0)) 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.74) {
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.74: 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.74) 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.74) 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.74], 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.74:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -0.73999999999999999Initial program 100.0%
Taylor expanded in m around 0 43.0%
Taylor expanded in k around inf 59.9%
unpow259.9%
Simplified59.9%
if -0.73999999999999999 < m Initial program 87.9%
+-commutative87.9%
add-cbrt-cube80.8%
cbrt-prod87.9%
associate-*l*87.9%
fma-def87.9%
cbrt-prod87.8%
pow287.8%
+-commutative87.8%
*-commutative87.8%
fma-def87.8%
Applied egg-rr87.8%
fma-udef87.8%
+-commutative87.8%
*-commutative87.8%
associate-*r*87.8%
*-commutative87.8%
associate-*l*87.8%
pow-plus87.8%
metadata-eval87.8%
Simplified87.8%
Taylor expanded in m around 0 51.1%
unpow251.1%
distribute-rgt-in51.1%
Simplified51.1%
Final simplification53.7%
(FPCore (a k m) :precision binary64 (if (or (<= k -2.6e+101) (not (<= k 0.1))) (/ a (* k 10.0)) a))
double code(double a, double k, double m) {
double tmp;
if ((k <= -2.6e+101) || !(k <= 0.1)) {
tmp = a / (k * 10.0);
} 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.6d+101)) .or. (.not. (k <= 0.1d0))) then
tmp = a / (k * 10.0d0)
else
tmp = a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if ((k <= -2.6e+101) || !(k <= 0.1)) {
tmp = a / (k * 10.0);
} else {
tmp = a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if (k <= -2.6e+101) or not (k <= 0.1): tmp = a / (k * 10.0) else: tmp = a return tmp
function code(a, k, m) tmp = 0.0 if ((k <= -2.6e+101) || !(k <= 0.1)) tmp = Float64(a / Float64(k * 10.0)); else tmp = a; end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((k <= -2.6e+101) || ~((k <= 0.1))) tmp = a / (k * 10.0); else tmp = a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[k, -2.6e+101], N[Not[LessEqual[k, 0.1]], $MachinePrecision]], N[(a / N[(k * 10.0), $MachinePrecision]), $MachinePrecision], a]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq -2.6 \cdot 10^{+101} \lor \neg \left(k \leq 0.1\right):\\
\;\;\;\;\frac{a}{k \cdot 10}\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if k < -2.6e101 or 0.10000000000000001 < k Initial program 82.2%
Taylor expanded in k around 0 68.1%
Taylor expanded in m around 0 27.0%
Taylor expanded in k around inf 27.0%
*-commutative27.0%
Simplified27.0%
if -2.6e101 < k < 0.10000000000000001Initial program 99.9%
Taylor expanded in m around 0 39.4%
Taylor expanded in k around 0 37.5%
Final simplification32.5%
(FPCore (a k m) :precision binary64 (if (or (<= k -3.4e-274) (not (<= k 1.0))) (/ a (* k k)) a))
double code(double a, double k, double m) {
double tmp;
if ((k <= -3.4e-274) || !(k <= 1.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 <= (-3.4d-274)) .or. (.not. (k <= 1.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 <= -3.4e-274) || !(k <= 1.0)) {
tmp = a / (k * k);
} else {
tmp = a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if (k <= -3.4e-274) or not (k <= 1.0): tmp = a / (k * k) else: tmp = a return tmp
function code(a, k, m) tmp = 0.0 if ((k <= -3.4e-274) || !(k <= 1.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 <= -3.4e-274) || ~((k <= 1.0))) tmp = a / (k * k); else tmp = a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[k, -3.4e-274], N[Not[LessEqual[k, 1.0]], $MachinePrecision]], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], a]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq -3.4 \cdot 10^{-274} \lor \neg \left(k \leq 1\right):\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if k < -3.39999999999999981e-274 or 1 < k Initial program 87.1%
Taylor expanded in m around 0 43.8%
Taylor expanded in k around inf 46.0%
unpow246.0%
Simplified46.0%
if -3.39999999999999981e-274 < k < 1Initial program 99.9%
Taylor expanded in m around 0 58.1%
Taylor expanded in k around 0 55.2%
Final simplification49.2%
(FPCore (a k m) :precision binary64 (if (<= m -0.5) (/ a (* k k)) (/ a (+ 1.0 (* k k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.5) {
tmp = a / (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.5d0)) then
tmp = a / (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.5) {
tmp = a / (k * k);
} else {
tmp = a / (1.0 + (k * k));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.5: tmp = a / (k * k) else: tmp = a / (1.0 + (k * k)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.5) tmp = Float64(a / 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.5) tmp = a / (k * k); else tmp = a / (1.0 + (k * k)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.5], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.5:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\
\end{array}
\end{array}
if m < -0.5Initial program 100.0%
Taylor expanded in m around 0 43.0%
Taylor expanded in k around inf 59.9%
unpow259.9%
Simplified59.9%
if -0.5 < m Initial program 87.9%
Taylor expanded in m around 0 51.1%
Taylor expanded in k around 0 48.7%
Final simplification52.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 91.5%
Taylor expanded in m around 0 48.7%
Taylor expanded in k around 0 21.7%
Final simplification21.7%
herbie shell --seed 2023238
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))