
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}
(FPCore (a k m) :precision binary64 (if (<= m 3.5) (* (/ (pow (pow k (- m)) -1.0) (fma (+ k 10.0) k 1.0)) a) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.5) {
tmp = (pow(pow(k, -m), -1.0) / fma((k + 10.0), k, 1.0)) * a;
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 3.5) tmp = Float64(Float64(((k ^ Float64(-m)) ^ -1.0) / fma(Float64(k + 10.0), k, 1.0)) * a); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 3.5], N[(N[(N[Power[N[Power[k, (-m)], $MachinePrecision], -1.0], $MachinePrecision] / N[(N[(k + 10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.5:\\
\;\;\;\;\frac{{\left({k}^{\left(-m\right)}\right)}^{-1}}{\mathsf{fma}\left(k + 10, k, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 3.5Initial program 97.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6497.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-+.f6497.7
Applied rewrites97.7%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
pow2N/A
lower-pow.f6497.7
Applied rewrites97.7%
Taylor expanded in k around inf
*-commutativeN/A
exp-prodN/A
lower-pow.f64N/A
log-recN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-neg.f6497.7
Applied rewrites97.7%
Applied rewrites97.7%
if 3.5 < m Initial program 75.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.9
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-+.f6475.9
Applied rewrites75.9%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
pow2N/A
lower-pow.f6475.9
Applied rewrites75.9%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64100.0
Applied rewrites100.0%
Final simplification98.5%
(FPCore (a k m) :precision binary64 (if (<= (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))) 0.0) (* (* a k) -10.0) (* (fma -10.0 k 1.0) a)))
double code(double a, double k, double m) {
double tmp;
if (((a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))) <= 0.0) {
tmp = (a * k) * -10.0;
} else {
tmp = fma(-10.0, k, 1.0) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) <= 0.0) tmp = Float64(Float64(a * k) * -10.0); else tmp = Float64(fma(-10.0, k, 1.0) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[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], 0.0], N[(N[(a * k), $MachinePrecision] * -10.0), $MachinePrecision], N[(N[(-10.0 * k + 1.0), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq 0:\\
\;\;\;\;\left(a \cdot k\right) \cdot -10\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-10, 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))) < 0.0Initial program 97.8%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6446.4
Applied rewrites46.4%
Taylor expanded in k around 0
Applied rewrites14.6%
Taylor expanded in k around inf
Applied rewrites9.3%
Applied rewrites9.3%
if 0.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 74.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-+.f6437.1
Applied rewrites37.1%
Taylor expanded in k around 0
Applied rewrites25.7%
Taylor expanded in k around 0
Applied rewrites25.7%
Final simplification14.5%
(FPCore (a k m)
:precision binary64
(if (<= m -68.0)
(/ (/ (* (/ (/ a k) k) 99.0) k) k)
(if (<= m 1.3e-12)
(* (pow (fma (+ 10.0 k) k 1.0) -1.0) a)
(/ a (* (* (/ (pow k -1.0) k) k) k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -68.0) {
tmp = ((((a / k) / k) * 99.0) / k) / k;
} else if (m <= 1.3e-12) {
tmp = pow(fma((10.0 + k), k, 1.0), -1.0) * a;
} else {
tmp = a / (((pow(k, -1.0) / k) * k) * k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -68.0) tmp = Float64(Float64(Float64(Float64(Float64(a / k) / k) * 99.0) / k) / k); elseif (m <= 1.3e-12) tmp = Float64((fma(Float64(10.0 + k), k, 1.0) ^ -1.0) * a); else tmp = Float64(a / Float64(Float64(Float64((k ^ -1.0) / k) * k) * k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -68.0], N[(N[(N[(N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision] * 99.0), $MachinePrecision] / k), $MachinePrecision] / k), $MachinePrecision], If[LessEqual[m, 1.3e-12], N[(N[Power[N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision], -1.0], $MachinePrecision] * a), $MachinePrecision], N[(a / N[(N[(N[(N[Power[k, -1.0], $MachinePrecision] / k), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -68:\\
\;\;\;\;\frac{\frac{\frac{\frac{a}{k}}{k} \cdot 99}{k}}{k}\\
\mathbf{elif}\;m \leq 1.3 \cdot 10^{-12}:\\
\;\;\;\;{\left(\mathsf{fma}\left(10 + k, k, 1\right)\right)}^{-1} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\left(\frac{{k}^{-1}}{k} \cdot k\right) \cdot k}\\
\end{array}
\end{array}
if m < -68Initial 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-+.f6434.1
Applied rewrites34.1%
Taylor expanded in k around 0
Applied rewrites3.3%
Taylor expanded in k around inf
Applied rewrites71.2%
Taylor expanded in k around 0
Applied rewrites81.4%
if -68 < m < 1.29999999999999991e-12Initial program 95.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.4
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-+.f6495.4
Applied rewrites95.4%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6495.1
Applied rewrites95.1%
if 1.29999999999999991e-12 < m Initial program 76.4%
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.6
Applied rewrites3.6%
Taylor expanded in k around inf
Applied rewrites32.9%
Taylor expanded in k around 0
Applied rewrites55.2%
Final simplification76.8%
(FPCore (a k m)
:precision binary64
(if (<= m -68.0)
(/ a (* k k))
(if (<= m 1.3e-12)
(* (pow (fma (+ 10.0 k) k 1.0) -1.0) a)
(/ a (* (* (/ (pow k -1.0) k) k) k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -68.0) {
tmp = a / (k * k);
} else if (m <= 1.3e-12) {
tmp = pow(fma((10.0 + k), k, 1.0), -1.0) * a;
} else {
tmp = a / (((pow(k, -1.0) / k) * k) * k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -68.0) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.3e-12) tmp = Float64((fma(Float64(10.0 + k), k, 1.0) ^ -1.0) * a); else tmp = Float64(a / Float64(Float64(Float64((k ^ -1.0) / k) * k) * k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -68.0], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.3e-12], N[(N[Power[N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision], -1.0], $MachinePrecision] * a), $MachinePrecision], N[(a / N[(N[(N[(N[Power[k, -1.0], $MachinePrecision] / k), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -68:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.3 \cdot 10^{-12}:\\
\;\;\;\;{\left(\mathsf{fma}\left(10 + k, k, 1\right)\right)}^{-1} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\left(\frac{{k}^{-1}}{k} \cdot k\right) \cdot k}\\
\end{array}
\end{array}
if m < -68Initial 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-+.f6434.1
Applied rewrites34.1%
Taylor expanded in k around inf
Applied rewrites66.7%
if -68 < m < 1.29999999999999991e-12Initial program 95.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.4
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-+.f6495.4
Applied rewrites95.4%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6495.1
Applied rewrites95.1%
if 1.29999999999999991e-12 < m Initial program 76.4%
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.6
Applied rewrites3.6%
Taylor expanded in k around inf
Applied rewrites32.9%
Taylor expanded in k around 0
Applied rewrites55.2%
Final simplification72.0%
(FPCore (a k m) :precision binary64 (if (<= m 3.5) (* (/ (pow k m) (fma (+ k 10.0) k 1.0)) a) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.5) {
tmp = (pow(k, m) / fma((k + 10.0), k, 1.0)) * a;
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 3.5) tmp = Float64(Float64((k ^ m) / fma(Float64(k + 10.0), k, 1.0)) * a); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 3.5], N[(N[(N[Power[k, m], $MachinePrecision] / N[(N[(k + 10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.5:\\
\;\;\;\;\frac{{k}^{m}}{\mathsf{fma}\left(k + 10, k, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 3.5Initial program 97.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6497.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-+.f6497.7
Applied rewrites97.7%
if 3.5 < m Initial program 75.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.9
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-+.f6475.9
Applied rewrites75.9%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
pow2N/A
lower-pow.f6475.9
Applied rewrites75.9%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (or (<= m -68.0) (not (<= m 1.3e-12))) (* (pow k m) a) (* (pow (fma (+ 10.0 k) k 1.0) -1.0) a)))
double code(double a, double k, double m) {
double tmp;
if ((m <= -68.0) || !(m <= 1.3e-12)) {
tmp = pow(k, m) * a;
} else {
tmp = pow(fma((10.0 + k), k, 1.0), -1.0) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if ((m <= -68.0) || !(m <= 1.3e-12)) tmp = Float64((k ^ m) * a); else tmp = Float64((fma(Float64(10.0 + k), k, 1.0) ^ -1.0) * a); end return tmp end
code[a_, k_, m_] := If[Or[LessEqual[m, -68.0], N[Not[LessEqual[m, 1.3e-12]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision], N[(N[Power[N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision], -1.0], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -68 \lor \neg \left(m \leq 1.3 \cdot 10^{-12}\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{fma}\left(10 + k, k, 1\right)\right)}^{-1} \cdot a\\
\end{array}
\end{array}
if m < -68 or 1.29999999999999991e-12 < m Initial program 87.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.8
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-+.f6487.8
Applied rewrites87.8%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
pow2N/A
lower-pow.f6487.8
Applied rewrites87.8%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6499.5
Applied rewrites99.5%
if -68 < m < 1.29999999999999991e-12Initial program 95.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.4
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-+.f6495.4
Applied rewrites95.4%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6495.1
Applied rewrites95.1%
Final simplification98.0%
(FPCore (a k m)
:precision binary64
(if (<= m -68.0)
(/ a (* k k))
(if (<= m 1.6)
(* (pow (fma (+ 10.0 k) k 1.0) -1.0) a)
(* (* (* a k) k) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -68.0) {
tmp = a / (k * k);
} else if (m <= 1.6) {
tmp = pow(fma((10.0 + k), k, 1.0), -1.0) * a;
} else {
tmp = ((a * k) * k) * 99.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -68.0) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.6) tmp = Float64((fma(Float64(10.0 + k), k, 1.0) ^ -1.0) * a); else tmp = Float64(Float64(Float64(a * k) * k) * 99.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -68.0], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.6], N[(N[Power[N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision], -1.0], $MachinePrecision] * a), $MachinePrecision], N[(N[(N[(a * k), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -68:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.6:\\
\;\;\;\;{\left(\mathsf{fma}\left(10 + k, k, 1\right)\right)}^{-1} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\
\end{array}
\end{array}
if m < -68Initial 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-+.f6434.1
Applied rewrites34.1%
Taylor expanded in k around inf
Applied rewrites66.7%
if -68 < m < 1.6000000000000001Initial program 95.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.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-+.f6495.5
Applied rewrites95.5%
Taylor expanded in m around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6493.7
Applied rewrites93.7%
if 1.6000000000000001 < m Initial program 75.9%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f642.8
Applied rewrites2.8%
Taylor expanded in k around 0
Applied rewrites23.9%
Taylor expanded in k around inf
Applied rewrites53.8%
Final simplification71.4%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ a (* k k))))
(if (<= m -2.45e-36)
t_0
(if (<= m 2.3e-129)
(/ a 1.0)
(if (<= m 1.6) t_0 (* (* (* a k) k) 99.0))))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double tmp;
if (m <= -2.45e-36) {
tmp = t_0;
} else if (m <= 2.3e-129) {
tmp = a / 1.0;
} else if (m <= 1.6) {
tmp = t_0;
} else {
tmp = ((a * k) * k) * 99.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: tmp
t_0 = a / (k * k)
if (m <= (-2.45d-36)) then
tmp = t_0
else if (m <= 2.3d-129) then
tmp = a / 1.0d0
else if (m <= 1.6d0) then
tmp = t_0
else
tmp = ((a * k) * k) * 99.0d0
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 <= -2.45e-36) {
tmp = t_0;
} else if (m <= 2.3e-129) {
tmp = a / 1.0;
} else if (m <= 1.6) {
tmp = t_0;
} else {
tmp = ((a * k) * k) * 99.0;
}
return tmp;
}
def code(a, k, m): t_0 = a / (k * k) tmp = 0 if m <= -2.45e-36: tmp = t_0 elif m <= 2.3e-129: tmp = a / 1.0 elif m <= 1.6: tmp = t_0 else: tmp = ((a * k) * k) * 99.0 return tmp
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) tmp = 0.0 if (m <= -2.45e-36) tmp = t_0; elseif (m <= 2.3e-129) tmp = Float64(a / 1.0); elseif (m <= 1.6) tmp = t_0; else tmp = Float64(Float64(Float64(a * k) * k) * 99.0); end return tmp end
function tmp_2 = code(a, k, m) t_0 = a / (k * k); tmp = 0.0; if (m <= -2.45e-36) tmp = t_0; elseif (m <= 2.3e-129) tmp = a / 1.0; elseif (m <= 1.6) tmp = t_0; else tmp = ((a * k) * k) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -2.45e-36], t$95$0, If[LessEqual[m, 2.3e-129], N[(a / 1.0), $MachinePrecision], If[LessEqual[m, 1.6], t$95$0, N[(N[(N[(a * k), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
\mathbf{if}\;m \leq -2.45 \cdot 10^{-36}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 2.3 \cdot 10^{-129}:\\
\;\;\;\;\frac{a}{1}\\
\mathbf{elif}\;m \leq 1.6:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\
\end{array}
\end{array}
if m < -2.4499999999999998e-36 or 2.3e-129 < m < 1.6000000000000001Initial program 99.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.9
Applied rewrites43.9%
Taylor expanded in k around inf
Applied rewrites67.2%
if -2.4499999999999998e-36 < m < 2.3e-129Initial program 95.6%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6495.6
Applied rewrites95.6%
Taylor expanded in k around 0
Applied rewrites55.9%
if 1.6000000000000001 < m Initial program 75.9%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f642.8
Applied rewrites2.8%
Taylor expanded in k around 0
Applied rewrites23.9%
Taylor expanded in k around inf
Applied rewrites53.8%
Final simplification59.7%
(FPCore (a k m) :precision binary64 (if (<= m -68.0) (/ a (* k k)) (if (<= m 1.6) (/ a (fma (+ 10.0 k) k 1.0)) (* (* (* a k) k) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -68.0) {
tmp = a / (k * k);
} else if (m <= 1.6) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = ((a * k) * k) * 99.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -68.0) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.6) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(Float64(a * k) * k) * 99.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -68.0], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.6], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * k), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -68:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.6:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\
\end{array}
\end{array}
if m < -68Initial 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-+.f6434.1
Applied rewrites34.1%
Taylor expanded in k around inf
Applied rewrites66.7%
if -68 < m < 1.6000000000000001Initial program 95.4%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6493.7
Applied rewrites93.7%
if 1.6000000000000001 < m Initial program 75.9%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f642.8
Applied rewrites2.8%
Taylor expanded in k around 0
Applied rewrites23.9%
Taylor expanded in k around inf
Applied rewrites53.8%
Final simplification71.4%
(FPCore (a k m) :precision binary64 (if (<= m -2.5e-36) (/ a (* k k)) (if (<= m 1.6) (/ a (fma 10.0 k 1.0)) (* (* (* a k) k) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -2.5e-36) {
tmp = a / (k * k);
} else if (m <= 1.6) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = ((a * k) * k) * 99.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -2.5e-36) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.6) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = Float64(Float64(Float64(a * k) * k) * 99.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -2.5e-36], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.6], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * k), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.5 \cdot 10^{-36}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.6:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\
\end{array}
\end{array}
if m < -2.50000000000000002e-36Initial 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-+.f6436.4
Applied rewrites36.4%
Taylor expanded in k around inf
Applied rewrites66.9%
if -2.50000000000000002e-36 < m < 1.6000000000000001Initial program 95.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-+.f6493.5
Applied rewrites93.5%
Taylor expanded in k around 0
Applied rewrites60.3%
if 1.6000000000000001 < m Initial program 75.9%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f642.8
Applied rewrites2.8%
Taylor expanded in k around 0
Applied rewrites23.9%
Taylor expanded in k around inf
Applied rewrites53.8%
Final simplification60.3%
(FPCore (a k m) :precision binary64 (if (<= m 1.35) (/ a 1.0) (* (* (* a k) k) 99.0)))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.35) {
tmp = a / 1.0;
} else {
tmp = ((a * k) * k) * 99.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 <= 1.35d0) then
tmp = a / 1.0d0
else
tmp = ((a * k) * k) * 99.0d0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1.35) {
tmp = a / 1.0;
} else {
tmp = ((a * k) * k) * 99.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1.35: tmp = a / 1.0 else: tmp = ((a * k) * k) * 99.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1.35) tmp = Float64(a / 1.0); else tmp = Float64(Float64(Float64(a * k) * k) * 99.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1.35) tmp = a / 1.0; else tmp = ((a * k) * k) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1.35], N[(a / 1.0), $MachinePrecision], N[(N[(N[(a * k), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.35:\\
\;\;\;\;\frac{a}{1}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\
\end{array}
\end{array}
if m < 1.3500000000000001Initial program 97.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-+.f6464.4
Applied rewrites64.4%
Taylor expanded in k around 0
Applied rewrites26.3%
if 1.3500000000000001 < m Initial program 75.9%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f642.8
Applied rewrites2.8%
Taylor expanded in k around 0
Applied rewrites23.9%
Taylor expanded in k around inf
Applied rewrites53.8%
Final simplification35.6%
(FPCore (a k m) :precision binary64 (if (<= m 135000.0) (/ a 1.0) (* (* -10.0 k) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 135000.0) {
tmp = a / 1.0;
} else {
tmp = (-10.0 * 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 <= 135000.0d0) then
tmp = a / 1.0d0
else
tmp = ((-10.0d0) * k) * a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 135000.0) {
tmp = a / 1.0;
} else {
tmp = (-10.0 * k) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 135000.0: tmp = a / 1.0 else: tmp = (-10.0 * k) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 135000.0) tmp = Float64(a / 1.0); else tmp = Float64(Float64(-10.0 * k) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 135000.0) tmp = a / 1.0; else tmp = (-10.0 * k) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 135000.0], N[(a / 1.0), $MachinePrecision], N[(N[(-10.0 * k), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 135000:\\
\;\;\;\;\frac{a}{1}\\
\mathbf{else}:\\
\;\;\;\;\left(-10 \cdot k\right) \cdot a\\
\end{array}
\end{array}
if m < 135000Initial program 97.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-+.f6463.7
Applied rewrites63.7%
Taylor expanded in k around 0
Applied rewrites26.0%
if 135000 < m Initial program 76.5%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f642.8
Applied rewrites2.8%
Taylor expanded in k around 0
Applied rewrites4.0%
Taylor expanded in k around inf
Applied rewrites17.3%
Applied rewrites17.3%
Final simplification23.1%
(FPCore (a k m) :precision binary64 (* (* a k) -10.0))
double code(double a, double k, double m) {
return (a * k) * -10.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * k) * (-10.0d0)
end function
public static double code(double a, double k, double m) {
return (a * k) * -10.0;
}
def code(a, k, m): return (a * k) * -10.0
function code(a, k, m) return Float64(Float64(a * k) * -10.0) end
function tmp = code(a, k, m) tmp = (a * k) * -10.0; end
code[a_, k_, m_] := N[(N[(a * k), $MachinePrecision] * -10.0), $MachinePrecision]
\begin{array}{l}
\\
\left(a \cdot k\right) \cdot -10
\end{array}
Initial program 90.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-+.f6443.5
Applied rewrites43.5%
Taylor expanded in k around 0
Applied rewrites18.1%
Taylor expanded in k around inf
Applied rewrites7.4%
Applied rewrites7.4%
Final simplification7.4%
(FPCore (a k m) :precision binary64 (* (* -10.0 a) k))
double code(double a, double k, double m) {
return (-10.0 * a) * 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 = ((-10.0d0) * a) * k
end function
public static double code(double a, double k, double m) {
return (-10.0 * a) * k;
}
def code(a, k, m): return (-10.0 * a) * k
function code(a, k, m) return Float64(Float64(-10.0 * a) * k) end
function tmp = code(a, k, m) tmp = (-10.0 * a) * k; end
code[a_, k_, m_] := N[(N[(-10.0 * a), $MachinePrecision] * k), $MachinePrecision]
\begin{array}{l}
\\
\left(-10 \cdot a\right) \cdot k
\end{array}
Initial program 90.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-+.f6443.5
Applied rewrites43.5%
Taylor expanded in k around 0
Applied rewrites18.1%
Taylor expanded in k around inf
Applied rewrites7.4%
Final simplification7.4%
herbie shell --seed 2024356
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))