
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}
Herbie found 10 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}
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
:precision binary64
(*
a_s
(if (<= (/ (* a_m (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))) 5e+208)
(* (pow k m) (/ a_m (fma (+ 10.0 k) k 1.0)))
(* (pow k m) a_m))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (((a_m * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))) <= 5e+208) {
tmp = pow(k, m) * (a_m / fma((10.0 + k), k, 1.0));
} else {
tmp = pow(k, m) * a_m;
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (Float64(Float64(a_m * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) <= 5e+208) tmp = Float64((k ^ m) * Float64(a_m / fma(Float64(10.0 + k), k, 1.0))); else tmp = Float64((k ^ m) * a_m); end return Float64(a_s * tmp) end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[N[(N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+208], N[(N[Power[k, m], $MachinePrecision] * N[(a$95$m / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{a\_m \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq 5 \cdot 10^{+208}:\\
\;\;\;\;{k}^{m} \cdot \frac{a\_m}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\_m\\
\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))) < 5.0000000000000004e208Initial program 91.0%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6491.0
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
associate-+l+N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6491.0
Applied rewrites91.0%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-+.f64N/A
lift-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-fma.f64N/A
lift-+.f64N/A
lift-/.f6488.8
Applied rewrites88.8%
if 5.0000000000000004e208 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
Applied rewrites20.2%
Taylor expanded in k around 0
sqr-powN/A
unpow2N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-powN/A
lower-pow.f6482.7
Applied rewrites82.7%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
:precision binary64
(*
a_s
(if (<= m -5.4e-10)
(* (pow k m) (/ a_m (* k k)))
(if (<= m 5e-7)
(/ (fma (* a_m m) (log k) a_m) (fma (+ 10.0 k) k 1.0))
(* (pow k m) a_m)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= -5.4e-10) {
tmp = pow(k, m) * (a_m / (k * k));
} else if (m <= 5e-7) {
tmp = fma((a_m * m), log(k), a_m) / fma((10.0 + k), k, 1.0);
} else {
tmp = pow(k, m) * a_m;
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (m <= -5.4e-10) tmp = Float64((k ^ m) * Float64(a_m / Float64(k * k))); elseif (m <= 5e-7) tmp = Float64(fma(Float64(a_m * m), log(k), a_m) / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64((k ^ m) * a_m); end return Float64(a_s * tmp) end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, -5.4e-10], N[(N[Power[k, m], $MachinePrecision] * N[(a$95$m / N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 5e-7], N[(N[(N[(a$95$m * m), $MachinePrecision] * N[Log[k], $MachinePrecision] + a$95$m), $MachinePrecision] / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -5.4 \cdot 10^{-10}:\\
\;\;\;\;{k}^{m} \cdot \frac{a\_m}{k \cdot k}\\
\mathbf{elif}\;m \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a\_m \cdot m, \log k, a\_m\right)}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\_m\\
\end{array}
\end{array}
if m < -5.4e-10Initial program 91.0%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6491.0
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
associate-+l+N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6491.0
Applied rewrites91.0%
Taylor expanded in k around inf
pow2N/A
lower-*.f6465.4
Applied rewrites65.4%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
associate-/l*N/A
lift-/.f64N/A
lower-*.f64N/A
lift-pow.f6460.9
Applied rewrites60.9%
if -5.4e-10 < m < 4.99999999999999977e-7Initial program 91.0%
Taylor expanded in m around 0
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6440.5
Applied rewrites40.5%
lift-fma.f64N/A
lift-*.f64N/A
lift-log.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f64N/A
lift-log.f6440.5
Applied rewrites40.5%
if 4.99999999999999977e-7 < m Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
Applied rewrites20.2%
Taylor expanded in k around 0
sqr-powN/A
unpow2N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-powN/A
lower-pow.f6482.7
Applied rewrites82.7%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
:precision binary64
(let* ((t_0 (* (pow k m) a_m)))
(*
a_s
(if (<= m -8.5e-5)
t_0
(if (<= m 5e-7)
(/ (fma (* a_m m) (log k) a_m) (fma (+ 10.0 k) k 1.0))
t_0)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double t_0 = pow(k, m) * a_m;
double tmp;
if (m <= -8.5e-5) {
tmp = t_0;
} else if (m <= 5e-7) {
tmp = fma((a_m * m), log(k), a_m) / fma((10.0 + k), k, 1.0);
} else {
tmp = t_0;
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) t_0 = Float64((k ^ m) * a_m) tmp = 0.0 if (m <= -8.5e-5) tmp = t_0; elseif (m <= 5e-7) tmp = Float64(fma(Float64(a_m * m), log(k), a_m) / fma(Float64(10.0 + k), k, 1.0)); else tmp = t_0; end return Float64(a_s * tmp) end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a$95$m), $MachinePrecision]}, N[(a$95$s * If[LessEqual[m, -8.5e-5], t$95$0, If[LessEqual[m, 5e-7], N[(N[(N[(a$95$m * m), $MachinePrecision] * N[Log[k], $MachinePrecision] + a$95$m), $MachinePrecision] / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]), $MachinePrecision]]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\_m\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -8.5 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a\_m \cdot m, \log k, a\_m\right)}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if m < -8.500000000000001e-5 or 4.99999999999999977e-7 < m Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
Applied rewrites20.2%
Taylor expanded in k around 0
sqr-powN/A
unpow2N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-powN/A
lower-pow.f6482.7
Applied rewrites82.7%
if -8.500000000000001e-5 < m < 4.99999999999999977e-7Initial program 91.0%
Taylor expanded in m around 0
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6440.5
Applied rewrites40.5%
lift-fma.f64N/A
lift-*.f64N/A
lift-log.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f64N/A
lift-log.f6440.5
Applied rewrites40.5%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
:precision binary64
(let* ((t_0 (* (pow k m) a_m)))
(*
a_s
(if (<= m -8.5e-5)
t_0
(if (<= m 4e-9) (/ a_m (fma (+ 10.0 k) k 1.0)) t_0)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double t_0 = pow(k, m) * a_m;
double tmp;
if (m <= -8.5e-5) {
tmp = t_0;
} else if (m <= 4e-9) {
tmp = a_m / fma((10.0 + k), k, 1.0);
} else {
tmp = t_0;
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) t_0 = Float64((k ^ m) * a_m) tmp = 0.0 if (m <= -8.5e-5) tmp = t_0; elseif (m <= 4e-9) tmp = Float64(a_m / fma(Float64(10.0 + k), k, 1.0)); else tmp = t_0; end return Float64(a_s * tmp) end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a$95$m), $MachinePrecision]}, N[(a$95$s * If[LessEqual[m, -8.5e-5], t$95$0, If[LessEqual[m, 4e-9], N[(a$95$m / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]), $MachinePrecision]]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\_m\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -8.5 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 4 \cdot 10^{-9}:\\
\;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if m < -8.500000000000001e-5 or 4.00000000000000025e-9 < m Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
Applied rewrites20.2%
Taylor expanded in k around 0
sqr-powN/A
unpow2N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-powN/A
lower-pow.f6482.7
Applied rewrites82.7%
if -8.500000000000001e-5 < m < 4.00000000000000025e-9Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
:precision binary64
(*
a_s
(if (<= m -0.22)
(/ a_m (* k k))
(if (<= m 1.3) (/ a_m (fma (+ 10.0 k) k 1.0)) (* (* (* k k) a_m) 99.0)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= -0.22) {
tmp = a_m / (k * k);
} else if (m <= 1.3) {
tmp = a_m / fma((10.0 + k), k, 1.0);
} else {
tmp = ((k * k) * a_m) * 99.0;
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (m <= -0.22) tmp = Float64(a_m / Float64(k * k)); elseif (m <= 1.3) tmp = Float64(a_m / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(Float64(k * k) * a_m) * 99.0); end return Float64(a_s * tmp) end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, -0.22], N[(a$95$m / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.3], N[(a$95$m / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a$95$m), $MachinePrecision] * 99.0), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -0.22:\\
\;\;\;\;\frac{a\_m}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.3:\\
\;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\_m\right) \cdot 99\\
\end{array}
\end{array}
if m < -0.220000000000000001Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around inf
pow2N/A
lower-*.f6435.9
Applied rewrites35.9%
if -0.220000000000000001 < m < 1.30000000000000004Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
if 1.30000000000000004 < m Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6427.1
Applied rewrites27.1%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6422.3
Applied rewrites22.3%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
:precision binary64
(*
a_s
(if (<= m -5.9e-18)
(/ a_m (* k k))
(if (<= m 1.3) (/ a_m (fma 10.0 k 1.0)) (* (* (* k k) a_m) 99.0)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= -5.9e-18) {
tmp = a_m / (k * k);
} else if (m <= 1.3) {
tmp = a_m / fma(10.0, k, 1.0);
} else {
tmp = ((k * k) * a_m) * 99.0;
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (m <= -5.9e-18) tmp = Float64(a_m / Float64(k * k)); elseif (m <= 1.3) tmp = Float64(a_m / fma(10.0, k, 1.0)); else tmp = Float64(Float64(Float64(k * k) * a_m) * 99.0); end return Float64(a_s * tmp) end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, -5.9e-18], N[(a$95$m / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.3], N[(a$95$m / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a$95$m), $MachinePrecision] * 99.0), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -5.9 \cdot 10^{-18}:\\
\;\;\;\;\frac{a\_m}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.3:\\
\;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\_m\right) \cdot 99\\
\end{array}
\end{array}
if m < -5.90000000000000019e-18Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around inf
pow2N/A
lower-*.f6435.9
Applied rewrites35.9%
if -5.90000000000000019e-18 < m < 1.30000000000000004Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
Applied rewrites28.3%
if 1.30000000000000004 < m Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6427.1
Applied rewrites27.1%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6422.3
Applied rewrites22.3%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
:precision binary64
(let* ((t_0 (/ a_m (* k k)))
(t_1 (/ (* a_m (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
(*
a_s
(if (<= t_1 0.0)
t_0
(if (<= t_1 1e+299)
(/ a_m 1.0)
(if (<= t_1 INFINITY) t_0 (fma (* -10.0 a_m) k a_m)))))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double t_0 = a_m / (k * k);
double t_1 = (a_m * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_1 <= 0.0) {
tmp = t_0;
} else if (t_1 <= 1e+299) {
tmp = a_m / 1.0;
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_0;
} else {
tmp = fma((-10.0 * a_m), k, a_m);
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) t_0 = Float64(a_m / Float64(k * k)) t_1 = Float64(Float64(a_m * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) tmp = 0.0 if (t_1 <= 0.0) tmp = t_0; elseif (t_1 <= 1e+299) tmp = Float64(a_m / 1.0); elseif (t_1 <= Inf) tmp = t_0; else tmp = fma(Float64(-10.0 * a_m), k, a_m); end return Float64(a_s * tmp) end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := Block[{t$95$0 = N[(a$95$m / N[(k * k), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, 1e+299], N[(a$95$m / 1.0), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$0, N[(N[(-10.0 * a$95$m), $MachinePrecision] * k + a$95$m), $MachinePrecision]]]]), $MachinePrecision]]]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
\begin{array}{l}
t_0 := \frac{a\_m}{k \cdot k}\\
t_1 := \frac{a\_m \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{+299}:\\
\;\;\;\;\frac{a\_m}{1}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-10 \cdot a\_m, k, a\_m\right)\\
\end{array}
\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.0 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 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around inf
pow2N/A
lower-*.f6435.9
Applied rewrites35.9%
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))) < 1.0000000000000001e299Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
Applied rewrites20.2%
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 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6427.1
Applied rewrites27.1%
Taylor expanded in k around 0
lower-*.f6421.0
Applied rewrites21.0%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
:precision binary64
(*
a_s
(if (<= m -5.9e-18)
(/ a_m (* k k))
(if (<= m 1.3e+31) (/ a_m (fma 10.0 k 1.0)) (fma (* -10.0 a_m) k a_m)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= -5.9e-18) {
tmp = a_m / (k * k);
} else if (m <= 1.3e+31) {
tmp = a_m / fma(10.0, k, 1.0);
} else {
tmp = fma((-10.0 * a_m), k, a_m);
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (m <= -5.9e-18) tmp = Float64(a_m / Float64(k * k)); elseif (m <= 1.3e+31) tmp = Float64(a_m / fma(10.0, k, 1.0)); else tmp = fma(Float64(-10.0 * a_m), k, a_m); end return Float64(a_s * tmp) end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, -5.9e-18], N[(a$95$m / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.3e+31], N[(a$95$m / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(-10.0 * a$95$m), $MachinePrecision] * k + a$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -5.9 \cdot 10^{-18}:\\
\;\;\;\;\frac{a\_m}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.3 \cdot 10^{+31}:\\
\;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-10 \cdot a\_m, k, a\_m\right)\\
\end{array}
\end{array}
if m < -5.90000000000000019e-18Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around inf
pow2N/A
lower-*.f6435.9
Applied rewrites35.9%
if -5.90000000000000019e-18 < m < 1.3e31Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
Applied rewrites28.3%
if 1.3e31 < m Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6427.1
Applied rewrites27.1%
Taylor expanded in k around 0
lower-*.f6421.0
Applied rewrites21.0%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
:precision binary64
(let* ((t_0 (/ a_m (* k k)))
(t_1 (/ (* a_m (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
(* a_s (if (<= t_1 0.0) t_0 (if (<= t_1 1e+299) (/ a_m 1.0) t_0)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double t_0 = a_m / (k * k);
double t_1 = (a_m * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_1 <= 0.0) {
tmp = t_0;
} else if (t_1 <= 1e+299) {
tmp = a_m / 1.0;
} else {
tmp = t_0;
}
return a_s * tmp;
}
a\_m = private
a\_s = private
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_s, a_m, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = a_m / (k * k)
t_1 = (a_m * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
if (t_1 <= 0.0d0) then
tmp = t_0
else if (t_1 <= 1d+299) then
tmp = a_m / 1.0d0
else
tmp = t_0
end if
code = a_s * tmp
end function
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
double t_0 = a_m / (k * k);
double t_1 = (a_m * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_1 <= 0.0) {
tmp = t_0;
} else if (t_1 <= 1e+299) {
tmp = a_m / 1.0;
} else {
tmp = t_0;
}
return a_s * tmp;
}
a\_m = math.fabs(a) a\_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): t_0 = a_m / (k * k) t_1 = (a_m * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k)) tmp = 0 if t_1 <= 0.0: tmp = t_0 elif t_1 <= 1e+299: tmp = a_m / 1.0 else: tmp = t_0 return a_s * tmp
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) t_0 = Float64(a_m / Float64(k * k)) t_1 = Float64(Float64(a_m * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) tmp = 0.0 if (t_1 <= 0.0) tmp = t_0; elseif (t_1 <= 1e+299) tmp = Float64(a_m / 1.0); else tmp = t_0; end return Float64(a_s * tmp) end
a\_m = abs(a); a\_s = sign(a) * abs(1.0); function tmp_2 = code(a_s, a_m, k, m) t_0 = a_m / (k * k); t_1 = (a_m * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); tmp = 0.0; if (t_1 <= 0.0) tmp = t_0; elseif (t_1 <= 1e+299) tmp = a_m / 1.0; else tmp = t_0; end tmp_2 = a_s * tmp; end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := Block[{t$95$0 = N[(a$95$m / N[(k * k), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, 1e+299], N[(a$95$m / 1.0), $MachinePrecision], t$95$0]]), $MachinePrecision]]]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
\begin{array}{l}
t_0 := \frac{a\_m}{k \cdot k}\\
t_1 := \frac{a\_m \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{+299}:\\
\;\;\;\;\frac{a\_m}{1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\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.0 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))) Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around inf
pow2N/A
lower-*.f6435.9
Applied rewrites35.9%
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))) < 1.0000000000000001e299Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
Applied rewrites20.2%
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s a_m k m) :precision binary64 (* a_s (/ a_m 1.0)))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
return a_s * (a_m / 1.0);
}
a\_m = private
a\_s = private
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_s, a_m, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a_s * (a_m / 1.0d0)
end function
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
return a_s * (a_m / 1.0);
}
a\_m = math.fabs(a) a\_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): return a_s * (a_m / 1.0)
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) return Float64(a_s * Float64(a_m / 1.0)) end
a\_m = abs(a); a\_s = sign(a) * abs(1.0); function tmp = code(a_s, a_m, k, m) tmp = a_s * (a_m / 1.0); end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * N[(a$95$m / 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \frac{a\_m}{1}
\end{array}
Initial program 91.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.0
Applied rewrites45.0%
Taylor expanded in k around 0
Applied rewrites20.2%
herbie shell --seed 2025139
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))