
(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 12 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 2.2e-9) (* a (/ (pow k m) (+ (* (+ 10.0 k) k) 1.0))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 2.2e-9) {
tmp = a * (pow(k, m) / (((10.0 + k) * k) + 1.0));
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 2.2d-9) then
tmp = a * ((k ** m) / (((10.0d0 + k) * k) + 1.0d0))
else
tmp = (k ** m) * a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 2.2e-9) {
tmp = a * (Math.pow(k, m) / (((10.0 + k) * k) + 1.0));
} else {
tmp = Math.pow(k, m) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 2.2e-9: tmp = a * (math.pow(k, m) / (((10.0 + k) * k) + 1.0)) else: tmp = math.pow(k, m) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 2.2e-9) tmp = Float64(a * Float64((k ^ m) / Float64(Float64(Float64(10.0 + k) * k) + 1.0))); else tmp = Float64((k ^ m) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 2.2e-9) tmp = a * ((k ^ m) / (((10.0 + k) * k) + 1.0)); else tmp = (k ^ m) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 2.2e-9], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(N[(N[(10.0 + k), $MachinePrecision] * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.2 \cdot 10^{-9}:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{\left(10 + k\right) \cdot k + 1}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 2.1999999999999998e-9Initial program 99.4%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
pow2N/A
associate-+r+N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6499.4
Applied rewrites99.4%
if 2.1999999999999998e-9 < m Initial program 75.3%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m)
:precision binary64
(if (<= m -2e-17)
(/ (* a (pow k m)) (+ (* 10.0 k) 1.0))
(if (<= m 2e-9)
(/ a (+ (* (* (+ (/ 10.0 k) 1.0) k) k) 1.0))
(* (pow k m) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -2e-17) {
tmp = (a * pow(k, m)) / ((10.0 * k) + 1.0);
} else if (m <= 2e-9) {
tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= (-2d-17)) then
tmp = (a * (k ** m)) / ((10.0d0 * k) + 1.0d0)
else if (m <= 2d-9) then
tmp = a / (((((10.0d0 / k) + 1.0d0) * k) * k) + 1.0d0)
else
tmp = (k ** m) * a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -2e-17) {
tmp = (a * Math.pow(k, m)) / ((10.0 * k) + 1.0);
} else if (m <= 2e-9) {
tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
} else {
tmp = Math.pow(k, m) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -2e-17: tmp = (a * math.pow(k, m)) / ((10.0 * k) + 1.0) elif m <= 2e-9: tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0) else: tmp = math.pow(k, m) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= -2e-17) tmp = Float64(Float64(a * (k ^ m)) / Float64(Float64(10.0 * k) + 1.0)); elseif (m <= 2e-9) tmp = Float64(a / Float64(Float64(Float64(Float64(Float64(10.0 / k) + 1.0) * k) * k) + 1.0)); else tmp = Float64((k ^ m) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -2e-17) tmp = (a * (k ^ m)) / ((10.0 * k) + 1.0); elseif (m <= 2e-9) tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0); else tmp = (k ^ m) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -2e-17], N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(10.0 * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 2e-9], N[(a / N[(N[(N[(N[(N[(10.0 / k), $MachinePrecision] + 1.0), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2 \cdot 10^{-17}:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{10 \cdot k + 1}\\
\mathbf{elif}\;m \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < -2.00000000000000014e-17Initial program 100.0%
Taylor expanded in k around 0
+-commutativeN/A
lower-+.f64N/A
lift-*.f64100.0
Applied rewrites100.0%
if -2.00000000000000014e-17 < m < 2.00000000000000012e-9Initial program 98.6%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6497.5
Applied rewrites97.5%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6497.5
Applied rewrites97.5%
if 2.00000000000000012e-9 < m Initial program 75.3%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (or (<= m -1.05e-6) (not (<= m 2e-9))) (* (pow k m) a) (/ a (+ (* (* (+ (/ 10.0 k) 1.0) k) k) 1.0))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -1.05e-6) || !(m <= 2e-9)) {
tmp = pow(k, m) * a;
} else {
tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.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.05d-6)) .or. (.not. (m <= 2d-9))) then
tmp = (k ** m) * a
else
tmp = a / (((((10.0d0 / k) + 1.0d0) * k) * k) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if ((m <= -1.05e-6) || !(m <= 2e-9)) {
tmp = Math.pow(k, m) * a;
} else {
tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
}
return tmp;
}
def code(a, k, m): tmp = 0 if (m <= -1.05e-6) or not (m <= 2e-9): tmp = math.pow(k, m) * a else: tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0) return tmp
function code(a, k, m) tmp = 0.0 if ((m <= -1.05e-6) || !(m <= 2e-9)) tmp = Float64((k ^ m) * a); else tmp = Float64(a / Float64(Float64(Float64(Float64(Float64(10.0 / k) + 1.0) * k) * k) + 1.0)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((m <= -1.05e-6) || ~((m <= 2e-9))) tmp = (k ^ m) * a; else tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0); end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[m, -1.05e-6], N[Not[LessEqual[m, 2e-9]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision], N[(a / N[(N[(N[(N[(N[(10.0 / k), $MachinePrecision] + 1.0), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.05 \cdot 10^{-6} \lor \neg \left(m \leq 2 \cdot 10^{-9}\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\
\end{array}
\end{array}
if m < -1.0499999999999999e-6 or 2.00000000000000012e-9 < m Initial program 87.9%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
if -1.0499999999999999e-6 < m < 2.00000000000000012e-9Initial program 98.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6497.0
Applied rewrites97.0%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6497.0
Applied rewrites97.0%
Final simplification99.0%
(FPCore (a k m)
:precision binary64
(if (<= m -0.27)
(/ (+ (/ (- (* 99.0 (/ a k)) (* 10.0 a)) k) a) (* k k))
(if (<= m 1.2)
(/ a (+ (* (* (+ (/ 10.0 k) 1.0) k) k) 1.0))
(* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.27) {
tmp = ((((99.0 * (a / k)) - (10.0 * a)) / k) + a) / (k * k);
} else if (m <= 1.2) {
tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
} else {
tmp = ((k * k) * a) * 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 <= (-0.27d0)) then
tmp = ((((99.0d0 * (a / k)) - (10.0d0 * a)) / k) + a) / (k * k)
else if (m <= 1.2d0) then
tmp = a / (((((10.0d0 / k) + 1.0d0) * k) * k) + 1.0d0)
else
tmp = ((k * k) * a) * 99.0d0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -0.27) {
tmp = ((((99.0 * (a / k)) - (10.0 * a)) / k) + a) / (k * k);
} else if (m <= 1.2) {
tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.27: tmp = ((((99.0 * (a / k)) - (10.0 * a)) / k) + a) / (k * k) elif m <= 1.2: tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0) else: tmp = ((k * k) * a) * 99.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.27) tmp = Float64(Float64(Float64(Float64(Float64(99.0 * Float64(a / k)) - Float64(10.0 * a)) / k) + a) / Float64(k * k)); elseif (m <= 1.2) tmp = Float64(a / Float64(Float64(Float64(Float64(Float64(10.0 / k) + 1.0) * k) * k) + 1.0)); else tmp = Float64(Float64(Float64(k * k) * a) * 99.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -0.27) tmp = ((((99.0 * (a / k)) - (10.0 * a)) / k) + a) / (k * k); elseif (m <= 1.2) tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0); else tmp = ((k * k) * a) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.27], N[(N[(N[(N[(N[(99.0 * N[(a / k), $MachinePrecision]), $MachinePrecision] - N[(10.0 * a), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision] + a), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(N[(N[(N[(N[(10.0 / k), $MachinePrecision] + 1.0), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.27:\\
\;\;\;\;\frac{\frac{99 \cdot \frac{a}{k} - 10 \cdot a}{k} + a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.2:\\
\;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -0.27000000000000002Initial program 100.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6438.7
Applied rewrites38.7%
Taylor expanded in k around -inf
lower-/.f64N/A
Applied rewrites48.6%
Taylor expanded in k around inf
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
lower--.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lower-*.f6471.6
Applied rewrites71.6%
if -0.27000000000000002 < m < 1.19999999999999996Initial program 98.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6495.4
Applied rewrites95.4%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6495.4
Applied rewrites95.4%
if 1.19999999999999996 < m Initial program 75.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites3.8%
Taylor expanded in k around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6428.3
Applied rewrites28.3%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6464.7
Applied rewrites64.7%
(FPCore (a k m)
:precision binary64
(if (<= m -0.27)
(/ a (* k k))
(if (<= m 1.2)
(/ a (+ (* (* (+ (/ 10.0 k) 1.0) k) k) 1.0))
(* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.27) {
tmp = a / (k * k);
} else if (m <= 1.2) {
tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
} else {
tmp = ((k * k) * a) * 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 <= (-0.27d0)) then
tmp = a / (k * k)
else if (m <= 1.2d0) then
tmp = a / (((((10.0d0 / k) + 1.0d0) * k) * k) + 1.0d0)
else
tmp = ((k * k) * a) * 99.0d0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -0.27) {
tmp = a / (k * k);
} else if (m <= 1.2) {
tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.27: tmp = a / (k * k) elif m <= 1.2: tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0) else: tmp = ((k * k) * a) * 99.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.27) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.2) tmp = Float64(a / Float64(Float64(Float64(Float64(Float64(10.0 / k) + 1.0) * k) * k) + 1.0)); else tmp = Float64(Float64(Float64(k * k) * a) * 99.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -0.27) tmp = a / (k * k); elseif (m <= 1.2) tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0); else tmp = ((k * k) * a) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.27], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(N[(N[(N[(N[(10.0 / k), $MachinePrecision] + 1.0), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.27:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.2:\\
\;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -0.27000000000000002Initial program 100.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites65.1%
if -0.27000000000000002 < m < 1.19999999999999996Initial program 98.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6495.4
Applied rewrites95.4%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6495.4
Applied rewrites95.4%
if 1.19999999999999996 < m Initial program 75.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites3.8%
Taylor expanded in k around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6428.3
Applied rewrites28.3%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6464.7
Applied rewrites64.7%
(FPCore (a k m) :precision binary64 (if (<= m -0.27) (/ a (* k k)) (if (<= m 1.2) (/ a (+ (* (+ 10.0 k) k) 1.0)) (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.27) {
tmp = a / (k * k);
} else if (m <= 1.2) {
tmp = a / (((10.0 + k) * k) + 1.0);
} else {
tmp = ((k * k) * a) * 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 <= (-0.27d0)) then
tmp = a / (k * k)
else if (m <= 1.2d0) then
tmp = a / (((10.0d0 + k) * k) + 1.0d0)
else
tmp = ((k * k) * a) * 99.0d0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -0.27) {
tmp = a / (k * k);
} else if (m <= 1.2) {
tmp = a / (((10.0 + k) * k) + 1.0);
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.27: tmp = a / (k * k) elif m <= 1.2: tmp = a / (((10.0 + k) * k) + 1.0) else: tmp = ((k * k) * a) * 99.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.27) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.2) tmp = Float64(a / Float64(Float64(Float64(10.0 + k) * k) + 1.0)); else tmp = Float64(Float64(Float64(k * k) * a) * 99.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -0.27) tmp = a / (k * k); elseif (m <= 1.2) tmp = a / (((10.0 + k) * k) + 1.0); else tmp = ((k * k) * a) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.27], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(N[(N[(10.0 + k), $MachinePrecision] * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.27:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.2:\\
\;\;\;\;\frac{a}{\left(10 + k\right) \cdot k + 1}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -0.27000000000000002Initial program 100.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites65.1%
if -0.27000000000000002 < m < 1.19999999999999996Initial program 98.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6495.4
Applied rewrites95.4%
if 1.19999999999999996 < m Initial program 75.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites3.8%
Taylor expanded in k around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6428.3
Applied rewrites28.3%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6464.7
Applied rewrites64.7%
(FPCore (a k m) :precision binary64 (if (<= m -0.27) (/ a (* k k)) (if (<= m 1.2) (/ a (+ (* k k) 1.0)) (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.27) {
tmp = a / (k * k);
} else if (m <= 1.2) {
tmp = a / ((k * k) + 1.0);
} else {
tmp = ((k * k) * a) * 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 <= (-0.27d0)) then
tmp = a / (k * k)
else if (m <= 1.2d0) then
tmp = a / ((k * k) + 1.0d0)
else
tmp = ((k * k) * a) * 99.0d0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -0.27) {
tmp = a / (k * k);
} else if (m <= 1.2) {
tmp = a / ((k * k) + 1.0);
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.27: tmp = a / (k * k) elif m <= 1.2: tmp = a / ((k * k) + 1.0) else: tmp = ((k * k) * a) * 99.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.27) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.2) tmp = Float64(a / Float64(Float64(k * k) + 1.0)); else tmp = Float64(Float64(Float64(k * k) * a) * 99.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -0.27) tmp = a / (k * k); elseif (m <= 1.2) tmp = a / ((k * k) + 1.0); else tmp = ((k * k) * a) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.27], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(N[(k * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.27:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.2:\\
\;\;\;\;\frac{a}{k \cdot k + 1}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -0.27000000000000002Initial program 100.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites65.1%
if -0.27000000000000002 < m < 1.19999999999999996Initial program 98.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6495.4
Applied rewrites95.4%
Taylor expanded in k around inf
Applied rewrites90.2%
if 1.19999999999999996 < m Initial program 75.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites3.8%
Taylor expanded in k around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6428.3
Applied rewrites28.3%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6464.7
Applied rewrites64.7%
(FPCore (a k m)
:precision binary64
(if (<= m -6.8e-12)
(/ a (* k k))
(if (<= m 0.48)
(* a (ratio-square-sum 1.0 (* (+ 10.0 k) k)))
(* (* (* k k) a) 99.0))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -6.8 \cdot 10^{-12}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.48:\\
\;\;\;\;a \cdot \mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot k\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -6.8000000000000001e-12Initial program 100.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f6499.0
Applied rewrites99.0%
Taylor expanded in m around 0
Applied rewrites64.8%
if -6.8000000000000001e-12 < m < 0.47999999999999998Initial program 98.7%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
pow2N/A
associate-+r+N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6498.7
Applied rewrites98.7%
Taylor expanded in m around 0
metadata-evalN/A
lower-ratio-square-sum.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-+.f6480.5
Applied rewrites80.5%
if 0.47999999999999998 < m Initial program 75.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites3.8%
Taylor expanded in k around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6428.3
Applied rewrites28.3%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6464.7
Applied rewrites64.7%
(FPCore (a k m) :precision binary64 (if (<= m 0.48) (* a (ratio-square-sum 1.0 (* (+ 10.0 k) k))) (* (* (* k k) a) 99.0)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.48:\\
\;\;\;\;a \cdot \mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot k\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < 0.47999999999999998Initial program 99.4%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
pow2N/A
associate-+r+N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6499.4
Applied rewrites99.4%
Taylor expanded in m around 0
metadata-evalN/A
lower-ratio-square-sum.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-+.f6443.7
Applied rewrites43.7%
if 0.47999999999999998 < m Initial program 75.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites3.8%
Taylor expanded in k around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6428.3
Applied rewrites28.3%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6464.7
Applied rewrites64.7%
(FPCore (a k m) :precision binary64 (if (<= m 0.4) a (* (* (* k k) a) 99.0)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.4) {
tmp = a;
} else {
tmp = ((k * k) * a) * 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 <= 0.4d0) then
tmp = a
else
tmp = ((k * k) * a) * 99.0d0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 0.4) {
tmp = a;
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.4: tmp = a else: tmp = ((k * k) * a) * 99.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.4) tmp = a; else tmp = Float64(Float64(Float64(k * k) * a) * 99.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 0.4) tmp = a; else tmp = ((k * k) * a) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.4], a, N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.4:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < 0.40000000000000002Initial program 99.4%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6466.4
Applied rewrites66.4%
Taylor expanded in k around 0
Applied rewrites28.0%
if 0.40000000000000002 < m Initial program 75.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites3.8%
Taylor expanded in k around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6428.3
Applied rewrites28.3%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6464.7
Applied rewrites64.7%
(FPCore (a k m) :precision binary64 (if (<= m 0.4) a (* (* k a) -10.0)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.4) {
tmp = a;
} else {
tmp = (k * a) * -10.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 <= 0.4d0) then
tmp = a
else
tmp = (k * a) * (-10.0d0)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 0.4) {
tmp = a;
} else {
tmp = (k * a) * -10.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.4: tmp = a else: tmp = (k * a) * -10.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.4) tmp = a; else tmp = Float64(Float64(k * a) * -10.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 0.4) tmp = a; else tmp = (k * a) * -10.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.4], a, N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.4:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\end{array}
\end{array}
if m < 0.40000000000000002Initial program 99.4%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6466.4
Applied rewrites66.4%
Taylor expanded in k around 0
Applied rewrites28.0%
if 0.40000000000000002 < m Initial program 75.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f646.3
Applied rewrites6.3%
Taylor expanded in k around inf
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6417.1
Applied rewrites17.1%
(FPCore (a k m) :precision binary64 a)
double code(double a, double k, double m) {
return a;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a
end function
public static double code(double a, double k, double m) {
return a;
}
def code(a, k, m): return a
function code(a, k, m) return a end
function tmp = code(a, k, m) tmp = a; end
code[a_, k_, m_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 91.4%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6445.6
Applied rewrites45.6%
Taylor expanded in k around 0
Applied rewrites20.0%
herbie shell --seed 2025058
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))