
(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]
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
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]
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
(FPCore (a k m) :precision binary64 (let* ((t_0 (* a (pow k m))) (t_1 (/ t_0 (+ (+ 1.0 (* 10.0 k)) (* k k))))) (if (<= t_1 5e+293) t_1 t_0)))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double t_1 = t_0 / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_1 <= 5e+293) {
tmp = t_1;
} else {
tmp = t_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) :: t_1
real(8) :: tmp
t_0 = a * (k ** m)
t_1 = t_0 / ((1.0d0 + (10.0d0 * k)) + (k * k))
if (t_1 <= 5d+293) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double t_0 = a * Math.pow(k, m);
double t_1 = t_0 / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_1 <= 5e+293) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a * math.pow(k, m) t_1 = t_0 / ((1.0 + (10.0 * k)) + (k * k)) tmp = 0 if t_1 <= 5e+293: tmp = t_1 else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a * (k ^ m)) t_1 = Float64(t_0 / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) tmp = 0.0 if (t_1 <= 5e+293) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a * (k ^ m); t_1 = t_0 / ((1.0 + (10.0 * k)) + (k * k)); tmp = 0.0; if (t_1 <= 5e+293) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+293], t$95$1, t$95$0]]]
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
t_1 := \frac{t\_0}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+293}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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.0000000000000003e293Initial program 90.6%
if 5.0000000000000003e293 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 90.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.7%
Taylor expanded in k around 0
Applied rewrites80.3%
Taylor expanded in k around 0
Applied rewrites82.9%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.9%
Applied rewrites82.9%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* a (pow k m))))
(if (<= (/ t_0 (+ (+ 1.0 (* 10.0 k)) (* k k))) 5e+293)
(* (/ (pow k m) (fma (- k -10.0) k 1.0)) a)
t_0)))double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double tmp;
if ((t_0 / ((1.0 + (10.0 * k)) + (k * k))) <= 5e+293) {
tmp = (pow(k, m) / fma((k - -10.0), k, 1.0)) * a;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64(a * (k ^ m)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) <= 5e+293) tmp = Float64(Float64((k ^ m) / fma(Float64(k - -10.0), k, 1.0)) * a); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+293], N[(N[(N[Power[k, m], $MachinePrecision] / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], t$95$0]]
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;\frac{t\_0}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq 5 \cdot 10^{+293}:\\
\;\;\;\;\frac{{k}^{m}}{\mathsf{fma}\left(k - -10, k, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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.0000000000000003e293Initial program 90.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.7%
if 5.0000000000000003e293 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 90.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.7%
Taylor expanded in k around 0
Applied rewrites80.3%
Taylor expanded in k around 0
Applied rewrites82.9%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.9%
Applied rewrites82.9%
(FPCore (a k m) :precision binary64 (let* ((t_0 (* a (pow k m)))) (if (<= m 1.4) (/ t_0 (+ 1.0 (* k k))) t_0)))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double tmp;
if (m <= 1.4) {
tmp = t_0 / (1.0 + (k * k));
} else {
tmp = t_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 ** m)
if (m <= 1.4d0) then
tmp = t_0 / (1.0d0 + (k * k))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double t_0 = a * Math.pow(k, m);
double tmp;
if (m <= 1.4) {
tmp = t_0 / (1.0 + (k * k));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a * math.pow(k, m) tmp = 0 if m <= 1.4: tmp = t_0 / (1.0 + (k * k)) else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a * (k ^ m)) tmp = 0.0 if (m <= 1.4) tmp = Float64(t_0 / Float64(1.0 + Float64(k * k))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a * (k ^ m); tmp = 0.0; if (m <= 1.4) tmp = t_0 / (1.0 + (k * k)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, 1.4], N[(t$95$0 / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;m \leq 1.4:\\
\;\;\;\;\frac{t\_0}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if m < 1.3999999999999999Initial program 90.6%
Taylor expanded in k around 0
Applied rewrites89.8%
if 1.3999999999999999 < m Initial program 90.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.7%
Taylor expanded in k around 0
Applied rewrites80.3%
Taylor expanded in k around 0
Applied rewrites82.9%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.9%
Applied rewrites82.9%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* a (pow k m))))
(if (<= m -2.6e-8)
t_0
(if (<= m 3.4e-9) (/ a (fma (- k -10.0) k 1.0)) t_0))))double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double tmp;
if (m <= -2.6e-8) {
tmp = t_0;
} else if (m <= 3.4e-9) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64(a * (k ^ m)) tmp = 0.0 if (m <= -2.6e-8) tmp = t_0; elseif (m <= 3.4e-9) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -2.6e-8], t$95$0, If[LessEqual[m, 3.4e-9], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;m \leq -2.6 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 3.4 \cdot 10^{-9}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if m < -2.6000000000000001e-8 or 3.3999999999999998e-9 < m Initial program 90.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.7%
Taylor expanded in k around 0
Applied rewrites80.3%
Taylor expanded in k around 0
Applied rewrites82.9%
Taylor expanded in k around 0
lower-*.f64N/A
lower-pow.f6482.9%
Applied rewrites82.9%
if -2.6000000000000001e-8 < m < 3.3999999999999998e-9Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f6444.3%
Applied rewrites44.3%
(FPCore (a k m) :precision binary64 (if (<= m -20000000000.0) (/ a (sqrt (* (* k k) (* k k)))) (/ a (fma (- k -10.0) k 1.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -20000000000.0) {
tmp = a / sqrt(((k * k) * (k * k)));
} else {
tmp = a / fma((k - -10.0), k, 1.0);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -20000000000.0) tmp = Float64(a / sqrt(Float64(Float64(k * k) * Float64(k * k)))); else tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -20000000000.0], N[(a / N[Sqrt[N[(N[(k * k), $MachinePrecision] * N[(k * k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;m \leq -20000000000:\\
\;\;\;\;\frac{a}{\sqrt{\left(k \cdot k\right) \cdot \left(k \cdot k\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\end{array}
if m < -2e10Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-pow.f64N/A
pow2N/A
fabs-sqrN/A
lift-*.f64N/A
neg-fabsN/A
rem-sqrt-square-revN/A
lower-*.f32N/A
lower-unsound-*.f32N/A
lower-sqrt.f64N/A
lower-unsound-*.f32N/A
lower-*.f32N/A
sqr-neg-revN/A
lower-*.f6438.0%
Applied rewrites38.0%
if -2e10 < m Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f6444.3%
Applied rewrites44.3%
(FPCore (a k m) :precision binary64 (if (<= m -33000000000.0) (/ 1.0 (/ (* k k) a)) (/ a (fma (- k -10.0) k 1.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -33000000000.0) {
tmp = 1.0 / ((k * k) / a);
} else {
tmp = a / fma((k - -10.0), k, 1.0);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -33000000000.0) tmp = Float64(1.0 / Float64(Float64(k * k) / a)); else tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -33000000000.0], N[(1.0 / N[(N[(k * k), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;m \leq -33000000000:\\
\;\;\;\;\frac{1}{\frac{k \cdot k}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\end{array}
if m < -3.3e10Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6435.8%
Applied rewrites35.8%
if -3.3e10 < m Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f6444.3%
Applied rewrites44.3%
(FPCore (a k m) :precision binary64 (if (<= k 3.5e-307) (/ 1.0 (/ (* k k) a)) (if (<= k 2.15e-5) (fma (* a -10.0) k a) (/ (* (/ 1.0 k) a) k))))
double code(double a, double k, double m) {
double tmp;
if (k <= 3.5e-307) {
tmp = 1.0 / ((k * k) / a);
} else if (k <= 2.15e-5) {
tmp = fma((a * -10.0), k, a);
} else {
tmp = ((1.0 / k) * a) / k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (k <= 3.5e-307) tmp = Float64(1.0 / Float64(Float64(k * k) / a)); elseif (k <= 2.15e-5) tmp = fma(Float64(a * -10.0), k, a); else tmp = Float64(Float64(Float64(1.0 / k) * a) / k); end return tmp end
code[a_, k_, m_] := If[LessEqual[k, 3.5e-307], N[(1.0 / N[(N[(k * k), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 2.15e-5], N[(N[(a * -10.0), $MachinePrecision] * k + a), $MachinePrecision], N[(N[(N[(1.0 / k), $MachinePrecision] * a), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;k \leq 3.5 \cdot 10^{-307}:\\
\;\;\;\;\frac{1}{\frac{k \cdot k}{a}}\\
\mathbf{elif}\;k \leq 2.15 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot -10, k, a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{k} \cdot a}{k}\\
\end{array}
if k < 3.5000000000000002e-307Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6435.8%
Applied rewrites35.8%
if 3.5000000000000002e-307 < k < 2.1500000000000001e-5Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around 0
Applied rewrites19.8%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7%
Applied rewrites20.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6420.7%
Applied rewrites20.7%
if 2.1500000000000001e-5 < k Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
mult-flipN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
(FPCore (a k m) :precision binary64 (if (<= k 3.5e-307) (/ 1.0 (/ (* k k) a)) (if (<= k 2.15e-5) (fma (* a -10.0) k a) (* (/ a k) (/ 1.0 k)))))
double code(double a, double k, double m) {
double tmp;
if (k <= 3.5e-307) {
tmp = 1.0 / ((k * k) / a);
} else if (k <= 2.15e-5) {
tmp = fma((a * -10.0), k, a);
} else {
tmp = (a / k) * (1.0 / k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (k <= 3.5e-307) tmp = Float64(1.0 / Float64(Float64(k * k) / a)); elseif (k <= 2.15e-5) tmp = fma(Float64(a * -10.0), k, a); else tmp = Float64(Float64(a / k) * Float64(1.0 / k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[k, 3.5e-307], N[(1.0 / N[(N[(k * k), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 2.15e-5], N[(N[(a * -10.0), $MachinePrecision] * k + a), $MachinePrecision], N[(N[(a / k), $MachinePrecision] * N[(1.0 / k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;k \leq 3.5 \cdot 10^{-307}:\\
\;\;\;\;\frac{1}{\frac{k \cdot k}{a}}\\
\mathbf{elif}\;k \leq 2.15 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot -10, k, a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{k} \cdot \frac{1}{k}\\
\end{array}
if k < 3.5000000000000002e-307Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6435.8%
Applied rewrites35.8%
if 3.5000000000000002e-307 < k < 2.1500000000000001e-5Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around 0
Applied rewrites19.8%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7%
Applied rewrites20.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6420.7%
Applied rewrites20.7%
if 2.1500000000000001e-5 < k Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
*-rgt-identityN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
(FPCore (a k m) :precision binary64 (if (<= k 3.5e-307) (/ a (* k k)) (if (<= k 2.15e-5) (fma (* a -10.0) k a) (* (/ a k) (/ 1.0 k)))))
double code(double a, double k, double m) {
double tmp;
if (k <= 3.5e-307) {
tmp = a / (k * k);
} else if (k <= 2.15e-5) {
tmp = fma((a * -10.0), k, a);
} else {
tmp = (a / k) * (1.0 / k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (k <= 3.5e-307) tmp = Float64(a / Float64(k * k)); elseif (k <= 2.15e-5) tmp = fma(Float64(a * -10.0), k, a); else tmp = Float64(Float64(a / k) * Float64(1.0 / k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[k, 3.5e-307], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 2.15e-5], N[(N[(a * -10.0), $MachinePrecision] * k + a), $MachinePrecision], N[(N[(a / k), $MachinePrecision] * N[(1.0 / k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;k \leq 3.5 \cdot 10^{-307}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 2.15 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot -10, k, a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{k} \cdot \frac{1}{k}\\
\end{array}
if k < 3.5000000000000002e-307Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-pow.f64N/A
pow2N/A
lift-*.f6435.8%
Applied rewrites35.8%
if 3.5000000000000002e-307 < k < 2.1500000000000001e-5Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around 0
Applied rewrites19.8%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7%
Applied rewrites20.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6420.7%
Applied rewrites20.7%
if 2.1500000000000001e-5 < k Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
*-rgt-identityN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
(FPCore (a k m) :precision binary64 (if (<= k 3.5e-307) (/ a (* k k)) (if (<= k 2.15e-5) (fma (* a -10.0) k a) (/ (/ a k) k))))
double code(double a, double k, double m) {
double tmp;
if (k <= 3.5e-307) {
tmp = a / (k * k);
} else if (k <= 2.15e-5) {
tmp = fma((a * -10.0), k, a);
} else {
tmp = (a / k) / k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (k <= 3.5e-307) tmp = Float64(a / Float64(k * k)); elseif (k <= 2.15e-5) tmp = fma(Float64(a * -10.0), k, a); else tmp = Float64(Float64(a / k) / k); end return tmp end
code[a_, k_, m_] := If[LessEqual[k, 3.5e-307], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 2.15e-5], N[(N[(a * -10.0), $MachinePrecision] * k + a), $MachinePrecision], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;k \leq 3.5 \cdot 10^{-307}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 2.15 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot -10, k, a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\end{array}
if k < 3.5000000000000002e-307Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-pow.f64N/A
pow2N/A
lift-*.f6435.8%
Applied rewrites35.8%
if 3.5000000000000002e-307 < k < 2.1500000000000001e-5Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around 0
Applied rewrites19.8%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7%
Applied rewrites20.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6420.7%
Applied rewrites20.7%
if 2.1500000000000001e-5 < k Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
(FPCore (a k m) :precision binary64 (if (<= k 3.5e-307) (/ a (* k k)) (if (<= k 2.15e-5) (* (fma -10.0 k 1.0) a) (/ (/ a k) k))))
double code(double a, double k, double m) {
double tmp;
if (k <= 3.5e-307) {
tmp = a / (k * k);
} else if (k <= 2.15e-5) {
tmp = fma(-10.0, k, 1.0) * a;
} else {
tmp = (a / k) / k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (k <= 3.5e-307) tmp = Float64(a / Float64(k * k)); elseif (k <= 2.15e-5) tmp = Float64(fma(-10.0, k, 1.0) * a); else tmp = Float64(Float64(a / k) / k); end return tmp end
code[a_, k_, m_] := If[LessEqual[k, 3.5e-307], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 2.15e-5], N[(N[(-10.0 * k + 1.0), $MachinePrecision] * a), $MachinePrecision], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;k \leq 3.5 \cdot 10^{-307}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 2.15 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(-10, k, 1\right) \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\end{array}
if k < 3.5000000000000002e-307Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-pow.f64N/A
pow2N/A
lift-*.f6435.8%
Applied rewrites35.8%
if 3.5000000000000002e-307 < k < 2.1500000000000001e-5Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around 0
Applied rewrites19.8%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.7%
Applied rewrites20.7%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt1-inN/A
lower-*.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
lower-fma.f6420.7%
Applied rewrites20.7%
if 2.1500000000000001e-5 < k Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
(FPCore (a k m) :precision binary64 (if (<= k 3.5e-307) (/ a (* k k)) (if (<= k 6e+21) (/ a 1.0) (/ (/ a k) k))))
double code(double a, double k, double m) {
double tmp;
if (k <= 3.5e-307) {
tmp = a / (k * k);
} else if (k <= 6e+21) {
tmp = a / 1.0;
} else {
tmp = (a / k) / 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 (k <= 3.5d-307) then
tmp = a / (k * k)
else if (k <= 6d+21) then
tmp = a / 1.0d0
else
tmp = (a / k) / k
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (k <= 3.5e-307) {
tmp = a / (k * k);
} else if (k <= 6e+21) {
tmp = a / 1.0;
} else {
tmp = (a / k) / k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= 3.5e-307: tmp = a / (k * k) elif k <= 6e+21: tmp = a / 1.0 else: tmp = (a / k) / k return tmp
function code(a, k, m) tmp = 0.0 if (k <= 3.5e-307) tmp = Float64(a / Float64(k * k)); elseif (k <= 6e+21) tmp = Float64(a / 1.0); else tmp = Float64(Float64(a / k) / k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= 3.5e-307) tmp = a / (k * k); elseif (k <= 6e+21) tmp = a / 1.0; else tmp = (a / k) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, 3.5e-307], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 6e+21], N[(a / 1.0), $MachinePrecision], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;k \leq 3.5 \cdot 10^{-307}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 6 \cdot 10^{+21}:\\
\;\;\;\;\frac{a}{1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\end{array}
if k < 3.5000000000000002e-307Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-pow.f64N/A
pow2N/A
lift-*.f6435.8%
Applied rewrites35.8%
if 3.5000000000000002e-307 < k < 6e21Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around 0
Applied rewrites19.8%
if 6e21 < k Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6434.3%
Applied rewrites34.3%
(FPCore (a k m) :precision binary64 (let* ((t_0 (/ a (* k k)))) (if (<= k 3.5e-307) t_0 (if (<= k 6e+21) (/ a 1.0) t_0))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double tmp;
if (k <= 3.5e-307) {
tmp = t_0;
} else if (k <= 6e+21) {
tmp = a / 1.0;
} else {
tmp = t_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 (k <= 3.5d-307) then
tmp = t_0
else if (k <= 6d+21) then
tmp = a / 1.0d0
else
tmp = t_0
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 (k <= 3.5e-307) {
tmp = t_0;
} else if (k <= 6e+21) {
tmp = a / 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a / (k * k) tmp = 0 if k <= 3.5e-307: tmp = t_0 elif k <= 6e+21: tmp = a / 1.0 else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) tmp = 0.0 if (k <= 3.5e-307) tmp = t_0; elseif (k <= 6e+21) tmp = Float64(a / 1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a / (k * k); tmp = 0.0; if (k <= 3.5e-307) tmp = t_0; elseif (k <= 6e+21) tmp = a / 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k, 3.5e-307], t$95$0, If[LessEqual[k, 6e+21], N[(a / 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
\mathbf{if}\;k \leq 3.5 \cdot 10^{-307}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;k \leq 6 \cdot 10^{+21}:\\
\;\;\;\;\frac{a}{1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if k < 3.5000000000000002e-307 or 6e21 < k Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around inf
lower-/.f64N/A
lower-pow.f6435.8%
Applied rewrites35.8%
lift-pow.f64N/A
pow2N/A
lift-*.f6435.8%
Applied rewrites35.8%
if 3.5000000000000002e-307 < k < 6e21Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around 0
Applied rewrites19.8%
(FPCore (a k m) :precision binary64 (/ a 1.0))
double code(double a, double k, double m) {
return a / 1.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 / 1.0d0
end function
public static double code(double a, double k, double m) {
return a / 1.0;
}
def code(a, k, m): return a / 1.0
function code(a, k, m) return Float64(a / 1.0) end
function tmp = code(a, k, m) tmp = a / 1.0; end
code[a_, k_, m_] := N[(a / 1.0), $MachinePrecision]
\frac{a}{1}
Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.3%
Applied rewrites44.3%
Taylor expanded in k around 0
Applied rewrites19.8%
herbie shell --seed 2025207
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))