
(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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
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}
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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
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
(if (<= k 8e-15)
(* a (pow k m))
(/
(/ (* (pow k m) a) (fma (/ 1.0 (fabs k)) (fma 10.0 k 1.0) (fabs k)))
(fabs k))))
double code(double a, double k, double m) {
double tmp;
if (k <= 8e-15) {
tmp = a * pow(k, m);
} else {
tmp = ((pow(k, m) * a) / fma((1.0 / fabs(k)), fma(10.0, k, 1.0), fabs(k))) / fabs(k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (k <= 8e-15) tmp = Float64(a * (k ^ m)); else tmp = Float64(Float64(Float64((k ^ m) * a) / fma(Float64(1.0 / abs(k)), fma(10.0, k, 1.0), abs(k))) / abs(k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[k, 8e-15], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision] / N[(N[(1.0 / N[Abs[k], $MachinePrecision]), $MachinePrecision] * N[(10.0 * k + 1.0), $MachinePrecision] + N[Abs[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Abs[k], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 8 \cdot 10^{-15}:\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{k}^{m} \cdot a}{\mathsf{fma}\left(\frac{1}{\left|k\right|}, \mathsf{fma}\left(10, k, 1\right), \left|k\right|\right)}}{\left|k\right|}\\
\end{array}
\end{array}
if k < 8.0000000000000006e-15Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7
Applied rewrites20.7%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.8
Applied rewrites82.8%
if 8.0000000000000006e-15 < k Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Applied rewrites96.0%
(FPCore (a k m)
:precision binary64
(if (<= k 4e-30)
(* a (pow k m))
(*
(/ (pow k m) (fma (/ 1.0 (fabs k)) (fma 10.0 k 1.0) (fabs k)))
(/ a (fabs k)))))
double code(double a, double k, double m) {
double tmp;
if (k <= 4e-30) {
tmp = a * pow(k, m);
} else {
tmp = (pow(k, m) / fma((1.0 / fabs(k)), fma(10.0, k, 1.0), fabs(k))) * (a / fabs(k));
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (k <= 4e-30) tmp = Float64(a * (k ^ m)); else tmp = Float64(Float64((k ^ m) / fma(Float64(1.0 / abs(k)), fma(10.0, k, 1.0), abs(k))) * Float64(a / abs(k))); end return tmp end
code[a_, k_, m_] := If[LessEqual[k, 4e-30], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[k, m], $MachinePrecision] / N[(N[(1.0 / N[Abs[k], $MachinePrecision]), $MachinePrecision] * N[(10.0 * k + 1.0), $MachinePrecision] + N[Abs[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a / N[Abs[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 4 \cdot 10^{-30}:\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;\frac{{k}^{m}}{\mathsf{fma}\left(\frac{1}{\left|k\right|}, \mathsf{fma}\left(10, k, 1\right), \left|k\right|\right)} \cdot \frac{a}{\left|k\right|}\\
\end{array}
\end{array}
if k < 4e-30Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7
Applied rewrites20.7%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.8
Applied rewrites82.8%
if 4e-30 < k Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Applied rewrites88.0%
(FPCore (a k m) :precision binary64 (if (<= m 0.175) (/ (* (/ 2.0 (fma (- k -10.0) k 1.0)) (* (pow k m) a)) 2.0) (* a (pow k m))))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.175) {
tmp = ((2.0 / fma((k - -10.0), k, 1.0)) * (pow(k, m) * a)) / 2.0;
} else {
tmp = a * pow(k, m);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 0.175) tmp = Float64(Float64(Float64(2.0 / fma(Float64(k - -10.0), k, 1.0)) * Float64((k ^ m) * a)) / 2.0); else tmp = Float64(a * (k ^ m)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 0.175], N[(N[(N[(2.0 / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.175:\\
\;\;\;\;\frac{\frac{2}{\mathsf{fma}\left(k - -10, k, 1\right)} \cdot \left({k}^{m} \cdot a\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;a \cdot {k}^{m}\\
\end{array}
\end{array}
if m < 0.17499999999999999Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
if 0.17499999999999999 < m Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7
Applied rewrites20.7%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.8
Applied rewrites82.8%
(FPCore (a k m) :precision binary64 (if (<= m 0.175) (* (/ (pow k m) (fma (- k -10.0) k 1.0)) a) (* a (pow k m))))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.175) {
tmp = (pow(k, m) / fma((k - -10.0), k, 1.0)) * a;
} else {
tmp = a * pow(k, m);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 0.175) tmp = Float64(Float64((k ^ m) / fma(Float64(k - -10.0), k, 1.0)) * a); else tmp = Float64(a * (k ^ m)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 0.175], N[(N[(N[Power[k, m], $MachinePrecision] / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.175:\\
\;\;\;\;\frac{{k}^{m}}{\mathsf{fma}\left(k - -10, k, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;a \cdot {k}^{m}\\
\end{array}
\end{array}
if m < 0.17499999999999999Initial program 90.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6490.5
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
metadata-eval90.5
Applied rewrites90.5%
if 0.17499999999999999 < m Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7
Applied rewrites20.7%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.8
Applied rewrites82.8%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* a (pow k m))))
(if (<= m -1.6e-8)
t_0
(if (<= m 1.82e-6) (* (/ 1.0 (fma (- k -10.0) k 1.0)) a) t_0))))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double tmp;
if (m <= -1.6e-8) {
tmp = t_0;
} else if (m <= 1.82e-6) {
tmp = (1.0 / fma((k - -10.0), k, 1.0)) * a;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64(a * (k ^ m)) tmp = 0.0 if (m <= -1.6e-8) tmp = t_0; elseif (m <= 1.82e-6) tmp = Float64(Float64(1.0 / fma(Float64(k - -10.0), k, 1.0)) * a); 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[m, -1.6e-8], t$95$0, If[LessEqual[m, 1.82e-6], N[(N[(1.0 / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;m \leq -1.6 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 1.82 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(k - -10, k, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -1.6000000000000001e-8 or 1.8199999999999999e-6 < m Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7
Applied rewrites20.7%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.8
Applied rewrites82.8%
if -1.6000000000000001e-8 < m < 1.8199999999999999e-6Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6444.8
Applied rewrites44.8%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
(if (<= t_0 1e-322)
(/ (/ a (+ (fabs k) (/ 1.0 (fabs k)))) (fabs k))
(if (<= t_0 1e+207)
(* (/ 1.0 (fma (- k -10.0) k 1.0)) a)
(* (+ 1.0 (* k (- (* 99.0 k) 10.0))) a)))))
double code(double a, double k, double m) {
double t_0 = (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_0 <= 1e-322) {
tmp = (a / (fabs(k) + (1.0 / fabs(k)))) / fabs(k);
} else if (t_0 <= 1e+207) {
tmp = (1.0 / fma((k - -10.0), k, 1.0)) * a;
} else {
tmp = (1.0 + (k * ((99.0 * k) - 10.0))) * a;
}
return tmp;
}
function code(a, k, m) t_0 = Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) tmp = 0.0 if (t_0 <= 1e-322) tmp = Float64(Float64(a / Float64(abs(k) + Float64(1.0 / abs(k)))) / abs(k)); elseif (t_0 <= 1e+207) tmp = Float64(Float64(1.0 / fma(Float64(k - -10.0), k, 1.0)) * a); else tmp = Float64(Float64(1.0 + Float64(k * Float64(Float64(99.0 * k) - 10.0))) * a); end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, 1e-322], N[(N[(a / N[(N[Abs[k], $MachinePrecision] + N[(1.0 / N[Abs[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Abs[k], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+207], N[(N[(1.0 / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(N[(1.0 + N[(k * N[(N[(99.0 * k), $MachinePrecision] - 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
\mathbf{if}\;t\_0 \leq 10^{-322}:\\
\;\;\;\;\frac{\frac{a}{\left|k\right| + \frac{1}{\left|k\right|}}}{\left|k\right|}\\
\mathbf{elif}\;t\_0 \leq 10^{+207}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(k - -10, k, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(1 + k \cdot \left(99 \cdot k - 10\right)\right) \cdot a\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 9.88131e-323Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Applied rewrites96.0%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fabs.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-/.f64N/A
lower-fabs.f6444.6
Applied rewrites44.6%
Taylor expanded in k around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fabs.f64N/A
lower-/.f64N/A
lower-fabs.f6443.9
Applied rewrites43.9%
if 9.88131e-323 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 1e207Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6444.8
Applied rewrites44.8%
if 1e207 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6444.8
Applied rewrites44.8%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6428.8
Applied rewrites28.8%
(FPCore (a k m) :precision binary64 (if (<= (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))) 1e+207) (* (/ 1.0 (fma (- k -10.0) k 1.0)) a) (* (+ 1.0 (* k (- (* 99.0 k) 10.0))) a)))
double code(double a, double k, double m) {
double tmp;
if (((a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))) <= 1e+207) {
tmp = (1.0 / fma((k - -10.0), k, 1.0)) * a;
} else {
tmp = (1.0 + (k * ((99.0 * k) - 10.0))) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) <= 1e+207) tmp = Float64(Float64(1.0 / fma(Float64(k - -10.0), k, 1.0)) * a); else tmp = Float64(Float64(1.0 + Float64(k * Float64(Float64(99.0 * k) - 10.0))) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[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], 1e+207], N[(N[(1.0 / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(N[(1.0 + N[(k * N[(N[(99.0 * k), $MachinePrecision] - 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq 10^{+207}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(k - -10, k, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(1 + k \cdot \left(99 \cdot k - 10\right)\right) \cdot a\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 1e207Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6444.8
Applied rewrites44.8%
if 1e207 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6444.8
Applied rewrites44.8%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6428.8
Applied rewrites28.8%
(FPCore (a k m) :precision binary64 (if (<= (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))) 2e+287) (* (/ 1.0 (fma (- k -10.0) k 1.0)) a) (* k (fma -10.0 a (/ a k)))))
double code(double a, double k, double m) {
double tmp;
if (((a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))) <= 2e+287) {
tmp = (1.0 / fma((k - -10.0), k, 1.0)) * a;
} else {
tmp = k * fma(-10.0, a, (a / k));
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) <= 2e+287) tmp = Float64(Float64(1.0 / fma(Float64(k - -10.0), k, 1.0)) * a); else tmp = Float64(k * fma(-10.0, a, Float64(a / k))); end return tmp end
code[a_, k_, m_] := If[LessEqual[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], 2e+287], N[(N[(1.0 / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(k * N[(-10.0 * a + N[(a / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq 2 \cdot 10^{+287}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(k - -10, k, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;k \cdot \mathsf{fma}\left(-10, a, \frac{a}{k}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 2.0000000000000002e287Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6444.8
Applied rewrites44.8%
if 2.0000000000000002e287 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7
Applied rewrites20.7%
Taylor expanded in k around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f6419.9
Applied rewrites19.9%
(FPCore (a k m) :precision binary64 (if (<= (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))) 2e+287) (/ a (fma (- k -10.0) k 1.0)) (* k (fma -10.0 a (/ a k)))))
double code(double a, double k, double m) {
double tmp;
if (((a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))) <= 2e+287) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = k * fma(-10.0, a, (a / k));
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) <= 2e+287) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(k * fma(-10.0, a, Float64(a / k))); end return tmp end
code[a_, k_, m_] := If[LessEqual[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], 2e+287], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(k * N[(-10.0 * a + N[(a / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq 2 \cdot 10^{+287}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;k \cdot \mathsf{fma}\left(-10, a, \frac{a}{k}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 2.0000000000000002e287Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f6444.9
Applied rewrites44.9%
if 2.0000000000000002e287 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7
Applied rewrites20.7%
Taylor expanded in k around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f6419.9
Applied rewrites19.9%
(FPCore (a k m) :precision binary64 (/ a (fma (- k -10.0) k 1.0)))
double code(double a, double k, double m) {
return a / fma((k - -10.0), k, 1.0);
}
function code(a, k, m) return Float64(a / fma(Float64(k - -10.0), k, 1.0)) end
code[a_, k_, m_] := N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}
\end{array}
Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f6444.9
Applied rewrites44.9%
(FPCore (a k m) :precision binary64 (if (<= m 2.8e+33) (/ a (+ 1.0 (* k 10.0))) (* (fma -10.0 k 1.0) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 2.8e+33) {
tmp = a / (1.0 + (k * 10.0));
} else {
tmp = fma(-10.0, k, 1.0) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 2.8e+33) tmp = Float64(a / Float64(1.0 + Float64(k * 10.0))); else tmp = Float64(fma(-10.0, k, 1.0) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 2.8e+33], N[(a / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-10.0 * k + 1.0), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.8 \cdot 10^{+33}:\\
\;\;\;\;\frac{a}{1 + k \cdot 10}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-10, k, 1\right) \cdot a\\
\end{array}
\end{array}
if m < 2.8000000000000001e33Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around 0
Applied rewrites28.1%
if 2.8000000000000001e33 < m Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7
Applied rewrites20.7%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
distribute-rgt1-inN/A
lower-*.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
lower-fma.f6420.7
Applied rewrites20.7%
(FPCore (a k m) :precision binary64 (fma (* -10.0 a) k a))
double code(double a, double k, double m) {
return fma((-10.0 * a), k, a);
}
function code(a, k, m) return fma(Float64(-10.0 * a), k, a) end
code[a_, k_, m_] := N[(N[(-10.0 * a), $MachinePrecision] * k + a), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-10 \cdot a, k, a\right)
\end{array}
Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7
Applied rewrites20.7%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
remove-double-negN/A
lower-fma.f64N/A
lower-*.f6420.7
Applied rewrites20.7%
(FPCore (a k m) :precision binary64 (* (fma -10.0 k 1.0) a))
double code(double a, double k, double m) {
return fma(-10.0, k, 1.0) * a;
}
function code(a, k, m) return Float64(fma(-10.0, k, 1.0) * a) end
code[a_, k_, m_] := N[(N[(-10.0 * k + 1.0), $MachinePrecision] * a), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-10, k, 1\right) \cdot a
\end{array}
Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7
Applied rewrites20.7%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
distribute-rgt1-inN/A
lower-*.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
lower-fma.f6420.7
Applied rewrites20.7%
herbie shell --seed 2025154
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))