
(FPCore (x y z t a b) :precision binary64 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b);
}
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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (((x + y) + z) - (z * log(t))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return (((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\end{array}
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b);
}
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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (((x + y) + z) - (z * log(t))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return (((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (fma (- a 0.5) b (- (+ (+ y x) z) (* (log t) z))))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, (((y + x) + z) - (log(t) * z)));
}
function code(x, y, z, t, a, b) return fma(Float64(a - 0.5), b, Float64(Float64(Float64(y + x) + z) - Float64(log(t) * z))) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + N[(N[(N[(y + x), $MachinePrecision] + z), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, \left(\left(y + x\right) + z\right) - \log t \cdot z\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b))))
(if (<= t_1 -1e+306)
(* b a)
(if (<= t_1 -2e-30) x (if (<= t_1 5e+307) y (* b a))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b);
double tmp;
if (t_1 <= -1e+306) {
tmp = b * a;
} else if (t_1 <= -2e-30) {
tmp = x;
} else if (t_1 <= 5e+307) {
tmp = y;
} else {
tmp = b * 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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: tmp
t_1 = (((x + y) + z) - (z * log(t))) + ((a - 0.5d0) * b)
if (t_1 <= (-1d+306)) then
tmp = b * a
else if (t_1 <= (-2d-30)) then
tmp = x
else if (t_1 <= 5d+307) then
tmp = y
else
tmp = b * a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b);
double tmp;
if (t_1 <= -1e+306) {
tmp = b * a;
} else if (t_1 <= -2e-30) {
tmp = x;
} else if (t_1 <= 5e+307) {
tmp = y;
} else {
tmp = b * a;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b) tmp = 0 if t_1 <= -1e+306: tmp = b * a elif t_1 <= -2e-30: tmp = x elif t_1 <= 5e+307: tmp = y else: tmp = b * a return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) tmp = 0.0 if (t_1 <= -1e+306) tmp = Float64(b * a); elseif (t_1 <= -2e-30) tmp = x; elseif (t_1 <= 5e+307) tmp = y; else tmp = Float64(b * a); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b); tmp = 0.0; if (t_1 <= -1e+306) tmp = b * a; elseif (t_1 <= -2e-30) tmp = x; elseif (t_1 <= 5e+307) tmp = y; else tmp = b * a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+306], N[(b * a), $MachinePrecision], If[LessEqual[t$95$1, -2e-30], x, If[LessEqual[t$95$1, 5e+307], y, N[(b * a), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+306}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-30}:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+307}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < -1.00000000000000002e306 or 5e307 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) Initial program 100.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6492.4
Applied rewrites92.4%
if -1.00000000000000002e306 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < -2e-30Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites24.5%
if -2e-30 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < 5e307Initial program 99.8%
Taylor expanded in y around inf
Applied rewrites23.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)) (t_2 (fma (- a 0.5) b (+ x y))))
(if (<= t_1 -2e+147)
t_2
(if (<= t_1 5e+26) (- (+ (+ y x) z) (* (log t) z)) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double t_2 = fma((a - 0.5), b, (x + y));
double tmp;
if (t_1 <= -2e+147) {
tmp = t_2;
} else if (t_1 <= 5e+26) {
tmp = ((y + x) + z) - (log(t) * z);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) t_2 = fma(Float64(a - 0.5), b, Float64(x + y)) tmp = 0.0 if (t_1 <= -2e+147) tmp = t_2; elseif (t_1 <= 5e+26) tmp = Float64(Float64(Float64(y + x) + z) - Float64(log(t) * z)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+147], t$95$2, If[LessEqual[t$95$1, 5e+26], N[(N[(N[(y + x), $MachinePrecision] + z), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
t_2 := \mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+147}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+26}:\\
\;\;\;\;\left(\left(y + x\right) + z\right) - \log t \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -2e147 or 5.0000000000000001e26 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6487.7
Applied rewrites87.7%
if -2e147 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 5.0000000000000001e26Initial program 99.8%
Taylor expanded in b around 0
associate-+r+N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6490.9
Applied rewrites90.9%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)) -2e-30) x y))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((((x + y) + z) - (z * log(t))) + ((a - 0.5) * b)) <= -2e-30) {
tmp = x;
} else {
tmp = y;
}
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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (((((x + y) + z) - (z * log(t))) + ((a - 0.5d0) * b)) <= (-2d-30)) then
tmp = x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b)) <= -2e-30) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)) <= -2e-30: tmp = x else: tmp = y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) <= -2e-30) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((((x + y) + z) - (z * log(t))) + ((a - 0.5) * b)) <= -2e-30) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], -2e-30], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \leq -2 \cdot 10^{-30}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < -2e-30Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites21.6%
if -2e-30 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) Initial program 99.9%
Taylor expanded in y around inf
Applied rewrites20.9%
(FPCore (x y z t a b) :precision binary64 (if (<= x -2.2e+60) (fma (- a 0.5) b (+ x y)) (- (+ (fma (- a 0.5) b z) y) (* (log t) z))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -2.2e+60) {
tmp = fma((a - 0.5), b, (x + y));
} else {
tmp = (fma((a - 0.5), b, z) + y) - (log(t) * z);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -2.2e+60) tmp = fma(Float64(a - 0.5), b, Float64(x + y)); else tmp = Float64(Float64(fma(Float64(a - 0.5), b, z) + y) - Float64(log(t) * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -2.2e+60], N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(a - 0.5), $MachinePrecision] * b + z), $MachinePrecision] + y), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(a - 0.5, b, z\right) + y\right) - \log t \cdot z\\
\end{array}
\end{array}
if x < -2.19999999999999996e60Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6486.1
Applied rewrites86.1%
if -2.19999999999999996e60 < x Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6484.4
Applied rewrites84.4%
(FPCore (x y z t a b) :precision binary64 (if (<= z -6.1e+268) (* (- 1.0 (log t)) z) (if (<= z 1e+194) (fma (- a 0.5) b (+ x y)) (- (+ z y) (* (log t) z)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -6.1e+268) {
tmp = (1.0 - log(t)) * z;
} else if (z <= 1e+194) {
tmp = fma((a - 0.5), b, (x + y));
} else {
tmp = (z + y) - (log(t) * z);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -6.1e+268) tmp = Float64(Float64(1.0 - log(t)) * z); elseif (z <= 1e+194) tmp = fma(Float64(a - 0.5), b, Float64(x + y)); else tmp = Float64(Float64(z + y) - Float64(log(t) * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -6.1e+268], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 1e+194], N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(z + y), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.1 \cdot 10^{+268}:\\
\;\;\;\;\left(1 - \log t\right) \cdot z\\
\mathbf{elif}\;z \leq 10^{+194}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z + y\right) - \log t \cdot z\\
\end{array}
\end{array}
if z < -6.10000000000000002e268Initial program 99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6480.6
Applied rewrites80.6%
if -6.10000000000000002e268 < z < 9.99999999999999945e193Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6485.1
Applied rewrites85.1%
if 9.99999999999999945e193 < z Initial program 99.6%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6493.6
Applied rewrites93.6%
Taylor expanded in z around inf
Applied rewrites71.8%
(FPCore (x y z t a b) :precision binary64 (if (<= z -6.1e+268) (* (- 1.0 (log t)) z) (if (<= z 2.9e+118) (fma (- a 0.5) b (+ x y)) (- (+ z x) (* (log t) z)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -6.1e+268) {
tmp = (1.0 - log(t)) * z;
} else if (z <= 2.9e+118) {
tmp = fma((a - 0.5), b, (x + y));
} else {
tmp = (z + x) - (log(t) * z);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -6.1e+268) tmp = Float64(Float64(1.0 - log(t)) * z); elseif (z <= 2.9e+118) tmp = fma(Float64(a - 0.5), b, Float64(x + y)); else tmp = Float64(Float64(z + x) - Float64(log(t) * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -6.1e+268], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 2.9e+118], N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(z + x), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.1 \cdot 10^{+268}:\\
\;\;\;\;\left(1 - \log t\right) \cdot z\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{+118}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z + x\right) - \log t \cdot z\\
\end{array}
\end{array}
if z < -6.10000000000000002e268Initial program 99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6480.6
Applied rewrites80.6%
if -6.10000000000000002e268 < z < 2.90000000000000016e118Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6486.4
Applied rewrites86.4%
if 2.90000000000000016e118 < z Initial program 99.7%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6499.7
Applied rewrites99.7%
Taylor expanded in b around 0
+-commutativeN/A
associate--l+N/A
+-commutativeN/A
*-commutativeN/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f6472.5
Applied rewrites72.5%
Taylor expanded in y around 0
Applied rewrites61.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- 1.0 (log t)) z)))
(if (<= z -6.1e+268)
t_1
(if (<= z 3.7e+194) (fma (- a 0.5) b (+ x y)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (1.0 - log(t)) * z;
double tmp;
if (z <= -6.1e+268) {
tmp = t_1;
} else if (z <= 3.7e+194) {
tmp = fma((a - 0.5), b, (x + y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(1.0 - log(t)) * z) tmp = 0.0 if (z <= -6.1e+268) tmp = t_1; elseif (z <= 3.7e+194) tmp = fma(Float64(a - 0.5), b, Float64(x + y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -6.1e+268], t$95$1, If[LessEqual[z, 3.7e+194], N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(1 - \log t\right) \cdot z\\
\mathbf{if}\;z \leq -6.1 \cdot 10^{+268}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{+194}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -6.10000000000000002e268 or 3.7000000000000003e194 < z Initial program 99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6469.2
Applied rewrites69.2%
if -6.10000000000000002e268 < z < 3.7000000000000003e194Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6485.1
Applied rewrites85.1%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -3e+142) x (if (<= (+ x y) 2e+148) (* (- a 0.5) b) y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= -3e+142) {
tmp = x;
} else if ((x + y) <= 2e+148) {
tmp = (a - 0.5) * b;
} else {
tmp = y;
}
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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((x + y) <= (-3d+142)) then
tmp = x
else if ((x + y) <= 2d+148) then
tmp = (a - 0.5d0) * b
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= -3e+142) {
tmp = x;
} else if ((x + y) <= 2e+148) {
tmp = (a - 0.5) * b;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x + y) <= -3e+142: tmp = x elif (x + y) <= 2e+148: tmp = (a - 0.5) * b else: tmp = y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= -3e+142) tmp = x; elseif (Float64(x + y) <= 2e+148) tmp = Float64(Float64(a - 0.5) * b); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x + y) <= -3e+142) tmp = x; elseif ((x + y) <= 2e+148) tmp = (a - 0.5) * b; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -3e+142], x, If[LessEqual[N[(x + y), $MachinePrecision], 2e+148], N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -3 \cdot 10^{+142}:\\
\;\;\;\;x\\
\mathbf{elif}\;x + y \leq 2 \cdot 10^{+148}:\\
\;\;\;\;\left(a - 0.5\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if (+.f64 x y) < -2.99999999999999975e142Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites32.9%
if -2.99999999999999975e142 < (+.f64 x y) < 2.0000000000000001e148Initial program 99.8%
Taylor expanded in b around inf
*-commutativeN/A
lift-*.f64N/A
lift--.f6449.1
Applied rewrites49.1%
if 2.0000000000000001e148 < (+.f64 x y) Initial program 99.9%
Taylor expanded in y around inf
Applied rewrites32.1%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b))) (if (<= b -6.2e+176) t_1 (if (<= b 2.5e+180) (fma a b (+ x y)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if (b <= -6.2e+176) {
tmp = t_1;
} else if (b <= 2.5e+180) {
tmp = fma(a, b, (x + y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if (b <= -6.2e+176) tmp = t_1; elseif (b <= 2.5e+180) tmp = fma(a, b, Float64(x + y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[b, -6.2e+176], t$95$1, If[LessEqual[b, 2.5e+180], N[(a * b + N[(x + y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;b \leq -6.2 \cdot 10^{+176}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{+180}:\\
\;\;\;\;\mathsf{fma}\left(a, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -6.1999999999999998e176 or 2.4999999999999998e180 < b Initial program 99.9%
Taylor expanded in b around inf
*-commutativeN/A
lift-*.f64N/A
lift--.f6482.3
Applied rewrites82.3%
if -6.1999999999999998e176 < b < 2.4999999999999998e180Initial program 99.8%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6474.4
Applied rewrites74.4%
Taylor expanded in a around inf
Applied rewrites68.2%
(FPCore (x y z t a b) :precision binary64 (if (<= y 3.3e+18) (fma (- a 0.5) b x) (fma a b (+ x y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= 3.3e+18) {
tmp = fma((a - 0.5), b, x);
} else {
tmp = fma(a, b, (x + y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= 3.3e+18) tmp = fma(Float64(a - 0.5), b, x); else tmp = fma(a, b, Float64(x + y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, 3.3e+18], N[(N[(a - 0.5), $MachinePrecision] * b + x), $MachinePrecision], N[(a * b + N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.3 \cdot 10^{+18}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, x + y\right)\\
\end{array}
\end{array}
if y < 3.3e18Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites62.3%
if 3.3e18 < y Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6485.1
Applied rewrites85.1%
Taylor expanded in a around inf
Applied rewrites76.3%
(FPCore (x y z t a b) :precision binary64 (fma (- a 0.5) b (+ x y)))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, (x + y));
}
function code(x, y, z, t, a, b) return fma(Float64(a - 0.5), b, Float64(x + y)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, x + y\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6478.4
Applied rewrites78.4%
(FPCore (x y z t a b) :precision binary64 (+ (fma (- a 0.5) b y) x))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, y) + x;
}
function code(x, y, z, t, a, b) return Float64(fma(Float64(a - 0.5), b, y) + x) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, y\right) + x
\end{array}
Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
(FPCore (x y z t a b) :precision binary64 x)
double code(double x, double y, double z, double t, double a, double b) {
return x;
}
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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = x
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x;
}
def code(x, y, z, t, a, b): return x
function code(x, y, z, t, a, b) return x end
function tmp = code(x, y, z, t, a, b) tmp = x; end
code[x_, y_, z_, t_, a_, b_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites22.5%
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x y) (/ (* (- 1.0 (pow (log t) 2.0)) z) (+ 1.0 (log t)))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + y) + (((1.0 - pow(log(t), 2.0)) * z) / (1.0 + log(t)))) + ((a - 0.5) * b);
}
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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x + y) + (((1.0d0 - (log(t) ** 2.0d0)) * z) / (1.0d0 + log(t)))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + y) + (((1.0 - Math.pow(Math.log(t), 2.0)) * z) / (1.0 + Math.log(t)))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return ((x + y) + (((1.0 - math.pow(math.log(t), 2.0)) * z) / (1.0 + math.log(t)))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + y) + Float64(Float64(Float64(1.0 - (log(t) ^ 2.0)) * z) / Float64(1.0 + log(t)))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + y) + (((1.0 - (log(t) ^ 2.0)) * z) / (1.0 + log(t)))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + y), $MachinePrecision] + N[(N[(N[(1.0 - N[Power[N[Log[t], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] / N[(1.0 + N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y\right) + \frac{\left(1 - {\log t}^{2}\right) \cdot z}{1 + \log t}\right) + \left(a - 0.5\right) \cdot b
\end{array}
herbie shell --seed 2025095
(FPCore (x y z t a b)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, A"
:precision binary64
:alt
(! :herbie-platform default (+ (+ (+ x y) (/ (* (- 1 (pow (log t) 2)) z) (+ 1 (log t)))) (* (- a 1/2) b)))
(+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))