
(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))))
(if (<= (/ t_0 (+ (+ 1.0 (* k 10.0)) (* k k))) 1e+305)
(/ a (/ (+ 1.0 (+ (* k k) (* k 10.0))) (pow k m)))
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+305) {
tmp = a / ((1.0 + ((k * k) + (k * 10.0))) / pow(k, m));
} 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 ((t_0 / ((1.0d0 + (k * 10.0d0)) + (k * k))) <= 1d+305) then
tmp = a / ((1.0d0 + ((k * k) + (k * 10.0d0))) / (k ** m))
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 ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 1e+305) {
tmp = a / ((1.0 + ((k * k) + (k * 10.0))) / Math.pow(k, m));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a * math.pow(k, m) tmp = 0 if (t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 1e+305: tmp = a / ((1.0 + ((k * k) + (k * 10.0))) / math.pow(k, m)) 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+305) tmp = Float64(a / Float64(Float64(1.0 + Float64(Float64(k * k) + Float64(k * 10.0))) / (k ^ m))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a * (k ^ m); tmp = 0.0; if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 1e+305) tmp = a / ((1.0 + ((k * k) + (k * 10.0))) / (k ^ m)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+305], N[(a / N[(N[(1.0 + N[(N[(k * k), $MachinePrecision] + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[k, m], $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^{+305}:\\
\;\;\;\;\frac{a}{\frac{1 + \left(k \cdot k + k \cdot 10\right)}{{k}^{m}}}\\
\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))) < 9.9999999999999994e304Initial program 98.1%
associate-/l*98.1%
associate-+l+98.1%
*-commutative98.1%
Simplified98.1%
if 9.9999999999999994e304 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k))) Initial program 51.1%
associate-*r/51.1%
associate-+l+51.1%
+-commutative51.1%
distribute-rgt-out51.1%
fma-def51.1%
+-commutative51.1%
Simplified51.1%
Taylor expanded in k around 0 51.1%
exp-to-pow100.0%
*-commutative100.0%
Simplified100.0%
Final simplification98.4%
(FPCore (a k m) :precision binary64 (if (or (<= m -65.0) (not (<= m 0.62))) (* a (pow k m)) (/ a (+ 1.0 (* k (+ k 10.0))))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -65.0) || !(m <= 0.62)) {
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 <= (-65.0d0)) .or. (.not. (m <= 0.62d0))) 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 <= -65.0) || !(m <= 0.62)) {
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 <= -65.0) or not (m <= 0.62): 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 <= -65.0) || !(m <= 0.62)) 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 <= -65.0) || ~((m <= 0.62))) 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, -65.0], N[Not[LessEqual[m, 0.62]], $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 -65 \lor \neg \left(m \leq 0.62\right):\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -65 or 0.619999999999999996 < m Initial program 85.1%
associate-*r/85.1%
associate-+l+85.1%
+-commutative85.1%
distribute-rgt-out85.1%
fma-def85.1%
+-commutative85.1%
Simplified85.1%
Taylor expanded in k around 0 56.1%
exp-to-pow100.0%
*-commutative100.0%
Simplified100.0%
if -65 < m < 0.619999999999999996Initial program 96.2%
associate-*r/96.2%
associate-+l+96.2%
+-commutative96.2%
distribute-rgt-out96.2%
fma-def96.2%
+-commutative96.2%
Simplified96.2%
Taylor expanded in m around 0 95.6%
Final simplification98.1%
(FPCore (a k m) :precision binary64 (if (<= m -65.0) (/ a (* k k)) (if (<= m 2.15) (/ a (+ 1.0 (* k k))) (+ a (* a (* k (* k 100.0)))))))
double code(double a, double k, double m) {
double tmp;
if (m <= -65.0) {
tmp = a / (k * k);
} else if (m <= 2.15) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a + (a * (k * (k * 100.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 <= (-65.0d0)) then
tmp = a / (k * k)
else if (m <= 2.15d0) then
tmp = a / (1.0d0 + (k * k))
else
tmp = a + (a * (k * (k * 100.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -65.0) {
tmp = a / (k * k);
} else if (m <= 2.15) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a + (a * (k * (k * 100.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -65.0: tmp = a / (k * k) elif m <= 2.15: tmp = a / (1.0 + (k * k)) else: tmp = a + (a * (k * (k * 100.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -65.0) tmp = Float64(a / Float64(k * k)); elseif (m <= 2.15) tmp = Float64(a / Float64(1.0 + Float64(k * k))); else tmp = Float64(a + Float64(a * Float64(k * Float64(k * 100.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -65.0) tmp = a / (k * k); elseif (m <= 2.15) tmp = a / (1.0 + (k * k)); else tmp = a + (a * (k * (k * 100.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -65.0], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 2.15], N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(a * N[(k * N[(k * 100.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -65:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 2.15:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a + a \cdot \left(k \cdot \left(k \cdot 100\right)\right)\\
\end{array}
\end{array}
if m < -65Initial 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 39.5%
Taylor expanded in k around inf 63.0%
unpow263.0%
Simplified63.0%
if -65 < m < 2.14999999999999991Initial program 96.2%
associate-*r/96.2%
associate-+l+96.2%
+-commutative96.2%
distribute-rgt-out96.2%
fma-def96.2%
+-commutative96.2%
Simplified96.2%
Taylor expanded in m around 0 95.6%
Taylor expanded in k around inf 93.4%
unpow293.4%
Simplified93.4%
if 2.14999999999999991 < m Initial program 73.5%
associate-*r/73.5%
associate-+l+73.5%
+-commutative73.5%
distribute-rgt-out73.5%
fma-def73.5%
+-commutative73.5%
Simplified73.5%
Taylor expanded in m around 0 2.7%
Taylor expanded in k around 0 2.5%
*-commutative2.5%
Simplified2.5%
Taylor expanded in k around 0 28.8%
+-commutative28.8%
unpow228.8%
associate-*r*28.8%
*-commutative28.8%
associate-*r*27.6%
*-commutative27.6%
metadata-eval27.6%
distribute-rgt-neg-in27.6%
distribute-rgt-out34.8%
associate-*l*34.8%
distribute-rgt-neg-in34.8%
metadata-eval34.8%
distribute-lft-out36.0%
Simplified36.0%
Taylor expanded in k around inf 36.0%
*-commutative36.0%
*-commutative36.0%
associate-*r*36.0%
unpow236.0%
associate-*r*36.0%
Simplified36.0%
Final simplification67.1%
(FPCore (a k m)
:precision binary64
(if (<= m -65.0)
(/ a (* k k))
(if (<= m 2.2)
(/ a (+ 1.0 (* k (+ k 10.0))))
(+ a (* a (* k (* k 100.0)))))))
double code(double a, double k, double m) {
double tmp;
if (m <= -65.0) {
tmp = a / (k * k);
} else if (m <= 2.2) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (a * (k * (k * 100.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 <= (-65.0d0)) then
tmp = a / (k * k)
else if (m <= 2.2d0) then
tmp = a / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = a + (a * (k * (k * 100.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -65.0) {
tmp = a / (k * k);
} else if (m <= 2.2) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (a * (k * (k * 100.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -65.0: tmp = a / (k * k) elif m <= 2.2: tmp = a / (1.0 + (k * (k + 10.0))) else: tmp = a + (a * (k * (k * 100.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -65.0) tmp = Float64(a / Float64(k * k)); elseif (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 * 100.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -65.0) tmp = a / (k * k); elseif (m <= 2.2) tmp = a / (1.0 + (k * (k + 10.0))); else tmp = a + (a * (k * (k * 100.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -65.0], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], 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 * 100.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -65:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 2.2:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a + a \cdot \left(k \cdot \left(k \cdot 100\right)\right)\\
\end{array}
\end{array}
if m < -65Initial 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 39.5%
Taylor expanded in k around inf 63.0%
unpow263.0%
Simplified63.0%
if -65 < m < 2.2000000000000002Initial program 96.2%
associate-*r/96.2%
associate-+l+96.2%
+-commutative96.2%
distribute-rgt-out96.2%
fma-def96.2%
+-commutative96.2%
Simplified96.2%
Taylor expanded in m around 0 95.6%
if 2.2000000000000002 < m Initial program 73.5%
associate-*r/73.5%
associate-+l+73.5%
+-commutative73.5%
distribute-rgt-out73.5%
fma-def73.5%
+-commutative73.5%
Simplified73.5%
Taylor expanded in m around 0 2.7%
Taylor expanded in k around 0 2.5%
*-commutative2.5%
Simplified2.5%
Taylor expanded in k around 0 28.8%
+-commutative28.8%
unpow228.8%
associate-*r*28.8%
*-commutative28.8%
associate-*r*27.6%
*-commutative27.6%
metadata-eval27.6%
distribute-rgt-neg-in27.6%
distribute-rgt-out34.8%
associate-*l*34.8%
distribute-rgt-neg-in34.8%
metadata-eval34.8%
distribute-lft-out36.0%
Simplified36.0%
Taylor expanded in k around inf 36.0%
*-commutative36.0%
*-commutative36.0%
associate-*r*36.0%
unpow236.0%
associate-*r*36.0%
Simplified36.0%
Final simplification68.0%
(FPCore (a k m) :precision binary64 (if (<= k -4.5e-299) (/ 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 <= -4.5e-299) {
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 <= (-4.5d-299)) 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 <= -4.5e-299) {
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 <= -4.5e-299: 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 <= -4.5e-299) 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 <= -4.5e-299) 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, -4.5e-299], 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 -4.5 \cdot 10^{-299}:\\
\;\;\;\;\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 < -4.50000000000000003e-299Initial program 84.4%
associate-*r/84.4%
associate-+l+84.4%
+-commutative84.4%
distribute-rgt-out84.4%
fma-def84.4%
+-commutative84.4%
Simplified84.4%
Taylor expanded in m around 0 15.3%
Taylor expanded in k around inf 25.3%
unpow225.3%
Simplified25.3%
if -4.50000000000000003e-299 < k < 0.10000000000000001Initial 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 52.5%
Taylor expanded in k around 0 51.9%
*-commutative51.9%
Simplified51.9%
if 0.10000000000000001 < k Initial program 84.4%
associate-*r/84.4%
associate-+l+84.4%
+-commutative84.4%
distribute-rgt-out84.4%
fma-def84.4%
+-commutative84.4%
Simplified84.4%
Taylor expanded in m around 0 72.4%
Taylor expanded in k around inf 71.1%
unpow271.1%
Simplified71.1%
*-un-lft-identity71.1%
times-frac71.2%
Applied egg-rr71.2%
associate-*l/71.3%
*-un-lft-identity71.3%
Applied egg-rr71.3%
Final simplification53.0%
(FPCore (a k m) :precision binary64 (if (<= k -4.5e-299) (/ a (* k k)) (if (<= k 10.2) (/ a (+ 1.0 (* k 10.0))) (/ (/ a k) k))))
double code(double a, double k, double m) {
double tmp;
if (k <= -4.5e-299) {
tmp = a / (k * k);
} else if (k <= 10.2) {
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 <= (-4.5d-299)) then
tmp = a / (k * k)
else if (k <= 10.2d0) 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 <= -4.5e-299) {
tmp = a / (k * k);
} else if (k <= 10.2) {
tmp = a / (1.0 + (k * 10.0));
} else {
tmp = (a / k) / k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= -4.5e-299: tmp = a / (k * k) elif k <= 10.2: tmp = a / (1.0 + (k * 10.0)) else: tmp = (a / k) / k return tmp
function code(a, k, m) tmp = 0.0 if (k <= -4.5e-299) tmp = Float64(a / Float64(k * k)); elseif (k <= 10.2) 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 <= -4.5e-299) tmp = a / (k * k); elseif (k <= 10.2) tmp = a / (1.0 + (k * 10.0)); else tmp = (a / k) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, -4.5e-299], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 10.2], 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 -4.5 \cdot 10^{-299}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 10.2:\\
\;\;\;\;\frac{a}{1 + k \cdot 10}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\end{array}
\end{array}
if k < -4.50000000000000003e-299Initial program 84.4%
associate-*r/84.4%
associate-+l+84.4%
+-commutative84.4%
distribute-rgt-out84.4%
fma-def84.4%
+-commutative84.4%
Simplified84.4%
Taylor expanded in m around 0 15.3%
Taylor expanded in k around inf 25.3%
unpow225.3%
Simplified25.3%
if -4.50000000000000003e-299 < k < 10.199999999999999Initial 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 52.5%
Taylor expanded in k around 0 52.0%
*-commutative52.0%
Simplified52.0%
if 10.199999999999999 < k Initial program 84.4%
associate-*r/84.4%
associate-+l+84.4%
+-commutative84.4%
distribute-rgt-out84.4%
fma-def84.4%
+-commutative84.4%
Simplified84.4%
Taylor expanded in m around 0 72.4%
Taylor expanded in k around inf 71.1%
unpow271.1%
Simplified71.1%
*-un-lft-identity71.1%
times-frac71.2%
Applied egg-rr71.2%
associate-*l/71.3%
*-un-lft-identity71.3%
Applied egg-rr71.3%
Final simplification53.1%
(FPCore (a k m) :precision binary64 (if (<= m -65.0) (/ a (* k k)) (if (<= m 1950.0) (/ a (+ 1.0 (* k k))) (* -10.0 (* a k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -65.0) {
tmp = a / (k * k);
} else if (m <= 1950.0) {
tmp = a / (1.0 + (k * k));
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= (-65.0d0)) then
tmp = a / (k * k)
else if (m <= 1950.0d0) then
tmp = a / (1.0d0 + (k * k))
else
tmp = (-10.0d0) * (a * k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -65.0) {
tmp = a / (k * k);
} else if (m <= 1950.0) {
tmp = a / (1.0 + (k * k));
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -65.0: tmp = a / (k * k) elif m <= 1950.0: tmp = a / (1.0 + (k * k)) else: tmp = -10.0 * (a * k) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -65.0) tmp = Float64(a / Float64(k * k)); elseif (m <= 1950.0) tmp = Float64(a / Float64(1.0 + Float64(k * k))); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -65.0) tmp = a / (k * k); elseif (m <= 1950.0) tmp = a / (1.0 + (k * k)); else tmp = -10.0 * (a * k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -65.0], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1950.0], N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -65:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1950:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < -65Initial 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 39.5%
Taylor expanded in k around inf 63.0%
unpow263.0%
Simplified63.0%
if -65 < m < 1950Initial program 96.2%
associate-*r/96.2%
associate-+l+96.2%
+-commutative96.2%
distribute-rgt-out96.2%
fma-def96.2%
+-commutative96.2%
Simplified96.2%
Taylor expanded in m around 0 95.6%
Taylor expanded in k around inf 93.4%
unpow293.4%
Simplified93.4%
if 1950 < m Initial program 73.5%
associate-*r/73.5%
associate-+l+73.5%
+-commutative73.5%
distribute-rgt-out73.5%
fma-def73.5%
+-commutative73.5%
Simplified73.5%
Taylor expanded in m around 0 2.7%
Taylor expanded in k around 0 9.8%
*-commutative9.8%
Simplified9.8%
Taylor expanded in k around inf 19.0%
Final simplification61.6%
(FPCore (a k m) :precision binary64 (if (or (<= k -4.5e-299) (not (<= k 1.0))) (/ a (* k k)) a))
double code(double a, double k, double m) {
double tmp;
if ((k <= -4.5e-299) || !(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 <= (-4.5d-299)) .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 <= -4.5e-299) || !(k <= 1.0)) {
tmp = a / (k * k);
} else {
tmp = a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if (k <= -4.5e-299) or not (k <= 1.0): tmp = a / (k * k) else: tmp = a return tmp
function code(a, k, m) tmp = 0.0 if ((k <= -4.5e-299) || !(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 <= -4.5e-299) || ~((k <= 1.0))) tmp = a / (k * k); else tmp = a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[k, -4.5e-299], 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 -4.5 \cdot 10^{-299} \lor \neg \left(k \leq 1\right):\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if k < -4.50000000000000003e-299 or 1 < k Initial program 84.4%
associate-*r/84.4%
associate-+l+84.4%
+-commutative84.4%
distribute-rgt-out84.4%
fma-def84.4%
+-commutative84.4%
Simplified84.4%
Taylor expanded in m around 0 50.5%
Taylor expanded in k around inf 53.5%
unpow253.5%
Simplified53.5%
if -4.50000000000000003e-299 < k < 1Initial 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 52.5%
Taylor expanded in k around 0 51.4%
Final simplification52.8%
(FPCore (a k m) :precision binary64 (if (<= k -4.5e-299) (/ a (* k k)) (if (<= k 1.0) a (/ (/ a k) k))))
double code(double a, double k, double m) {
double tmp;
if (k <= -4.5e-299) {
tmp = a / (k * k);
} else if (k <= 1.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 <= (-4.5d-299)) then
tmp = a / (k * k)
else if (k <= 1.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 <= -4.5e-299) {
tmp = a / (k * k);
} else if (k <= 1.0) {
tmp = a;
} else {
tmp = (a / k) / k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= -4.5e-299: tmp = a / (k * k) elif k <= 1.0: tmp = a else: tmp = (a / k) / k return tmp
function code(a, k, m) tmp = 0.0 if (k <= -4.5e-299) tmp = Float64(a / Float64(k * k)); elseif (k <= 1.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 <= -4.5e-299) tmp = a / (k * k); elseif (k <= 1.0) tmp = a; else tmp = (a / k) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, -4.5e-299], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 1.0], a, N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq -4.5 \cdot 10^{-299}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 1:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\end{array}
\end{array}
if k < -4.50000000000000003e-299Initial program 84.4%
associate-*r/84.4%
associate-+l+84.4%
+-commutative84.4%
distribute-rgt-out84.4%
fma-def84.4%
+-commutative84.4%
Simplified84.4%
Taylor expanded in m around 0 15.3%
Taylor expanded in k around inf 25.3%
unpow225.3%
Simplified25.3%
if -4.50000000000000003e-299 < k < 1Initial 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 52.5%
Taylor expanded in k around 0 51.4%
if 1 < k Initial program 84.4%
associate-*r/84.4%
associate-+l+84.4%
+-commutative84.4%
distribute-rgt-out84.4%
fma-def84.4%
+-commutative84.4%
Simplified84.4%
Taylor expanded in m around 0 72.4%
Taylor expanded in k around inf 71.1%
unpow271.1%
Simplified71.1%
*-un-lft-identity71.1%
times-frac71.2%
Applied egg-rr71.2%
associate-*l/71.3%
*-un-lft-identity71.3%
Applied egg-rr71.3%
Final simplification52.9%
(FPCore (a k m) :precision binary64 (if (<= m 1.25e+22) a (* -10.0 (* a k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.25e+22) {
tmp = a;
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 1.25d+22) then
tmp = a
else
tmp = (-10.0d0) * (a * k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1.25e+22) {
tmp = a;
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1.25e+22: tmp = a else: tmp = -10.0 * (a * k) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1.25e+22) tmp = a; else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1.25e+22) tmp = a; else tmp = -10.0 * (a * k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1.25e+22], a, N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.25 \cdot 10^{+22}:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < 1.2499999999999999e22Initial program 96.6%
associate-*r/96.5%
associate-+l+96.6%
+-commutative96.6%
distribute-rgt-out96.6%
fma-def96.6%
+-commutative96.6%
Simplified96.6%
Taylor expanded in m around 0 72.9%
Taylor expanded in k around 0 28.1%
if 1.2499999999999999e22 < m Initial program 74.7%
associate-*r/74.7%
associate-+l+74.7%
+-commutative74.7%
distribute-rgt-out74.7%
fma-def74.7%
+-commutative74.7%
Simplified74.7%
Taylor expanded in m around 0 2.7%
Taylor expanded in k around 0 10.2%
*-commutative10.2%
Simplified10.2%
Taylor expanded in k around inf 19.8%
Final simplification25.5%
(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 89.8%
associate-*r/89.8%
associate-+l+89.8%
+-commutative89.8%
distribute-rgt-out89.8%
fma-def89.8%
+-commutative89.8%
Simplified89.8%
Taylor expanded in m around 0 51.2%
Taylor expanded in k around 0 20.5%
Final simplification20.5%
herbie shell --seed 2023202
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))