
(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 14 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 (<= m 3.9) (* (/ a (fma k (/ k (fma 10.0 k 1.0)) 1.0)) (/ (pow k m) (fma 10.0 k 1.0))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.9) {
tmp = (a / fma(k, (k / fma(10.0, k, 1.0)), 1.0)) * (pow(k, m) / fma(10.0, k, 1.0));
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 3.9) tmp = Float64(Float64(a / fma(k, Float64(k / fma(10.0, k, 1.0)), 1.0)) * Float64((k ^ m) / fma(10.0, k, 1.0))); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 3.9], N[(N[(a / N[(k * N[(k / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[Power[k, m], $MachinePrecision] / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.9:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, \frac{k}{\mathsf{fma}\left(10, k, 1\right)}, 1\right)} \cdot \frac{{k}^{m}}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 3.89999999999999991Initial program 90.3%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
sum-to-multN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f6496.2
lift-+.f64N/A
Applied rewrites96.2%
if 3.89999999999999991 < m Initial program 90.3%
lift-/.f64N/A
lift-+.f64N/A
sum-to-multN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites96.2%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.5
Applied rewrites82.5%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6482.5
Applied rewrites82.5%
(FPCore (a k m) :precision binary64 (if (<= m 3.9) (* (/ a (- (/ k (- 10.0 (/ -1.0 k))) -1.0)) (/ (pow k m) (fma 10.0 k 1.0))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.9) {
tmp = (a / ((k / (10.0 - (-1.0 / k))) - -1.0)) * (pow(k, m) / fma(10.0, k, 1.0));
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 3.9) tmp = Float64(Float64(a / Float64(Float64(k / Float64(10.0 - Float64(-1.0 / k))) - -1.0)) * Float64((k ^ m) / fma(10.0, k, 1.0))); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 3.9], N[(N[(a / N[(N[(k / N[(10.0 - N[(-1.0 / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * N[(N[Power[k, m], $MachinePrecision] / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.9:\\
\;\;\;\;\frac{a}{\frac{k}{10 - \frac{-1}{k}} - -1} \cdot \frac{{k}^{m}}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 3.89999999999999991Initial program 90.3%
lift-/.f64N/A
lift-+.f64N/A
sum-to-multN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites96.2%
if 3.89999999999999991 < m Initial program 90.3%
lift-/.f64N/A
lift-+.f64N/A
sum-to-multN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites96.2%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.5
Applied rewrites82.5%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6482.5
Applied rewrites82.5%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -1.2e-11)
t_0
(if (<= m 0.095)
(* (/ a (- (/ k (- 10.0 (/ -1.0 k))) -1.0)) (/ 1.0 (+ 1.0 (* 10.0 k))))
t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= -1.2e-11) {
tmp = t_0;
} else if (m <= 0.095) {
tmp = (a / ((k / (10.0 - (-1.0 / k))) - -1.0)) * (1.0 / (1.0 + (10.0 * k)));
} else {
tmp = t_0;
}
return tmp;
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = (k ** m) * a
if (m <= (-1.2d-11)) then
tmp = t_0
else if (m <= 0.095d0) then
tmp = (a / ((k / (10.0d0 - ((-1.0d0) / k))) - (-1.0d0))) * (1.0d0 / (1.0d0 + (10.0d0 * k)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double t_0 = Math.pow(k, m) * a;
double tmp;
if (m <= -1.2e-11) {
tmp = t_0;
} else if (m <= 0.095) {
tmp = (a / ((k / (10.0 - (-1.0 / k))) - -1.0)) * (1.0 / (1.0 + (10.0 * k)));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = math.pow(k, m) * a tmp = 0 if m <= -1.2e-11: tmp = t_0 elif m <= 0.095: tmp = (a / ((k / (10.0 - (-1.0 / k))) - -1.0)) * (1.0 / (1.0 + (10.0 * k))) else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (m <= -1.2e-11) tmp = t_0; elseif (m <= 0.095) tmp = Float64(Float64(a / Float64(Float64(k / Float64(10.0 - Float64(-1.0 / k))) - -1.0)) * Float64(1.0 / Float64(1.0 + Float64(10.0 * k)))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = (k ^ m) * a; tmp = 0.0; if (m <= -1.2e-11) tmp = t_0; elseif (m <= 0.095) tmp = (a / ((k / (10.0 - (-1.0 / k))) - -1.0)) * (1.0 / (1.0 + (10.0 * k))); else tmp = t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[m, -1.2e-11], t$95$0, If[LessEqual[m, 0.095], N[(N[(a / N[(N[(k / N[(10.0 - N[(-1.0 / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq -1.2 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 0.095:\\
\;\;\;\;\frac{a}{\frac{k}{10 - \frac{-1}{k}} - -1} \cdot \frac{1}{1 + 10 \cdot k}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -1.2000000000000001e-11 or 0.095000000000000001 < m Initial program 90.3%
lift-/.f64N/A
lift-+.f64N/A
sum-to-multN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites96.2%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.5
Applied rewrites82.5%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6482.5
Applied rewrites82.5%
if -1.2000000000000001e-11 < m < 0.095000000000000001Initial program 90.3%
lift-/.f64N/A
lift-+.f64N/A
sum-to-multN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites96.2%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f6444.3
Applied rewrites44.3%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -1.2e-11)
t_0
(if (<= m 0.095)
(/ (/ a (- (/ k (- 10.0 (/ -1.0 k))) -1.0)) (fma 10.0 k 1.0))
t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= -1.2e-11) {
tmp = t_0;
} else if (m <= 0.095) {
tmp = (a / ((k / (10.0 - (-1.0 / k))) - -1.0)) / fma(10.0, k, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (m <= -1.2e-11) tmp = t_0; elseif (m <= 0.095) tmp = Float64(Float64(a / Float64(Float64(k / Float64(10.0 - Float64(-1.0 / k))) - -1.0)) / fma(10.0, k, 1.0)); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[m, -1.2e-11], t$95$0, If[LessEqual[m, 0.095], N[(N[(a / N[(N[(k / N[(10.0 - N[(-1.0 / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq -1.2 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 0.095:\\
\;\;\;\;\frac{\frac{a}{\frac{k}{10 - \frac{-1}{k}} - -1}}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -1.2000000000000001e-11 or 0.095000000000000001 < m Initial program 90.3%
lift-/.f64N/A
lift-+.f64N/A
sum-to-multN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites96.2%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.5
Applied rewrites82.5%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6482.5
Applied rewrites82.5%
if -1.2000000000000001e-11 < m < 0.095000000000000001Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
lift-/.f64N/A
lift-+.f64N/A
lift-fma.f64N/A
associate-+l+N/A
sum-to-multN/A
lift-pow.f64N/A
pow2N/A
+-commutativeN/A
lift-fma.f64N/A
associate-*r/N/A
lift-/.f64N/A
+-commutativeN/A
lift-fma.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites44.3%
(FPCore (a k m) :precision binary64 (/ (/ (* (pow k m) a) (fma k (/ k (fma 10.0 k 1.0)) 1.0)) (fma 10.0 k 1.0)))
double code(double a, double k, double m) {
return ((pow(k, m) * a) / fma(k, (k / fma(10.0, k, 1.0)), 1.0)) / fma(10.0, k, 1.0);
}
function code(a, k, m) return Float64(Float64(Float64((k ^ m) * a) / fma(k, Float64(k / fma(10.0, k, 1.0)), 1.0)) / fma(10.0, k, 1.0)) end
code[a_, k_, m_] := N[(N[(N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision] / N[(k * N[(k / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{{k}^{m} \cdot a}{\mathsf{fma}\left(k, \frac{k}{\mathsf{fma}\left(10, k, 1\right)}, 1\right)}}{\mathsf{fma}\left(10, k, 1\right)}
\end{array}
Initial program 90.3%
lift-/.f64N/A
lift-+.f64N/A
sum-to-multN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
(FPCore (a k m) :precision binary64 (if (<= m 3.5) (* (/ (pow k m) (fma k (+ 10.0 k) 1.0)) a) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.5) {
tmp = (pow(k, m) / fma(k, (10.0 + k), 1.0)) * a;
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 3.5) tmp = Float64(Float64((k ^ m) / fma(k, Float64(10.0 + k), 1.0)) * a); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 3.5], N[(N[(N[Power[k, m], $MachinePrecision] / N[(k * N[(10.0 + k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.5:\\
\;\;\;\;\frac{{k}^{m}}{\mathsf{fma}\left(k, 10 + k, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 3.5Initial program 90.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6490.3
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-+.f6490.3
Applied rewrites90.3%
if 3.5 < m Initial program 90.3%
lift-/.f64N/A
lift-+.f64N/A
sum-to-multN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites96.2%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.5
Applied rewrites82.5%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6482.5
Applied rewrites82.5%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -1.2e-11)
t_0
(if (<= m 0.095) (/ a (fma k 10.0 (fma k k 1.0))) t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= -1.2e-11) {
tmp = t_0;
} else if (m <= 0.095) {
tmp = a / fma(k, 10.0, fma(k, k, 1.0));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (m <= -1.2e-11) tmp = t_0; elseif (m <= 0.095) tmp = Float64(a / fma(k, 10.0, fma(k, k, 1.0))); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[m, -1.2e-11], t$95$0, If[LessEqual[m, 0.095], N[(a / N[(k * 10.0 + N[(k * k + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq -1.2 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 0.095:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, 10, \mathsf{fma}\left(k, k, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -1.2000000000000001e-11 or 0.095000000000000001 < m Initial program 90.3%
lift-/.f64N/A
lift-+.f64N/A
sum-to-multN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites96.2%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.5
Applied rewrites82.5%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6482.5
Applied rewrites82.5%
if -1.2000000000000001e-11 < m < 0.095000000000000001Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
lift-+.f64N/A
lift-fma.f64N/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lower-fma.f6444.6
Applied rewrites44.6%
(FPCore (a k m)
:precision binary64
(if (<= m -0.3)
(/ 1.0 (/ (* k k) a))
(if (<= m 120000.0)
(/ a (fma k 10.0 (fma k k 1.0)))
(* (+ 1.0 (* k (- (* 99.0 k) 10.0))) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.3) {
tmp = 1.0 / ((k * k) / a);
} else if (m <= 120000.0) {
tmp = a / fma(k, 10.0, fma(k, k, 1.0));
} else {
tmp = (1.0 + (k * ((99.0 * k) - 10.0))) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.3) tmp = Float64(1.0 / Float64(Float64(k * k) / a)); elseif (m <= 120000.0) tmp = Float64(a / fma(k, 10.0, fma(k, k, 1.0))); 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[m, -0.3], N[(1.0 / N[(N[(k * k), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 120000.0], N[(a / N[(k * 10.0 + N[(k * k + 1.0), $MachinePrecision]), $MachinePrecision]), $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}\;m \leq -0.3:\\
\;\;\;\;\frac{1}{\frac{k \cdot k}{a}}\\
\mathbf{elif}\;m \leq 120000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, 10, \mathsf{fma}\left(k, k, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + k \cdot \left(99 \cdot k - 10\right)\right) \cdot a\\
\end{array}
\end{array}
if m < -0.299999999999999989Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
div-flipN/A
lower-/.f64N/A
lower-/.f6435.8
Applied rewrites35.8%
if -0.299999999999999989 < m < 1.2e5Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
lift-+.f64N/A
lift-fma.f64N/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lower-fma.f6444.6
Applied rewrites44.6%
if 1.2e5 < m Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
lift-/.f64N/A
div-flipN/A
lift-+.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-inN/A
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f6444.6
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6444.6
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
metadata-eval44.6
Applied rewrites44.6%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6428.5
Applied rewrites28.5%
(FPCore (a k m)
:precision binary64
(if (<= m -0.3)
(/ 1.0 (/ (* k k) a))
(if (<= m 1.25e+16)
(/ a (fma k 10.0 (fma k k 1.0)))
(fma (* -10.0 k) a a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.3) {
tmp = 1.0 / ((k * k) / a);
} else if (m <= 1.25e+16) {
tmp = a / fma(k, 10.0, fma(k, k, 1.0));
} else {
tmp = fma((-10.0 * k), a, a);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.3) tmp = Float64(1.0 / Float64(Float64(k * k) / a)); elseif (m <= 1.25e+16) tmp = Float64(a / fma(k, 10.0, fma(k, k, 1.0))); else tmp = fma(Float64(-10.0 * k), a, a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.3], N[(1.0 / N[(N[(k * k), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.25e+16], N[(a / N[(k * 10.0 + N[(k * k + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-10.0 * k), $MachinePrecision] * a + a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.3:\\
\;\;\;\;\frac{1}{\frac{k \cdot k}{a}}\\
\mathbf{elif}\;m \leq 1.25 \cdot 10^{+16}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, 10, \mathsf{fma}\left(k, k, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-10 \cdot k, a, a\right)\\
\end{array}
\end{array}
if m < -0.299999999999999989Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
div-flipN/A
lower-/.f64N/A
lower-/.f6435.8
Applied rewrites35.8%
if -0.299999999999999989 < m < 1.25e16Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
lift-+.f64N/A
lift-fma.f64N/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lower-fma.f6444.6
Applied rewrites44.6%
if 1.25e16 < m Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.6
Applied rewrites20.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
lower-*.f6420.6
Applied rewrites20.6%
(FPCore (a k m) :precision binary64 (if (<= m -0.3) (/ 1.0 (/ (* k k) a)) (if (<= m 1.25e+16) (/ a (fma (- k -10.0) k 1.0)) (fma (* -10.0 k) a a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.3) {
tmp = 1.0 / ((k * k) / a);
} else if (m <= 1.25e+16) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = fma((-10.0 * k), a, a);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.3) tmp = Float64(1.0 / Float64(Float64(k * k) / a)); elseif (m <= 1.25e+16) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = fma(Float64(-10.0 * k), a, a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.3], N[(1.0 / N[(N[(k * k), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.25e+16], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(-10.0 * k), $MachinePrecision] * a + a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.3:\\
\;\;\;\;\frac{1}{\frac{k \cdot k}{a}}\\
\mathbf{elif}\;m \leq 1.25 \cdot 10^{+16}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-10 \cdot k, a, a\right)\\
\end{array}
\end{array}
if m < -0.299999999999999989Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
div-flipN/A
lower-/.f64N/A
lower-/.f6435.8
Applied rewrites35.8%
if -0.299999999999999989 < m < 1.25e16Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
lift-+.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-inN/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6444.6
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
metadata-eval44.6
Applied rewrites44.6%
if 1.25e16 < m Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.6
Applied rewrites20.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
lower-*.f6420.6
Applied rewrites20.6%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ a (* k k)))
(t_1 (+ 1.0 (* 10.0 k)))
(t_2 (/ (* a (pow k m)) (+ t_1 (* k k)))))
(if (<= t_2 1e-317) t_0 (if (<= t_2 4e+291) (/ a t_1) t_0))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double t_1 = 1.0 + (10.0 * k);
double t_2 = (a * pow(k, m)) / (t_1 + (k * k));
double tmp;
if (t_2 <= 1e-317) {
tmp = t_0;
} else if (t_2 <= 4e+291) {
tmp = a / t_1;
} else {
tmp = t_0;
}
return tmp;
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = a / (k * k)
t_1 = 1.0d0 + (10.0d0 * k)
t_2 = (a * (k ** m)) / (t_1 + (k * k))
if (t_2 <= 1d-317) then
tmp = t_0
else if (t_2 <= 4d+291) then
tmp = a / t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double t_0 = a / (k * k);
double t_1 = 1.0 + (10.0 * k);
double t_2 = (a * Math.pow(k, m)) / (t_1 + (k * k));
double tmp;
if (t_2 <= 1e-317) {
tmp = t_0;
} else if (t_2 <= 4e+291) {
tmp = a / t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a / (k * k) t_1 = 1.0 + (10.0 * k) t_2 = (a * math.pow(k, m)) / (t_1 + (k * k)) tmp = 0 if t_2 <= 1e-317: tmp = t_0 elif t_2 <= 4e+291: tmp = a / t_1 else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) t_1 = Float64(1.0 + Float64(10.0 * k)) t_2 = Float64(Float64(a * (k ^ m)) / Float64(t_1 + Float64(k * k))) tmp = 0.0 if (t_2 <= 1e-317) tmp = t_0; elseif (t_2 <= 4e+291) tmp = Float64(a / t_1); else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a / (k * k); t_1 = 1.0 + (10.0 * k); t_2 = (a * (k ^ m)) / (t_1 + (k * k)); tmp = 0.0; if (t_2 <= 1e-317) tmp = t_0; elseif (t_2 <= 4e+291) tmp = a / t_1; else tmp = t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 1e-317], t$95$0, If[LessEqual[t$95$2, 4e+291], N[(a / t$95$1), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
t_1 := 1 + 10 \cdot k\\
t_2 := \frac{a \cdot {k}^{m}}{t\_1 + k \cdot k}\\
\mathbf{if}\;t\_2 \leq 10^{-317}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+291}:\\
\;\;\;\;\frac{a}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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))) < 1.00000023e-317 or 3.9999999999999998e291 < (/.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.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
lift-pow.f64N/A
pow2N/A
lift-*.f6435.8
Applied rewrites35.8%
if 1.00000023e-317 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 3.9999999999999998e291Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
Taylor expanded in k around 0
lower-*.f6427.9
Applied rewrites27.9%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (+ 1.0 (* 10.0 k))) (t_1 (/ (* a (pow k m)) (+ t_0 (* k k)))))
(if (<= t_1 1e-317)
(/ a (* k k))
(if (<= t_1 4e+291) (/ a t_0) (* (/ 1.0 (* k k)) a)))))
double code(double a, double k, double m) {
double t_0 = 1.0 + (10.0 * k);
double t_1 = (a * pow(k, m)) / (t_0 + (k * k));
double tmp;
if (t_1 <= 1e-317) {
tmp = a / (k * k);
} else if (t_1 <= 4e+291) {
tmp = a / t_0;
} else {
tmp = (1.0 / (k * k)) * a;
}
return tmp;
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 + (10.0d0 * k)
t_1 = (a * (k ** m)) / (t_0 + (k * k))
if (t_1 <= 1d-317) then
tmp = a / (k * k)
else if (t_1 <= 4d+291) then
tmp = a / t_0
else
tmp = (1.0d0 / (k * k)) * a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double t_0 = 1.0 + (10.0 * k);
double t_1 = (a * Math.pow(k, m)) / (t_0 + (k * k));
double tmp;
if (t_1 <= 1e-317) {
tmp = a / (k * k);
} else if (t_1 <= 4e+291) {
tmp = a / t_0;
} else {
tmp = (1.0 / (k * k)) * a;
}
return tmp;
}
def code(a, k, m): t_0 = 1.0 + (10.0 * k) t_1 = (a * math.pow(k, m)) / (t_0 + (k * k)) tmp = 0 if t_1 <= 1e-317: tmp = a / (k * k) elif t_1 <= 4e+291: tmp = a / t_0 else: tmp = (1.0 / (k * k)) * a return tmp
function code(a, k, m) t_0 = Float64(1.0 + Float64(10.0 * k)) t_1 = Float64(Float64(a * (k ^ m)) / Float64(t_0 + Float64(k * k))) tmp = 0.0 if (t_1 <= 1e-317) tmp = Float64(a / Float64(k * k)); elseif (t_1 <= 4e+291) tmp = Float64(a / t_0); else tmp = Float64(Float64(1.0 / Float64(k * k)) * a); end return tmp end
function tmp_2 = code(a, k, m) t_0 = 1.0 + (10.0 * k); t_1 = (a * (k ^ m)) / (t_0 + (k * k)); tmp = 0.0; if (t_1 <= 1e-317) tmp = a / (k * k); elseif (t_1 <= 4e+291) tmp = a / t_0; else tmp = (1.0 / (k * k)) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e-317], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+291], N[(a / t$95$0), $MachinePrecision], N[(N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + 10 \cdot k\\
t_1 := \frac{a \cdot {k}^{m}}{t\_0 + k \cdot k}\\
\mathbf{if}\;t\_1 \leq 10^{-317}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+291}:\\
\;\;\;\;\frac{a}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{k \cdot k} \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))) < 1.00000023e-317Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
lift-pow.f64N/A
pow2N/A
lift-*.f6435.8
Applied rewrites35.8%
if 1.00000023e-317 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 3.9999999999999998e291Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
Taylor expanded in k around 0
lower-*.f6427.9
Applied rewrites27.9%
if 3.9999999999999998e291 < (/.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.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
div-flipN/A
associate-/r/N/A
metadata-evalN/A
lift-*.f64N/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
metadata-evalN/A
lift-*.f64N/A
lower-/.f6435.9
Applied rewrites35.9%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ a (* k k)))
(t_1 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
(if (<= t_1 1e-317) t_0 (if (<= t_1 4e+291) (/ a 1.0) t_0))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double t_1 = (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_1 <= 1e-317) {
tmp = t_0;
} else if (t_1 <= 4e+291) {
tmp = a / 1.0;
} else {
tmp = t_0;
}
return tmp;
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = a / (k * k)
t_1 = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
if (t_1 <= 1d-317) then
tmp = t_0
else if (t_1 <= 4d+291) then
tmp = a / 1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double t_0 = a / (k * k);
double t_1 = (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_1 <= 1e-317) {
tmp = t_0;
} else if (t_1 <= 4e+291) {
tmp = a / 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a / (k * k) t_1 = (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k)) tmp = 0 if t_1 <= 1e-317: tmp = t_0 elif t_1 <= 4e+291: tmp = a / 1.0 else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) t_1 = Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) tmp = 0.0 if (t_1 <= 1e-317) tmp = t_0; elseif (t_1 <= 4e+291) tmp = Float64(a / 1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a / (k * k); t_1 = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); tmp = 0.0; if (t_1 <= 1e-317) tmp = t_0; elseif (t_1 <= 4e+291) tmp = a / 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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$1, 1e-317], t$95$0, If[LessEqual[t$95$1, 4e+291], N[(a / 1.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
t_1 := \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
\mathbf{if}\;t\_1 \leq 10^{-317}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+291}:\\
\;\;\;\;\frac{a}{1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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))) < 1.00000023e-317 or 3.9999999999999998e291 < (/.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.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
lift-pow.f64N/A
pow2N/A
lift-*.f6435.8
Applied rewrites35.8%
if 1.00000023e-317 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 3.9999999999999998e291Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
lift-+.f64N/A
lift-fma.f64N/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lower-fma.f6444.6
Applied rewrites44.6%
Taylor expanded in k around 0
Applied rewrites19.6%
(FPCore (a k m) :precision binary64 (/ a 1.0))
double code(double a, double k, double m) {
return a / 1.0;
}
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 / 1.0d0
end function
public static double code(double a, double k, double m) {
return a / 1.0;
}
def code(a, k, m): return a / 1.0
function code(a, k, m) return Float64(a / 1.0) end
function tmp = code(a, k, m) tmp = a / 1.0; end
code[a_, k_, m_] := N[(a / 1.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{1}
\end{array}
Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.6
Applied rewrites44.6%
lift-+.f64N/A
lift-fma.f64N/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lower-fma.f6444.6
Applied rewrites44.6%
Taylor expanded in k around 0
Applied rewrites19.6%
herbie shell --seed 2025150
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))