
(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 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}
(FPCore (a k m) :precision binary64 (if (<= m 3.3) (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.3) {
tmp = (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
} else {
tmp = pow(k, m) * 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 (m <= 3.3d0) then
tmp = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
else
tmp = (k ** m) * a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 3.3) {
tmp = (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
} else {
tmp = Math.pow(k, m) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 3.3: tmp = (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k)) else: tmp = math.pow(k, m) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 3.3) tmp = Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))); else tmp = Float64((k ^ m) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 3.3) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); else tmp = (k ^ m) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 3.3], 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], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.3:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 3.2999999999999998Initial program 97.0%
if 3.2999999999999998 < m Initial program 83.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6483.1
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-+.f6483.1
Applied rewrites83.1%
Taylor expanded in k around 0
lower-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
(if (or (<= t_0 4e-320) (not (or (<= t_0 1e+299) (not (<= t_0 INFINITY)))))
(/ a (* k k))
(* (fma (fma 99.0 k -10.0) k 1.0) a))))
double code(double a, double k, double m) {
double t_0 = (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if ((t_0 <= 4e-320) || !((t_0 <= 1e+299) || !(t_0 <= ((double) INFINITY)))) {
tmp = a / (k * k);
} else {
tmp = fma(fma(99.0, k, -10.0), k, 1.0) * a;
}
return tmp;
}
function code(a, k, m) t_0 = Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) tmp = 0.0 if ((t_0 <= 4e-320) || !((t_0 <= 1e+299) || !(t_0 <= Inf))) tmp = Float64(a / Float64(k * k)); else tmp = Float64(fma(fma(99.0, k, -10.0), k, 1.0) * a); end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, 4e-320], N[Not[Or[LessEqual[t$95$0, 1e+299], N[Not[LessEqual[t$95$0, Infinity]], $MachinePrecision]]], $MachinePrecision]], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], N[(N[(N[(99.0 * k + -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{-320} \lor \neg \left(t\_0 \leq 10^{+299} \lor \neg \left(t\_0 \leq \infty\right)\right):\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(99, k, -10\right), k, 1\right) \cdot a\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 3.99996e-320 or 1.0000000000000001e299 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < +inf.0Initial program 97.5%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6444.1
Applied rewrites44.1%
Taylor expanded in k around inf
Applied rewrites42.3%
if 3.99996e-320 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 1.0000000000000001e299 or +inf.0 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 63.8%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6464.2
Applied rewrites64.2%
Taylor expanded in k around 0
Applied rewrites78.5%
Taylor expanded in a around 0
Applied rewrites89.0%
Final simplification48.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 4e-320)
t_0
(if (<= t_1 1e+299)
(fma (* (fma 99.0 k -10.0) a) k a)
(if (<= t_1 INFINITY) t_0 (* (fma (fma 99.0 k -10.0) k 1.0) a))))))
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 <= 4e-320) {
tmp = t_0;
} else if (t_1 <= 1e+299) {
tmp = fma((fma(99.0, k, -10.0) * a), k, a);
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_0;
} else {
tmp = fma(fma(99.0, k, -10.0), k, 1.0) * a;
}
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 <= 4e-320) tmp = t_0; elseif (t_1 <= 1e+299) tmp = fma(Float64(fma(99.0, k, -10.0) * a), k, a); elseif (t_1 <= Inf) tmp = t_0; else tmp = Float64(fma(fma(99.0, k, -10.0), k, 1.0) * a); end return 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, 4e-320], t$95$0, If[LessEqual[t$95$1, 1e+299], N[(N[(N[(99.0 * k + -10.0), $MachinePrecision] * a), $MachinePrecision] * k + a), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$0, N[(N[(N[(99.0 * k + -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision] * a), $MachinePrecision]]]]]]
\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 4 \cdot 10^{-320}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{+299}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(99, k, -10\right) \cdot a, k, a\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(99, k, -10\right), k, 1\right) \cdot a\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 3.99996e-320 or 1.0000000000000001e299 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < +inf.0Initial program 97.5%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6444.1
Applied rewrites44.1%
Taylor expanded in k around inf
Applied rewrites42.3%
if 3.99996e-320 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 1.0000000000000001e299Initial program 99.9%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6499.7
Applied rewrites99.7%
Taylor expanded in k around 0
Applied rewrites82.8%
Taylor expanded in a around 0
Applied rewrites82.8%
if +inf.0 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 0.0%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f641.6
Applied rewrites1.6%
Taylor expanded in k around 0
Applied rewrites71.0%
Taylor expanded in a around 0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (<= m 3.3) (* (/ (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.3) {
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.3) 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.3], 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.3:\\
\;\;\;\;\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.2999999999999998Initial program 97.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6497.0
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-+.f6497.0
Applied rewrites97.0%
if 3.2999999999999998 < m Initial program 83.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6483.1
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-+.f6483.1
Applied rewrites83.1%
Taylor expanded in k around 0
lower-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (or (<= m -0.014) (not (<= m 1.75e-6))) (* (pow k m) a) (/ a (fma (- k -10.0) k 1.0))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -0.014) || !(m <= 1.75e-6)) {
tmp = pow(k, m) * a;
} else {
tmp = a / fma((k - -10.0), k, 1.0);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if ((m <= -0.014) || !(m <= 1.75e-6)) tmp = Float64((k ^ m) * a); else tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); end return tmp end
code[a_, k_, m_] := If[Or[LessEqual[m, -0.014], N[Not[LessEqual[m, 1.75e-6]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.014 \lor \neg \left(m \leq 1.75 \cdot 10^{-6}\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\end{array}
\end{array}
if m < -0.0140000000000000003 or 1.74999999999999997e-6 < m Initial program 92.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6492.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-+.f6492.3
Applied rewrites92.3%
Taylor expanded in k around 0
lower-pow.f64100.0
Applied rewrites100.0%
if -0.0140000000000000003 < m < 1.74999999999999997e-6Initial program 93.8%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6493.7
Applied rewrites93.7%
Final simplification97.9%
(FPCore (a k m) :precision binary64 (if (<= m -2.85e+16) (* (/ (+ (/ (+ (/ 99.0 k) -10.0) k) 1.0) (* k k)) a) (if (<= m 0.87) (/ a (fma (- k -10.0) k 1.0)) (* (* (* 99.0 k) a) k))))
double code(double a, double k, double m) {
double tmp;
if (m <= -2.85e+16) {
tmp = (((((99.0 / k) + -10.0) / k) + 1.0) / (k * k)) * a;
} else if (m <= 0.87) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = ((99.0 * k) * a) * k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -2.85e+16) tmp = Float64(Float64(Float64(Float64(Float64(Float64(99.0 / k) + -10.0) / k) + 1.0) / Float64(k * k)) * a); elseif (m <= 0.87) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(Float64(Float64(99.0 * k) * a) * k); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -2.85e+16], N[(N[(N[(N[(N[(N[(99.0 / k), $MachinePrecision] + -10.0), $MachinePrecision] / k), $MachinePrecision] + 1.0), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[m, 0.87], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(99.0 * k), $MachinePrecision] * a), $MachinePrecision] * k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.85 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{\frac{99}{k} + -10}{k} + 1}{k \cdot k} \cdot a\\
\mathbf{elif}\;m \leq 0.87:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(99 \cdot k\right) \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < -2.85e16Initial program 100.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64100.0
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-+.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6437.9
Applied rewrites37.9%
Taylor expanded in k around inf
Applied rewrites68.9%
if -2.85e16 < m < 0.869999999999999996Initial program 94.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6493.0
Applied rewrites93.0%
if 0.869999999999999996 < m Initial program 83.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
Applied rewrites19.0%
Taylor expanded in k around inf
Applied rewrites19.0%
Taylor expanded in k around inf
Applied rewrites42.1%
(FPCore (a k m) :precision binary64 (if (<= m -2.85e+16) (* (/ 1.0 (* k k)) a) (if (<= m 0.87) (/ a (fma (- k -10.0) k 1.0)) (* (* (* 99.0 k) a) k))))
double code(double a, double k, double m) {
double tmp;
if (m <= -2.85e+16) {
tmp = (1.0 / (k * k)) * a;
} else if (m <= 0.87) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = ((99.0 * k) * a) * k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -2.85e+16) tmp = Float64(Float64(1.0 / Float64(k * k)) * a); elseif (m <= 0.87) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(Float64(Float64(99.0 * k) * a) * k); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -2.85e+16], N[(N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[m, 0.87], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(99.0 * k), $MachinePrecision] * a), $MachinePrecision] * k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.85 \cdot 10^{+16}:\\
\;\;\;\;\frac{1}{k \cdot k} \cdot a\\
\mathbf{elif}\;m \leq 0.87:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(99 \cdot k\right) \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < -2.85e16Initial program 100.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64100.0
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-+.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6437.9
Applied rewrites37.9%
Taylor expanded in k around inf
Applied rewrites60.1%
if -2.85e16 < m < 0.869999999999999996Initial program 94.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6493.0
Applied rewrites93.0%
if 0.869999999999999996 < m Initial program 83.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
Applied rewrites19.0%
Taylor expanded in k around inf
Applied rewrites19.0%
Taylor expanded in k around inf
Applied rewrites42.1%
(FPCore (a k m) :precision binary64 (if (<= m -2.85e+16) (/ a (* k k)) (if (<= m 0.87) (/ a (fma (- k -10.0) k 1.0)) (* (* (* 99.0 k) a) k))))
double code(double a, double k, double m) {
double tmp;
if (m <= -2.85e+16) {
tmp = a / (k * k);
} else if (m <= 0.87) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = ((99.0 * k) * a) * k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -2.85e+16) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.87) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(Float64(Float64(99.0 * k) * a) * k); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -2.85e+16], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.87], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(99.0 * k), $MachinePrecision] * a), $MachinePrecision] * k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.85 \cdot 10^{+16}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.87:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(99 \cdot k\right) \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < -2.85e16Initial program 100.0%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6437.9
Applied rewrites37.9%
Taylor expanded in k around inf
Applied rewrites59.0%
if -2.85e16 < m < 0.869999999999999996Initial program 94.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6493.0
Applied rewrites93.0%
if 0.869999999999999996 < m Initial program 83.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
Applied rewrites19.0%
Taylor expanded in k around inf
Applied rewrites19.0%
Taylor expanded in k around inf
Applied rewrites42.1%
(FPCore (a k m) :precision binary64 (if (<= m -2.1e-15) (/ a (* k k)) (if (<= m 0.87) (/ a (fma 10.0 k 1.0)) (* (* (* 99.0 k) a) k))))
double code(double a, double k, double m) {
double tmp;
if (m <= -2.1e-15) {
tmp = a / (k * k);
} else if (m <= 0.87) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = ((99.0 * k) * a) * k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -2.1e-15) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.87) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = Float64(Float64(Float64(99.0 * k) * a) * k); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -2.1e-15], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.87], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(99.0 * k), $MachinePrecision] * a), $MachinePrecision] * k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.1 \cdot 10^{-15}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.87:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(99 \cdot k\right) \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < -2.09999999999999981e-15Initial program 100.0%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6439.5
Applied rewrites39.5%
Taylor expanded in k around inf
Applied rewrites59.7%
if -2.09999999999999981e-15 < m < 0.869999999999999996Initial program 93.8%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6493.7
Applied rewrites93.7%
Taylor expanded in k around 0
Applied rewrites68.2%
if 0.869999999999999996 < m Initial program 83.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
Applied rewrites19.0%
Taylor expanded in k around inf
Applied rewrites19.0%
Taylor expanded in k around inf
Applied rewrites42.1%
(FPCore (a k m) :precision binary64 (if (<= m 1.55e-117) (/ a (* k k)) (if (<= m 0.49) (* 1.0 a) (* (* (* 99.0 k) a) k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.55e-117) {
tmp = a / (k * k);
} else if (m <= 0.49) {
tmp = 1.0 * a;
} else {
tmp = ((99.0 * k) * 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 <= 1.55d-117) then
tmp = a / (k * k)
else if (m <= 0.49d0) then
tmp = 1.0d0 * a
else
tmp = ((99.0d0 * k) * a) * k
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1.55e-117) {
tmp = a / (k * k);
} else if (m <= 0.49) {
tmp = 1.0 * a;
} else {
tmp = ((99.0 * k) * a) * k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1.55e-117: tmp = a / (k * k) elif m <= 0.49: tmp = 1.0 * a else: tmp = ((99.0 * k) * a) * k return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1.55e-117) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.49) tmp = Float64(1.0 * a); else tmp = Float64(Float64(Float64(99.0 * k) * a) * k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1.55e-117) tmp = a / (k * k); elseif (m <= 0.49) tmp = 1.0 * a; else tmp = ((99.0 * k) * a) * k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1.55e-117], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.49], N[(1.0 * a), $MachinePrecision], N[(N[(N[(99.0 * k), $MachinePrecision] * a), $MachinePrecision] * k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.55 \cdot 10^{-117}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.49:\\
\;\;\;\;1 \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(99 \cdot k\right) \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < 1.55000000000000005e-117Initial program 97.3%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6463.4
Applied rewrites63.4%
Taylor expanded in k around inf
Applied rewrites56.0%
if 1.55000000000000005e-117 < m < 0.48999999999999999Initial program 93.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6493.6
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-+.f6493.6
Applied rewrites93.6%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6493.2
Applied rewrites93.2%
Taylor expanded in k around 0
Applied rewrites67.9%
if 0.48999999999999999 < m Initial program 83.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
Applied rewrites19.0%
Taylor expanded in k around inf
Applied rewrites19.0%
Taylor expanded in k around inf
Applied rewrites42.1%
(FPCore (a k m) :precision binary64 (if (<= m 0.49) (* 1.0 a) (* (* (* 99.0 k) a) k)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.49) {
tmp = 1.0 * a;
} else {
tmp = ((99.0 * k) * 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 <= 0.49d0) then
tmp = 1.0d0 * a
else
tmp = ((99.0d0 * k) * a) * k
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 0.49) {
tmp = 1.0 * a;
} else {
tmp = ((99.0 * k) * a) * k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.49: tmp = 1.0 * a else: tmp = ((99.0 * k) * a) * k return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.49) tmp = Float64(1.0 * a); else tmp = Float64(Float64(Float64(99.0 * k) * a) * k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 0.49) tmp = 1.0 * a; else tmp = ((99.0 * k) * a) * k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.49], N[(1.0 * a), $MachinePrecision], N[(N[(N[(99.0 * k), $MachinePrecision] * a), $MachinePrecision] * k), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.49:\\
\;\;\;\;1 \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(99 \cdot k\right) \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < 0.48999999999999999Initial program 97.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6497.0
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-+.f6497.0
Applied rewrites97.0%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6465.9
Applied rewrites65.9%
Taylor expanded in k around 0
Applied rewrites26.4%
if 0.48999999999999999 < m Initial program 83.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
Applied rewrites19.0%
Taylor expanded in k around inf
Applied rewrites19.0%
Taylor expanded in k around inf
Applied rewrites42.1%
(FPCore (a k m) :precision binary64 (if (<= m 260000000.0) (* 1.0 a) (* (* -10.0 a) k)))
double code(double a, double k, double m) {
double tmp;
if (m <= 260000000.0) {
tmp = 1.0 * a;
} 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 <= 260000000.0d0) then
tmp = 1.0d0 * a
else
tmp = ((-10.0d0) * a) * k
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 260000000.0) {
tmp = 1.0 * a;
} else {
tmp = (-10.0 * a) * k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 260000000.0: tmp = 1.0 * a else: tmp = (-10.0 * a) * k return tmp
function code(a, k, m) tmp = 0.0 if (m <= 260000000.0) tmp = Float64(1.0 * a); else tmp = Float64(Float64(-10.0 * a) * k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 260000000.0) tmp = 1.0 * a; else tmp = (-10.0 * a) * k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 260000000.0], N[(1.0 * a), $MachinePrecision], N[(N[(-10.0 * a), $MachinePrecision] * k), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 260000000:\\
\;\;\;\;1 \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(-10 \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < 2.6e8Initial program 96.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6496.4
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-+.f6496.4
Applied rewrites96.4%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6465.5
Applied rewrites65.5%
Taylor expanded in k around 0
Applied rewrites26.3%
if 2.6e8 < m Initial program 84.2%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
Applied rewrites4.1%
Taylor expanded in k around inf
Applied rewrites15.8%
(FPCore (a k m) :precision binary64 (* 1.0 a))
double code(double a, double k, double m) {
return 1.0 * 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 = 1.0d0 * a
end function
public static double code(double a, double k, double m) {
return 1.0 * a;
}
def code(a, k, m): return 1.0 * a
function code(a, k, m) return Float64(1.0 * a) end
function tmp = code(a, k, m) tmp = 1.0 * a; end
code[a_, k_, m_] := N[(1.0 * a), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot a
\end{array}
Initial program 92.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6492.8
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-+.f6492.8
Applied rewrites92.8%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6447.0
Applied rewrites47.0%
Taylor expanded in k around 0
Applied rewrites19.6%
herbie shell --seed 2025016
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))