
(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 (let* ((t_0 (* (pow k m) a))) (if (<= m 3.45) (/ t_0 (fma (- k -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 <= 3.45) {
tmp = t_0 / fma((k - -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 <= 3.45) tmp = Float64(t_0 / fma(Float64(k - -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, 3.45], N[(t$95$0 / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq 3.45:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < 3.4500000000000002Initial program 90.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.1
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
+-lft-identityN/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.2
Applied rewrites90.2%
if 3.4500000000000002 < m Initial program 90.1%
Taylor expanded in m around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6440.7
Applied rewrites40.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.1%
Taylor expanded in k around 0
lower-pow.f6482.9
Applied rewrites82.9%
(FPCore (a k m) :precision binary64 (if (<= m 3.45) (* (/ (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.45) {
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.45) tmp = Float64(Float64((k ^ m) / fma(Float64(k - -10.0), k, 1.0)) * a); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 3.45], N[(N[(N[Power[k, m], $MachinePrecision] / N[(N[(k - -10.0), $MachinePrecision] * k + 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.45:\\
\;\;\;\;\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.4500000000000002Initial program 90.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.2%
if 3.4500000000000002 < m Initial program 90.1%
Taylor expanded in m around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6440.7
Applied rewrites40.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.1%
Taylor expanded in k around 0
lower-pow.f6482.9
Applied rewrites82.9%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -72000.0)
t_0
(if (<= m 0.046)
(/ (* (fma (log k) m 1.0) a) (fma (- k -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 <= -72000.0) {
tmp = t_0;
} else if (m <= 0.046) {
tmp = (fma(log(k), m, 1.0) * a) / fma((k - -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 <= -72000.0) tmp = t_0; elseif (m <= 0.046) tmp = Float64(Float64(fma(log(k), m, 1.0) * a) / fma(Float64(k - -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, -72000.0], t$95$0, If[LessEqual[m, 0.046], N[(N[(N[(N[Log[k], $MachinePrecision] * m + 1.0), $MachinePrecision] * a), $MachinePrecision] / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq -72000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 0.046:\\
\;\;\;\;\frac{\mathsf{fma}\left(\log k, m, 1\right) \cdot a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -72000 or 0.045999999999999999 < m Initial program 90.1%
Taylor expanded in m around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6440.7
Applied rewrites40.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.1%
Taylor expanded in k around 0
lower-pow.f6482.9
Applied rewrites82.9%
if -72000 < m < 0.045999999999999999Initial program 90.1%
Taylor expanded in m around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6440.7
Applied rewrites40.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6440.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6440.7
lower-fma.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
Applied rewrites40.7%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -72000.0)
t_0
(if (<= m 0.046)
(* (/ (fma (log k) m 1.0) (fma (- k -10.0) k 1.0)) a)
t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= -72000.0) {
tmp = t_0;
} else if (m <= 0.046) {
tmp = (fma(log(k), m, 1.0) / fma((k - -10.0), k, 1.0)) * a;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (m <= -72000.0) tmp = t_0; elseif (m <= 0.046) tmp = Float64(Float64(fma(log(k), m, 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[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[m, -72000.0], t$95$0, If[LessEqual[m, 0.046], N[(N[(N[(N[Log[k], $MachinePrecision] * m + 1.0), $MachinePrecision] / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq -72000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 0.046:\\
\;\;\;\;\frac{\mathsf{fma}\left(\log k, m, 1\right)}{\mathsf{fma}\left(k - -10, k, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -72000 or 0.045999999999999999 < m Initial program 90.1%
Taylor expanded in m around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6440.7
Applied rewrites40.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.1%
Taylor expanded in k around 0
lower-pow.f6482.9
Applied rewrites82.9%
if -72000 < m < 0.045999999999999999Initial program 90.1%
Taylor expanded in m around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6440.7
Applied rewrites40.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.1%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -72000.0)
t_0
(if (<= m 0.046) (/ a (fma (- k -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 <= -72000.0) {
tmp = t_0;
} else if (m <= 0.046) {
tmp = a / fma((k - -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 <= -72000.0) tmp = t_0; elseif (m <= 0.046) tmp = Float64(a / fma(Float64(k - -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, -72000.0], t$95$0, If[LessEqual[m, 0.046], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq -72000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 0.046:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -72000 or 0.045999999999999999 < m Initial program 90.1%
Taylor expanded in m around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6440.7
Applied rewrites40.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.1%
Taylor expanded in k around 0
lower-pow.f6482.9
Applied rewrites82.9%
if -72000 < m < 0.045999999999999999Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
lift-+.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
remove-double-negN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6445.4
Applied rewrites45.4%
(FPCore (a k m)
:precision binary64
(if (<= m -2.8e-6)
(/ a (sqrt (* (* k k) (* k k))))
(if (<= m 2.2)
(/ a (fma (- k -10.0) k 1.0))
(* (+ 1.0 (* k (- (* 99.0 k) 10.0))) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -2.8e-6) {
tmp = a / sqrt(((k * k) * (k * k)));
} else if (m <= 2.2) {
tmp = a / fma((k - -10.0), 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 <= -2.8e-6) tmp = Float64(a / sqrt(Float64(Float64(k * k) * Float64(k * k)))); elseif (m <= 2.2) tmp = Float64(a / fma(Float64(k - -10.0), 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, -2.8e-6], N[(a / N[Sqrt[N[(N[(k * k), $MachinePrecision] * N[(k * k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 2.2], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $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 -2.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{a}{\sqrt{\left(k \cdot k\right) \cdot \left(k \cdot k\right)}}\\
\mathbf{elif}\;m \leq 2.2:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + k \cdot \left(99 \cdot k - 10\right)\right) \cdot a\\
\end{array}
\end{array}
if m < -2.79999999999999987e-6Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
rem-square-sqrtN/A
sqrt-unprodN/A
sqr-neg-revN/A
lower-*.f32N/A
lower-unsound-*.f32N/A
lower-sqrt.f64N/A
lower-unsound-*.f32N/A
lower-*.f32N/A
sqr-neg-revN/A
lower-*.f6438.4
lift-pow.f64N/A
pow2N/A
lower-*.f6438.4
lift-pow.f64N/A
pow2N/A
lower-*.f6438.4
Applied rewrites38.4%
if -2.79999999999999987e-6 < m < 2.2000000000000002Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
lift-+.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
remove-double-negN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6445.4
Applied rewrites45.4%
if 2.2000000000000002 < m Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
lift-/.f64N/A
mult-flipN/A
lift-+.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
associate-+l+N/A
lift-+.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites45.4%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6429.3
Applied rewrites29.3%
(FPCore (a k m)
:precision binary64
(if (<= m -72000.0)
(/ a (sqrt (* (* k k) (* k k))))
(if (<= m 13500000000000.0)
(/ a (fma (- k -10.0) k 1.0))
(* -10.0 (* a k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -72000.0) {
tmp = a / sqrt(((k * k) * (k * k)));
} else if (m <= 13500000000000.0) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -72000.0) tmp = Float64(a / sqrt(Float64(Float64(k * k) * Float64(k * k)))); elseif (m <= 13500000000000.0) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -72000.0], N[(a / N[Sqrt[N[(N[(k * k), $MachinePrecision] * N[(k * k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 13500000000000.0], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -72000:\\
\;\;\;\;\frac{a}{\sqrt{\left(k \cdot k\right) \cdot \left(k \cdot k\right)}}\\
\mathbf{elif}\;m \leq 13500000000000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < -72000Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
rem-square-sqrtN/A
sqrt-unprodN/A
sqr-neg-revN/A
lower-*.f32N/A
lower-unsound-*.f32N/A
lower-sqrt.f64N/A
lower-unsound-*.f32N/A
lower-*.f32N/A
sqr-neg-revN/A
lower-*.f6438.4
lift-pow.f64N/A
pow2N/A
lower-*.f6438.4
lift-pow.f64N/A
pow2N/A
lower-*.f6438.4
Applied rewrites38.4%
if -72000 < m < 1.35e13Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
lift-+.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
remove-double-negN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6445.4
Applied rewrites45.4%
if 1.35e13 < m Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6421.4
Applied rewrites21.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6421.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6421.4
Applied rewrites21.4%
Taylor expanded in k around inf
lower-*.f64N/A
lower-*.f648.4
Applied rewrites8.4%
(FPCore (a k m)
:precision binary64
(if (<= m -72000.0)
(* (/ 1.0 (* k k)) a)
(if (<= m 13500000000000.0)
(/ a (fma (- k -10.0) k 1.0))
(* -10.0 (* a k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -72000.0) {
tmp = (1.0 / (k * k)) * a;
} else if (m <= 13500000000000.0) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -72000.0) tmp = Float64(Float64(1.0 / Float64(k * k)) * a); elseif (m <= 13500000000000.0) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -72000.0], N[(N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[m, 13500000000000.0], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -72000:\\
\;\;\;\;\frac{1}{k \cdot k} \cdot a\\
\mathbf{elif}\;m \leq 13500000000000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < -72000Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6435.9
lift-pow.f64N/A
pow2N/A
lower-*.f6435.9
Applied rewrites35.9%
if -72000 < m < 1.35e13Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
lift-+.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
remove-double-negN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6445.4
Applied rewrites45.4%
if 1.35e13 < m Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6421.4
Applied rewrites21.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6421.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6421.4
Applied rewrites21.4%
Taylor expanded in k around inf
lower-*.f64N/A
lower-*.f648.4
Applied rewrites8.4%
(FPCore (a k m) :precision binary64 (if (<= m -7.2e-55) (* (/ 1.0 (* k k)) a) (if (<= m 13500000000000.0) (/ a (fma 10.0 k 1.0)) (* -10.0 (* a k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -7.2e-55) {
tmp = (1.0 / (k * k)) * a;
} else if (m <= 13500000000000.0) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -7.2e-55) tmp = Float64(Float64(1.0 / Float64(k * k)) * a); elseif (m <= 13500000000000.0) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -7.2e-55], N[(N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[m, 13500000000000.0], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -7.2 \cdot 10^{-55}:\\
\;\;\;\;\frac{1}{k \cdot k} \cdot a\\
\mathbf{elif}\;m \leq 13500000000000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < -7.2000000000000001e-55Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6435.9
lift-pow.f64N/A
pow2N/A
lower-*.f6435.9
Applied rewrites35.9%
if -7.2000000000000001e-55 < m < 1.35e13Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
lift-+.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
remove-double-negN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6445.4
Applied rewrites45.4%
Taylor expanded in k around 0
Applied rewrites29.3%
if 1.35e13 < m Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6421.4
Applied rewrites21.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6421.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6421.4
Applied rewrites21.4%
Taylor expanded in k around inf
lower-*.f64N/A
lower-*.f648.4
Applied rewrites8.4%
(FPCore (a k m) :precision binary64 (if (<= m -7.2e-55) (/ a (* k k)) (if (<= m 13500000000000.0) (/ a (fma 10.0 k 1.0)) (* -10.0 (* a k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -7.2e-55) {
tmp = a / (k * k);
} else if (m <= 13500000000000.0) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -7.2e-55) tmp = Float64(a / Float64(k * k)); elseif (m <= 13500000000000.0) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -7.2e-55], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 13500000000000.0], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -7.2 \cdot 10^{-55}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 13500000000000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < -7.2000000000000001e-55Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
lift-pow.f64N/A
pow2N/A
lower-*.f6435.8
Applied rewrites35.8%
if -7.2000000000000001e-55 < m < 1.35e13Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
lift-+.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
remove-double-negN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6445.4
Applied rewrites45.4%
Taylor expanded in k around 0
Applied rewrites29.3%
if 1.35e13 < m Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6421.4
Applied rewrites21.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6421.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6421.4
Applied rewrites21.4%
Taylor expanded in k around inf
lower-*.f64N/A
lower-*.f648.4
Applied rewrites8.4%
(FPCore (a k m) :precision binary64 (let* ((t_0 (/ a (* k k)))) (if (<= k -6.5e-297) t_0 (if (<= k 0.1) (fma (* -10.0 a) k a) t_0))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double tmp;
if (k <= -6.5e-297) {
tmp = t_0;
} else if (k <= 0.1) {
tmp = fma((-10.0 * a), k, a);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) tmp = 0.0 if (k <= -6.5e-297) tmp = t_0; elseif (k <= 0.1) tmp = fma(Float64(-10.0 * a), k, a); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k, -6.5e-297], t$95$0, If[LessEqual[k, 0.1], N[(N[(-10.0 * a), $MachinePrecision] * k + a), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
\mathbf{if}\;k \leq -6.5 \cdot 10^{-297}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;k \leq 0.1:\\
\;\;\;\;\mathsf{fma}\left(-10 \cdot a, k, a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if k < -6.5000000000000002e-297 or 0.10000000000000001 < k Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
lift-pow.f64N/A
pow2N/A
lower-*.f6435.8
Applied rewrites35.8%
if -6.5000000000000002e-297 < k < 0.10000000000000001Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6421.4
Applied rewrites21.4%
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-*.f6421.4
Applied rewrites21.4%
(FPCore (a k m) :precision binary64 (let* ((t_0 (/ a (* k k)))) (if (<= k -6.5e-297) t_0 (if (<= k 1.0) (/ a 1.0) t_0))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double tmp;
if (k <= -6.5e-297) {
tmp = t_0;
} else if (k <= 1.0) {
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) :: tmp
t_0 = a / (k * k)
if (k <= (-6.5d-297)) then
tmp = t_0
else if (k <= 1.0d0) 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 tmp;
if (k <= -6.5e-297) {
tmp = t_0;
} else if (k <= 1.0) {
tmp = a / 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a / (k * k) tmp = 0 if k <= -6.5e-297: tmp = t_0 elif k <= 1.0: tmp = a / 1.0 else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) tmp = 0.0 if (k <= -6.5e-297) tmp = t_0; elseif (k <= 1.0) 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); tmp = 0.0; if (k <= -6.5e-297) tmp = t_0; elseif (k <= 1.0) 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]}, If[LessEqual[k, -6.5e-297], t$95$0, If[LessEqual[k, 1.0], N[(a / 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
\mathbf{if}\;k \leq -6.5 \cdot 10^{-297}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;k \leq 1:\\
\;\;\;\;\frac{a}{1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if k < -6.5000000000000002e-297 or 1 < k Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
lift-pow.f64N/A
pow2N/A
lower-*.f6435.8
Applied rewrites35.8%
if -6.5000000000000002e-297 < k < 1Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
lift-+.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
remove-double-negN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6445.4
Applied rewrites45.4%
Taylor expanded in k around 0
Applied rewrites20.5%
(FPCore (a k m) :precision binary64 (if (<= m 13500000000000.0) (/ a 1.0) (* -10.0 (* a k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 13500000000000.0) {
tmp = a / 1.0;
} else {
tmp = -10.0 * (a * k);
}
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) :: tmp
if (m <= 13500000000000.0d0) then
tmp = a / 1.0d0
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 <= 13500000000000.0) {
tmp = a / 1.0;
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 13500000000000.0: tmp = a / 1.0 else: tmp = -10.0 * (a * k) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 13500000000000.0) tmp = Float64(a / 1.0); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 13500000000000.0) tmp = a / 1.0; else tmp = -10.0 * (a * k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 13500000000000.0], N[(a / 1.0), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 13500000000000:\\
\;\;\;\;\frac{a}{1}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < 1.35e13Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
lift-+.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
remove-double-negN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6445.4
Applied rewrites45.4%
Taylor expanded in k around 0
Applied rewrites20.5%
if 1.35e13 < m Initial program 90.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6421.4
Applied rewrites21.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6421.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6421.4
Applied rewrites21.4%
Taylor expanded in k around inf
lower-*.f64N/A
lower-*.f648.4
Applied rewrites8.4%
(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.1%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
lift-+.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
remove-double-negN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6445.4
Applied rewrites45.4%
Taylor expanded in k around 0
Applied rewrites20.5%
herbie shell --seed 2025155
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))