
(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 9.4e-7) (* (pow k m) (/ a (fma (+ k 10.0) k 1.0))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 9.4e-7) {
tmp = pow(k, m) * (a / fma((k + 10.0), k, 1.0));
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 9.4e-7) tmp = Float64((k ^ m) * Float64(a / fma(Float64(k + 10.0), k, 1.0))); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 9.4e-7], N[(N[Power[k, m], $MachinePrecision] * N[(a / N[(N[(k + 10.0), $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 9.4 \cdot 10^{-7}:\\
\;\;\;\;{k}^{m} \cdot \frac{a}{\mathsf{fma}\left(k + 10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 9.4e-7Initial program 96.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6496.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6496.3
Applied rewrites96.3%
if 9.4e-7 < m Initial program 81.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6481.0
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6481.0
Applied rewrites81.0%
Taylor expanded in k around 0
lower-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (<= m 9.4e-7) (* (/ (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 <= 9.4e-7) {
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 <= 9.4e-7) 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, 9.4e-7], 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 9.4 \cdot 10^{-7}:\\
\;\;\;\;\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 < 9.4e-7Initial program 96.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6496.2
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6496.2
Applied rewrites96.2%
if 9.4e-7 < m Initial program 81.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6481.0
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6481.0
Applied rewrites81.0%
Taylor expanded in k around 0
lower-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (or (<= m -2.25e-5) (not (<= m 1.85e-9))) (* (pow k m) a) (/ a (fma (+ 10.0 k) k 1.0))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -2.25e-5) || !(m <= 1.85e-9)) {
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 <= -2.25e-5) || !(m <= 1.85e-9)) 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, -2.25e-5], N[Not[LessEqual[m, 1.85e-9]], $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 -2.25 \cdot 10^{-5} \lor \neg \left(m \leq 1.85 \cdot 10^{-9}\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\end{array}
\end{array}
if m < -2.25000000000000014e-5 or 1.85e-9 < m Initial program 90.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6490.5
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6490.5
Applied rewrites90.5%
Taylor expanded in k around 0
lower-pow.f6499.4
Applied rewrites99.4%
if -2.25000000000000014e-5 < m < 1.85e-9Initial program 92.7%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6492.6
Applied rewrites92.6%
Final simplification97.1%
(FPCore (a k m) :precision binary64 (if (<= m -1100.0) (* (pow (* k k) -1.0) a) (if (<= m 1.2) (/ a (fma (+ 10.0 k) k 1.0)) (* (* 99.0 (* k k)) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -1100.0) {
tmp = pow((k * k), -1.0) * a;
} else if (m <= 1.2) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = (99.0 * (k * k)) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -1100.0) tmp = Float64((Float64(k * k) ^ -1.0) * a); elseif (m <= 1.2) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(99.0 * Float64(k * k)) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -1100.0], N[(N[Power[N[(k * k), $MachinePrecision], -1.0], $MachinePrecision] * a), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(99.0 * N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1100:\\
\;\;\;\;{\left(k \cdot k\right)}^{-1} \cdot a\\
\mathbf{elif}\;m \leq 1.2:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(99 \cdot \left(k \cdot k\right)\right) \cdot a\\
\end{array}
\end{array}
if m < -1100Initial program 100.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64100.0
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6443.8
Applied rewrites43.8%
Taylor expanded in k around 0
Applied rewrites3.8%
Taylor expanded in k around inf
Applied rewrites64.4%
if -1100 < m < 1.19999999999999996Initial program 93.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6490.3
Applied rewrites90.3%
if 1.19999999999999996 < m Initial program 80.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.7
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6480.7
Applied rewrites80.7%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.3
Applied rewrites3.3%
Taylor expanded in k around 0
Applied rewrites27.3%
Taylor expanded in k around inf
Applied rewrites59.7%
Final simplification72.3%
(FPCore (a k m) :precision binary64 (if (<= m -1100.0) (* (/ (+ (/ (+ (/ 99.0 k) -10.0) k) 1.0) (* k k)) a) (if (<= m 1.2) (/ a (fma (+ 10.0 k) k 1.0)) (* (* 99.0 (* k k)) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -1100.0) {
tmp = (((((99.0 / k) + -10.0) / k) + 1.0) / (k * k)) * a;
} else if (m <= 1.2) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = (99.0 * (k * k)) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -1100.0) tmp = Float64(Float64(Float64(Float64(Float64(Float64(99.0 / k) + -10.0) / k) + 1.0) / Float64(k * k)) * a); elseif (m <= 1.2) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(99.0 * Float64(k * k)) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -1100.0], 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, 1.2], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(99.0 * N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1100:\\
\;\;\;\;\frac{\frac{\frac{99}{k} + -10}{k} + 1}{k \cdot k} \cdot a\\
\mathbf{elif}\;m \leq 1.2:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(99 \cdot \left(k \cdot k\right)\right) \cdot a\\
\end{array}
\end{array}
if m < -1100Initial program 100.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64100.0
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6443.8
Applied rewrites43.8%
Taylor expanded in k around inf
Applied rewrites74.1%
if -1100 < m < 1.19999999999999996Initial program 93.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6490.3
Applied rewrites90.3%
if 1.19999999999999996 < m Initial program 80.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.7
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6480.7
Applied rewrites80.7%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.3
Applied rewrites3.3%
Taylor expanded in k around 0
Applied rewrites27.3%
Taylor expanded in k around inf
Applied rewrites59.7%
(FPCore (a k m) :precision binary64 (if (<= m -1100.0) (/ (- a (/ (* (- 10.0 (/ 99.0 k)) a) k)) (* k k)) (if (<= m 1.2) (/ a (fma (+ 10.0 k) k 1.0)) (* (* 99.0 (* k k)) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -1100.0) {
tmp = (a - (((10.0 - (99.0 / k)) * a) / k)) / (k * k);
} else if (m <= 1.2) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = (99.0 * (k * k)) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -1100.0) tmp = Float64(Float64(a - Float64(Float64(Float64(10.0 - Float64(99.0 / k)) * a) / k)) / Float64(k * k)); elseif (m <= 1.2) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(99.0 * Float64(k * k)) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -1100.0], N[(N[(a - N[(N[(N[(10.0 - N[(99.0 / k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(99.0 * N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1100:\\
\;\;\;\;\frac{a - \frac{\left(10 - \frac{99}{k}\right) \cdot a}{k}}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.2:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(99 \cdot \left(k \cdot k\right)\right) \cdot a\\
\end{array}
\end{array}
if m < -1100Initial 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
lower-+.f6443.8
Applied rewrites43.8%
Taylor expanded in k around 0
Applied rewrites2.9%
Taylor expanded in k around inf
Applied rewrites67.1%
Taylor expanded in a around 0
Applied rewrites67.1%
if -1100 < m < 1.19999999999999996Initial program 93.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6490.3
Applied rewrites90.3%
if 1.19999999999999996 < m Initial program 80.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.7
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6480.7
Applied rewrites80.7%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.3
Applied rewrites3.3%
Taylor expanded in k around 0
Applied rewrites27.3%
Taylor expanded in k around inf
Applied rewrites59.7%
(FPCore (a k m) :precision binary64 (if (<= m -1100.0) (/ (- a (/ (* (/ a k) -99.0) k)) (* k k)) (if (<= m 1.2) (/ a (fma (+ 10.0 k) k 1.0)) (* (* 99.0 (* k k)) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -1100.0) {
tmp = (a - (((a / k) * -99.0) / k)) / (k * k);
} else if (m <= 1.2) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = (99.0 * (k * k)) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -1100.0) tmp = Float64(Float64(a - Float64(Float64(Float64(a / k) * -99.0) / k)) / Float64(k * k)); elseif (m <= 1.2) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(99.0 * Float64(k * k)) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -1100.0], N[(N[(a - N[(N[(N[(a / k), $MachinePrecision] * -99.0), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(99.0 * N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1100:\\
\;\;\;\;\frac{a - \frac{\frac{a}{k} \cdot -99}{k}}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.2:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(99 \cdot \left(k \cdot k\right)\right) \cdot a\\
\end{array}
\end{array}
if m < -1100Initial 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
lower-+.f6443.8
Applied rewrites43.8%
Taylor expanded in k around 0
Applied rewrites2.9%
Taylor expanded in k around inf
Applied rewrites67.1%
Taylor expanded in k around 0
Applied rewrites67.1%
if -1100 < m < 1.19999999999999996Initial program 93.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6490.3
Applied rewrites90.3%
if 1.19999999999999996 < m Initial program 80.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.7
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6480.7
Applied rewrites80.7%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.3
Applied rewrites3.3%
Taylor expanded in k around 0
Applied rewrites27.3%
Taylor expanded in k around inf
Applied rewrites59.7%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ a (* k k))))
(if (<= m -0.00025)
t_0
(if (<= m 2.2e-125)
(* 1.0 a)
(if (<= m 1.2) t_0 (* (* 99.0 (* k k)) a))))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double tmp;
if (m <= -0.00025) {
tmp = t_0;
} else if (m <= 2.2e-125) {
tmp = 1.0 * a;
} else if (m <= 1.2) {
tmp = t_0;
} else {
tmp = (99.0 * (k * k)) * a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: tmp
t_0 = a / (k * k)
if (m <= (-0.00025d0)) then
tmp = t_0
else if (m <= 2.2d-125) then
tmp = 1.0d0 * a
else if (m <= 1.2d0) then
tmp = t_0
else
tmp = (99.0d0 * (k * k)) * a
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 (m <= -0.00025) {
tmp = t_0;
} else if (m <= 2.2e-125) {
tmp = 1.0 * a;
} else if (m <= 1.2) {
tmp = t_0;
} else {
tmp = (99.0 * (k * k)) * a;
}
return tmp;
}
def code(a, k, m): t_0 = a / (k * k) tmp = 0 if m <= -0.00025: tmp = t_0 elif m <= 2.2e-125: tmp = 1.0 * a elif m <= 1.2: tmp = t_0 else: tmp = (99.0 * (k * k)) * a return tmp
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) tmp = 0.0 if (m <= -0.00025) tmp = t_0; elseif (m <= 2.2e-125) tmp = Float64(1.0 * a); elseif (m <= 1.2) tmp = t_0; else tmp = Float64(Float64(99.0 * Float64(k * k)) * a); end return tmp end
function tmp_2 = code(a, k, m) t_0 = a / (k * k); tmp = 0.0; if (m <= -0.00025) tmp = t_0; elseif (m <= 2.2e-125) tmp = 1.0 * a; elseif (m <= 1.2) tmp = t_0; else tmp = (99.0 * (k * k)) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -0.00025], t$95$0, If[LessEqual[m, 2.2e-125], N[(1.0 * a), $MachinePrecision], If[LessEqual[m, 1.2], t$95$0, N[(N[(99.0 * N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
\mathbf{if}\;m \leq -0.00025:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 2.2 \cdot 10^{-125}:\\
\;\;\;\;1 \cdot a\\
\mathbf{elif}\;m \leq 1.2:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(99 \cdot \left(k \cdot k\right)\right) \cdot a\\
\end{array}
\end{array}
if m < -2.5000000000000001e-4 or 2.19999999999999995e-125 < m < 1.19999999999999996Initial program 98.3%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6451.1
Applied rewrites51.1%
Taylor expanded in k around inf
Applied rewrites62.1%
if -2.5000000000000001e-4 < m < 2.19999999999999995e-125Initial program 93.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6493.5
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6493.5
Applied rewrites93.5%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6492.5
Applied rewrites92.5%
Taylor expanded in k around 0
Applied rewrites58.4%
if 1.19999999999999996 < m Initial program 80.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.7
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6480.7
Applied rewrites80.7%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.3
Applied rewrites3.3%
Taylor expanded in k around 0
Applied rewrites27.3%
Taylor expanded in k around inf
Applied rewrites59.7%
(FPCore (a k m) :precision binary64 (if (<= m -1100.0) (/ a (* k k)) (if (<= m 1.2) (/ a (fma (+ 10.0 k) k 1.0)) (* (* 99.0 (* k k)) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -1100.0) {
tmp = a / (k * k);
} else if (m <= 1.2) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = (99.0 * (k * k)) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -1100.0) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.2) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(99.0 * Float64(k * k)) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -1100.0], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(99.0 * N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1100:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.2:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(99 \cdot \left(k \cdot k\right)\right) \cdot a\\
\end{array}
\end{array}
if m < -1100Initial 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
lower-+.f6443.8
Applied rewrites43.8%
Taylor expanded in k around inf
Applied rewrites63.2%
if -1100 < m < 1.19999999999999996Initial program 93.1%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6490.3
Applied rewrites90.3%
if 1.19999999999999996 < m Initial program 80.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.7
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6480.7
Applied rewrites80.7%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.3
Applied rewrites3.3%
Taylor expanded in k around 0
Applied rewrites27.3%
Taylor expanded in k around inf
Applied rewrites59.7%
(FPCore (a k m) :precision binary64 (if (<= m -0.0007) (/ a (* k k)) (if (<= m 1.2) (/ a (fma 10.0 k 1.0)) (* (* 99.0 (* k k)) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.0007) {
tmp = a / (k * k);
} else if (m <= 1.2) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = (99.0 * (k * k)) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.0007) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.2) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = Float64(Float64(99.0 * Float64(k * k)) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.0007], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(99.0 * N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.0007:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.2:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(99 \cdot \left(k \cdot k\right)\right) \cdot a\\
\end{array}
\end{array}
if m < -6.99999999999999993e-4Initial 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
lower-+.f6444.5
Applied rewrites44.5%
Taylor expanded in k around inf
Applied rewrites63.7%
if -6.99999999999999993e-4 < m < 1.19999999999999996Initial program 93.0%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6490.2
Applied rewrites90.2%
Taylor expanded in k around 0
Applied rewrites67.1%
if 1.19999999999999996 < m Initial program 80.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.7
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6480.7
Applied rewrites80.7%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.3
Applied rewrites3.3%
Taylor expanded in k around 0
Applied rewrites27.3%
Taylor expanded in k around inf
Applied rewrites59.7%
(FPCore (a k m) :precision binary64 (if (<= m 0.92) (* 1.0 a) (* (* 99.0 (* k k)) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.92) {
tmp = 1.0 * a;
} else {
tmp = (99.0 * (k * k)) * a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 0.92d0) then
tmp = 1.0d0 * a
else
tmp = (99.0d0 * (k * k)) * a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 0.92) {
tmp = 1.0 * a;
} else {
tmp = (99.0 * (k * k)) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.92: tmp = 1.0 * a else: tmp = (99.0 * (k * k)) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.92) tmp = Float64(1.0 * a); else tmp = Float64(Float64(99.0 * Float64(k * k)) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 0.92) tmp = 1.0 * a; else tmp = (99.0 * (k * k)) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.92], N[(1.0 * a), $MachinePrecision], N[(N[(99.0 * N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.92:\\
\;\;\;\;1 \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(99 \cdot \left(k \cdot k\right)\right) \cdot a\\
\end{array}
\end{array}
if m < 0.92000000000000004Initial program 96.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6496.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6496.3
Applied rewrites96.3%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6468.8
Applied rewrites68.8%
Taylor expanded in k around 0
Applied rewrites29.9%
if 0.92000000000000004 < m Initial program 80.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.7
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6480.7
Applied rewrites80.7%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.3
Applied rewrites3.3%
Taylor expanded in k around 0
Applied rewrites27.3%
Taylor expanded in k around inf
Applied rewrites59.7%
(FPCore (a k m) :precision binary64 (if (<= m 0.92) (* 1.0 a) (* (* -10.0 a) k)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.92) {
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 <= 0.92d0) 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 <= 0.92) {
tmp = 1.0 * a;
} else {
tmp = (-10.0 * a) * k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.92: tmp = 1.0 * a else: tmp = (-10.0 * a) * k return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.92) 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 <= 0.92) tmp = 1.0 * a; else tmp = (-10.0 * a) * k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.92], N[(1.0 * a), $MachinePrecision], N[(N[(-10.0 * a), $MachinePrecision] * k), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.92:\\
\;\;\;\;1 \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(-10 \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < 0.92000000000000004Initial program 96.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6496.3
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6496.3
Applied rewrites96.3%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6468.8
Applied rewrites68.8%
Taylor expanded in k around 0
Applied rewrites29.9%
if 0.92000000000000004 < m Initial program 80.7%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f643.3
Applied rewrites3.3%
Taylor expanded in k around 0
Applied rewrites6.4%
Taylor expanded in k around inf
Applied rewrites18.1%
(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 91.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.2
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6491.2
Applied rewrites91.2%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6447.6
Applied rewrites47.6%
Taylor expanded in k around 0
Applied rewrites21.5%
herbie shell --seed 2024353
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))