
(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}
Sampling outcomes in binary64 precision:
Herbie found 12 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 1e-10) (* a (/ (pow k m) (fma (+ 10.0 k) k 1.0))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 1e-10) {
tmp = a * (pow(k, m) / fma((10.0 + k), k, 1.0));
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 1e-10) tmp = Float64(a * Float64((k ^ m) / fma(Float64(10.0 + k), k, 1.0))); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 1e-10], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 10^{-10}:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 1.00000000000000004e-10Initial program 96.1%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
pow2N/A
associate-+r+N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6496.1
Applied rewrites96.1%
if 1.00000000000000004e-10 < m Initial program 78.0%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (<= m -4.5e-8) (/ (* a (pow k m)) (* k k)) (if (<= m 5.3e-11) (/ a (fma (+ 10.0 k) k 1.0)) (* (pow k m) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -4.5e-8) {
tmp = (a * pow(k, m)) / (k * k);
} else if (m <= 5.3e-11) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -4.5e-8) tmp = Float64(Float64(a * (k ^ m)) / Float64(k * k)); elseif (m <= 5.3e-11) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -4.5e-8], N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 5.3e-11], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -4.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{k \cdot k}\\
\mathbf{elif}\;m \leq 5.3 \cdot 10^{-11}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < -4.49999999999999993e-8Initial program 100.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f6499.9
Applied rewrites99.9%
if -4.49999999999999993e-8 < m < 5.2999999999999998e-11Initial program 92.6%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6492.4
Applied rewrites92.4%
if 5.2999999999999998e-11 < m Initial program 78.0%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (or (<= m -0.00098) (not (<= m 5.3e-11))) (* (pow k m) a) (/ a (fma (+ 10.0 k) k 1.0))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -0.00098) || !(m <= 5.3e-11)) {
tmp = pow(k, m) * a;
} else {
tmp = a / fma((10.0 + k), k, 1.0);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if ((m <= -0.00098) || !(m <= 5.3e-11)) tmp = Float64((k ^ m) * a); else tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); end return tmp end
code[a_, k_, m_] := If[Or[LessEqual[m, -0.00098], N[Not[LessEqual[m, 5.3e-11]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.00098 \lor \neg \left(m \leq 5.3 \cdot 10^{-11}\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\end{array}
\end{array}
if m < -9.7999999999999997e-4 or 5.2999999999999998e-11 < m Initial program 89.0%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
if -9.7999999999999997e-4 < m < 5.2999999999999998e-11Initial program 92.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6492.0
Applied rewrites92.0%
Final simplification97.1%
(FPCore (a k m)
:precision binary64
(if (<= m -68.0)
(/ (fma (/ (fma -99.0 (/ a k) (* 10.0 a)) k) -1.0 a) (* k k))
(if (<= m 1e-10)
(/ a (fma (+ 10.0 k) k 1.0))
(if (<= m 3.1e+222)
(fma (fma (- k) (* -99.0 a) (* -10.0 a)) k a)
(* (* k a) -10.0)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -68.0) {
tmp = fma((fma(-99.0, (a / k), (10.0 * a)) / k), -1.0, a) / (k * k);
} else if (m <= 1e-10) {
tmp = a / fma((10.0 + k), k, 1.0);
} else if (m <= 3.1e+222) {
tmp = fma(fma(-k, (-99.0 * a), (-10.0 * a)), k, a);
} else {
tmp = (k * a) * -10.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -68.0) tmp = Float64(fma(Float64(fma(-99.0, Float64(a / k), Float64(10.0 * a)) / k), -1.0, a) / Float64(k * k)); elseif (m <= 1e-10) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); elseif (m <= 3.1e+222) tmp = fma(fma(Float64(-k), Float64(-99.0 * a), Float64(-10.0 * a)), k, a); else tmp = Float64(Float64(k * a) * -10.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -68.0], N[(N[(N[(N[(-99.0 * N[(a / k), $MachinePrecision] + N[(10.0 * a), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision] * -1.0 + a), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1e-10], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 3.1e+222], N[(N[((-k) * N[(-99.0 * a), $MachinePrecision] + N[(-10.0 * a), $MachinePrecision]), $MachinePrecision] * k + a), $MachinePrecision], N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -68:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{\mathsf{fma}\left(-99, \frac{a}{k}, 10 \cdot a\right)}{k}, -1, a\right)}{k \cdot k}\\
\mathbf{elif}\;m \leq 10^{-10}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{elif}\;m \leq 3.1 \cdot 10^{+222}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-k, -99 \cdot a, -10 \cdot a\right), k, a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\end{array}
\end{array}
if m < -68Initial program 100.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6426.3
Applied rewrites26.3%
Taylor expanded in k around -inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
fp-cancel-sub-sign-invN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
Applied rewrites57.7%
if -68 < m < 1.00000000000000004e-10Initial program 92.8%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6491.1
Applied rewrites91.1%
if 1.00000000000000004e-10 < m < 3.0999999999999998e222Initial program 75.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f644.7
Applied rewrites4.7%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
mul-1-negN/A
metadata-evalN/A
lower-fma.f64N/A
lower-neg.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6434.8
Applied rewrites34.8%
if 3.0999999999999998e222 < m Initial program 86.4%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.5
Applied rewrites3.5%
Taylor expanded in k around 0
Applied rewrites3.9%
Taylor expanded in k around 0
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
pow2N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f648.3
Applied rewrites8.3%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6438.9
Applied rewrites38.9%
Final simplification62.9%
(FPCore (a k m)
:precision binary64
(if (<= m -0.22)
(/ a (* k k))
(if (<= m 1e-10)
(/ a (fma (+ 10.0 k) k 1.0))
(if (<= m 3.1e+222)
(fma (fma (- k) (* -99.0 a) (* -10.0 a)) k a)
(* (* k a) -10.0)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.22) {
tmp = a / (k * k);
} else if (m <= 1e-10) {
tmp = a / fma((10.0 + k), k, 1.0);
} else if (m <= 3.1e+222) {
tmp = fma(fma(-k, (-99.0 * a), (-10.0 * a)), k, a);
} else {
tmp = (k * a) * -10.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.22) tmp = Float64(a / Float64(k * k)); elseif (m <= 1e-10) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); elseif (m <= 3.1e+222) tmp = fma(fma(Float64(-k), Float64(-99.0 * a), Float64(-10.0 * a)), k, a); else tmp = Float64(Float64(k * a) * -10.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.22], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1e-10], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 3.1e+222], N[(N[((-k) * N[(-99.0 * a), $MachinePrecision] + N[(-10.0 * a), $MachinePrecision]), $MachinePrecision] * k + a), $MachinePrecision], N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.22:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 10^{-10}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{elif}\;m \leq 3.1 \cdot 10^{+222}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-k, -99 \cdot a, -10 \cdot a\right), k, a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\end{array}
\end{array}
if m < -0.220000000000000001Initial program 100.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites48.8%
if -0.220000000000000001 < m < 1.00000000000000004e-10Initial program 92.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6492.0
Applied rewrites92.0%
if 1.00000000000000004e-10 < m < 3.0999999999999998e222Initial program 75.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f644.7
Applied rewrites4.7%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
mul-1-negN/A
metadata-evalN/A
lower-fma.f64N/A
lower-neg.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6434.8
Applied rewrites34.8%
if 3.0999999999999998e222 < m Initial program 86.4%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.5
Applied rewrites3.5%
Taylor expanded in k around 0
Applied rewrites3.9%
Taylor expanded in k around 0
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
pow2N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f648.3
Applied rewrites8.3%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6438.9
Applied rewrites38.9%
Final simplification60.2%
(FPCore (a k m) :precision binary64 (if (<= m -0.22) (/ a (* k k)) (if (<= m 1.7) (/ a (fma (+ 10.0 k) k 1.0)) (* (* k a) -10.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.22) {
tmp = a / (k * k);
} else if (m <= 1.7) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = (k * a) * -10.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.22) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.7) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(k * a) * -10.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.22], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.7], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.22:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.7:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\end{array}
\end{array}
if m < -0.220000000000000001Initial program 100.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites48.8%
if -0.220000000000000001 < m < 1.69999999999999996Initial program 92.9%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6491.3
Applied rewrites91.3%
if 1.69999999999999996 < m Initial program 77.5%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
Applied rewrites3.9%
Taylor expanded in k around 0
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
pow2N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f645.4
Applied rewrites5.4%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6420.3
Applied rewrites20.3%
(FPCore (a k m) :precision binary64 (if (<= m -0.22) (/ a (* k k)) (if (<= m 1.7) (/ a (fma k k 1.0)) (* (* k a) -10.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.22) {
tmp = a / (k * k);
} else if (m <= 1.7) {
tmp = a / fma(k, k, 1.0);
} else {
tmp = (k * a) * -10.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.22) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.7) tmp = Float64(a / fma(k, k, 1.0)); else tmp = Float64(Float64(k * a) * -10.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.22], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.7], N[(a / N[(k * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.22:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.7:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\end{array}
\end{array}
if m < -0.220000000000000001Initial program 100.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites48.8%
if -0.220000000000000001 < m < 1.69999999999999996Initial program 92.9%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6491.3
Applied rewrites91.3%
Taylor expanded in k around inf
Applied rewrites90.6%
if 1.69999999999999996 < m Initial program 77.5%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
Applied rewrites3.9%
Taylor expanded in k around 0
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
pow2N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f645.4
Applied rewrites5.4%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6420.3
Applied rewrites20.3%
(FPCore (a k m) :precision binary64 (if (<= m -2e-106) (/ a (* k k)) (if (<= m 1.7) (/ a (fma 10.0 k 1.0)) (* (* k a) -10.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -2e-106) {
tmp = a / (k * k);
} else if (m <= 1.7) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = (k * a) * -10.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -2e-106) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.7) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = Float64(Float64(k * a) * -10.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -2e-106], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.7], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2 \cdot 10^{-106}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.7:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\end{array}
\end{array}
if m < -1.99999999999999988e-106Initial program 98.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f6494.0
Applied rewrites94.0%
Taylor expanded in m around 0
Applied rewrites49.8%
if -1.99999999999999988e-106 < m < 1.69999999999999996Initial program 94.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6493.0
Applied rewrites93.0%
Taylor expanded in k around 0
Applied rewrites68.1%
if 1.69999999999999996 < m Initial program 77.5%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
Applied rewrites3.9%
Taylor expanded in k around 0
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
pow2N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f645.4
Applied rewrites5.4%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6420.3
Applied rewrites20.3%
(FPCore (a k m) :precision binary64 (if (or (<= k 1.08e-272) (not (<= k 2.6e-11))) (/ a (* k k)) a))
double code(double a, double k, double m) {
double tmp;
if ((k <= 1.08e-272) || !(k <= 2.6e-11)) {
tmp = a / (k * k);
} else {
tmp = 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) :: tmp
if ((k <= 1.08d-272) .or. (.not. (k <= 2.6d-11))) then
tmp = a / (k * k)
else
tmp = a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if ((k <= 1.08e-272) || !(k <= 2.6e-11)) {
tmp = a / (k * k);
} else {
tmp = a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if (k <= 1.08e-272) or not (k <= 2.6e-11): tmp = a / (k * k) else: tmp = a return tmp
function code(a, k, m) tmp = 0.0 if ((k <= 1.08e-272) || !(k <= 2.6e-11)) tmp = Float64(a / Float64(k * k)); else tmp = a; end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((k <= 1.08e-272) || ~((k <= 2.6e-11))) tmp = a / (k * k); else tmp = a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[k, 1.08e-272], N[Not[LessEqual[k, 2.6e-11]], $MachinePrecision]], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], a]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.08 \cdot 10^{-272} \lor \neg \left(k \leq 2.6 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if k < 1.07999999999999994e-272 or 2.6000000000000001e-11 < k Initial program 85.8%
Taylor expanded in k around inf
pow2N/A
lift-*.f6476.3
Applied rewrites76.3%
Taylor expanded in m around 0
Applied rewrites39.8%
if 1.07999999999999994e-272 < k < 2.6000000000000001e-11Initial program 100.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6456.4
Applied rewrites56.4%
Taylor expanded in k around 0
Applied rewrites56.4%
Final simplification45.1%
(FPCore (a k m) :precision binary64 (if (<= m -4.4e-8) (/ a (* 10.0 k)) (if (<= m 0.47) a (* (* k a) -10.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -4.4e-8) {
tmp = a / (10.0 * k);
} else if (m <= 0.47) {
tmp = a;
} else {
tmp = (k * a) * -10.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) :: tmp
if (m <= (-4.4d-8)) then
tmp = a / (10.0d0 * k)
else if (m <= 0.47d0) then
tmp = a
else
tmp = (k * a) * (-10.0d0)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -4.4e-8) {
tmp = a / (10.0 * k);
} else if (m <= 0.47) {
tmp = a;
} else {
tmp = (k * a) * -10.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -4.4e-8: tmp = a / (10.0 * k) elif m <= 0.47: tmp = a else: tmp = (k * a) * -10.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= -4.4e-8) tmp = Float64(a / Float64(10.0 * k)); elseif (m <= 0.47) tmp = a; else tmp = Float64(Float64(k * a) * -10.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -4.4e-8) tmp = a / (10.0 * k); elseif (m <= 0.47) tmp = a; else tmp = (k * a) * -10.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -4.4e-8], N[(a / N[(10.0 * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.47], a, N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -4.4 \cdot 10^{-8}:\\
\;\;\;\;\frac{a}{10 \cdot k}\\
\mathbf{elif}\;m \leq 0.47:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\end{array}
\end{array}
if m < -4.3999999999999997e-8Initial program 100.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6427.2
Applied rewrites27.2%
Taylor expanded in k around inf
+-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
pow2N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
pow2N/A
lift-*.f6440.7
Applied rewrites40.7%
Taylor expanded in k around 0
lower-*.f6422.8
Applied rewrites22.8%
if -4.3999999999999997e-8 < m < 0.46999999999999997Initial program 92.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6491.7
Applied rewrites91.7%
Taylor expanded in k around 0
Applied rewrites54.6%
if 0.46999999999999997 < m Initial program 77.5%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
Applied rewrites3.9%
Taylor expanded in k around 0
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
pow2N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f645.4
Applied rewrites5.4%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6420.3
Applied rewrites20.3%
Final simplification33.5%
(FPCore (a k m) :precision binary64 (if (<= m 0.47) a (* (* k a) -10.0)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.47) {
tmp = a;
} else {
tmp = (k * a) * -10.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) :: tmp
if (m <= 0.47d0) then
tmp = a
else
tmp = (k * a) * (-10.0d0)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 0.47) {
tmp = a;
} else {
tmp = (k * a) * -10.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.47: tmp = a else: tmp = (k * a) * -10.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.47) tmp = a; else tmp = Float64(Float64(k * a) * -10.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 0.47) tmp = a; else tmp = (k * a) * -10.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.47], a, N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.47:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\end{array}
\end{array}
if m < 0.46999999999999997Initial program 96.2%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6460.9
Applied rewrites60.9%
Taylor expanded in k around 0
Applied rewrites30.3%
if 0.46999999999999997 < m Initial program 77.5%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
Applied rewrites3.9%
Taylor expanded in k around 0
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
pow2N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f645.4
Applied rewrites5.4%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6420.3
Applied rewrites20.3%
Final simplification27.2%
(FPCore (a k m) :precision binary64 a)
double code(double a, double k, double m) {
return a;
}
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
end function
public static double code(double a, double k, double m) {
return a;
}
def code(a, k, m): return a
function code(a, k, m) return a end
function tmp = code(a, k, m) tmp = a; end
code[a_, k_, m_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 90.3%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6442.8
Applied rewrites42.8%
Taylor expanded in k around 0
Applied rewrites22.1%
Final simplification22.1%
herbie shell --seed 2025051
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))