
(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}
Sampling outcomes in binary64 precision:
Herbie found 19 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 (+ (- (+ (+ 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}
Initial program 99.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))) (t_2 (* (- a 0.5) b)))
(if (or (<= t_2 -1e+66) (not (<= t_2 1e+152)))
(fma t_1 z (fma (- a 0.5) b y))
(+ (fma t_1 z y) (fma -0.5 b x)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double t_2 = (a - 0.5) * b;
double tmp;
if ((t_2 <= -1e+66) || !(t_2 <= 1e+152)) {
tmp = fma(t_1, z, fma((a - 0.5), b, y));
} else {
tmp = fma(t_1, z, y) + fma(-0.5, b, x);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) t_2 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if ((t_2 <= -1e+66) || !(t_2 <= 1e+152)) tmp = fma(t_1, z, fma(Float64(a - 0.5), b, y)); else tmp = Float64(fma(t_1, z, y) + fma(-0.5, b, x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -1e+66], N[Not[LessEqual[t$95$2, 1e+152]], $MachinePrecision]], N[(t$95$1 * z + N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * z + y), $MachinePrecision] + N[(-0.5 * b + x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
t_2 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+66} \lor \neg \left(t\_2 \leq 10^{+152}\right):\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, \mathsf{fma}\left(a - 0.5, b, y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, y\right) + \mathsf{fma}\left(-0.5, b, x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -9.99999999999999945e65 or 1e152 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites95.6%
if -9.99999999999999945e65 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1e152Initial program 99.8%
Taylor expanded in a around 0
Applied rewrites94.5%
Final simplification95.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)))
(if (or (<= t_1 -2e-6) (not (<= t_1 2e+63)))
(fma (- a 0.5) b (+ y x))
(fma (- 1.0 (log t)) z (+ y x)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if ((t_1 <= -2e-6) || !(t_1 <= 2e+63)) {
tmp = fma((a - 0.5), b, (y + x));
} else {
tmp = fma((1.0 - log(t)), z, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if ((t_1 <= -2e-6) || !(t_1 <= 2e+63)) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); else tmp = fma(Float64(1.0 - log(t)), z, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e-6], N[Not[LessEqual[t$95$1, 2e+63]], $MachinePrecision]], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-6} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+63}\right):\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y + x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.99999999999999991e-6 or 2.00000000000000012e63 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites87.9%
if -1.99999999999999991e-6 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2.00000000000000012e63Initial program 99.8%
Taylor expanded in b around 0
Applied rewrites94.5%
Final simplification90.6%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)) -1e-137) 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)) <= -1e-137) {
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)) <= (-1d-137)) 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)) <= -1e-137) {
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)) <= -1e-137: 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)) <= -1e-137) 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)) <= -1e-137) 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], -1e-137], 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 -1 \cdot 10^{-137}:\\
\;\;\;\;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)) < -9.99999999999999978e-138Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites13.8%
if -9.99999999999999978e-138 < (+.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.5%
(FPCore (x y z t a b)
:precision binary64
(if (<= a -1.7e+67)
(fma a b (+ y x))
(if (<= a 0.00048)
(+ (fma (- 1.0 (log t)) z y) (fma -0.5 b x))
(fma (- a 0.5) b (+ y x)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -1.7e+67) {
tmp = fma(a, b, (y + x));
} else if (a <= 0.00048) {
tmp = fma((1.0 - log(t)), z, y) + fma(-0.5, b, x);
} else {
tmp = fma((a - 0.5), b, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -1.7e+67) tmp = fma(a, b, Float64(y + x)); elseif (a <= 0.00048) tmp = Float64(fma(Float64(1.0 - log(t)), z, y) + fma(-0.5, b, x)); else tmp = fma(Float64(a - 0.5), b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -1.7e+67], N[(a * b + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.00048], N[(N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + y), $MachinePrecision] + N[(-0.5 * b + x), $MachinePrecision]), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.7 \cdot 10^{+67}:\\
\;\;\;\;\mathsf{fma}\left(a, b, y + x\right)\\
\mathbf{elif}\;a \leq 0.00048:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y\right) + \mathsf{fma}\left(-0.5, b, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\end{array}
\end{array}
if a < -1.7000000000000001e67Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites88.8%
Taylor expanded in a around inf
Applied rewrites88.8%
if -1.7000000000000001e67 < a < 4.80000000000000012e-4Initial program 99.8%
Taylor expanded in a around 0
Applied rewrites97.7%
if 4.80000000000000012e-4 < a Initial program 100.0%
Taylor expanded in z around 0
Applied rewrites88.1%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -1e-137) (fma (- a 0.5) b x) (fma (- a 0.5) b y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((((x + y) + z) - (z * log(t))) <= -1e-137) {
tmp = fma((a - 0.5), b, x);
} else {
tmp = fma((a - 0.5), b, y);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) <= -1e-137) tmp = fma(Float64(a - 0.5), b, x); else tmp = fma(Float64(a - 0.5), b, y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-137], N[(N[(a - 0.5), $MachinePrecision] * b + x), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x + y\right) + z\right) - z \cdot \log t \leq -1 \cdot 10^{-137}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) < -9.99999999999999978e-138Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites77.5%
Taylor expanded in x around inf
Applied rewrites52.2%
if -9.99999999999999978e-138 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites82.5%
Taylor expanded in x around 0
Applied rewrites63.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -3.3e+148) (not (<= z 1.75e+189))) (fma (- 1.0 (log t)) z (* b a)) (fma (- a 0.5) b (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -3.3e+148) || !(z <= 1.75e+189)) {
tmp = fma((1.0 - log(t)), z, (b * a));
} else {
tmp = fma((a - 0.5), b, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -3.3e+148) || !(z <= 1.75e+189)) tmp = fma(Float64(1.0 - log(t)), z, Float64(b * a)); else tmp = fma(Float64(a - 0.5), b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -3.3e+148], N[Not[LessEqual[z, 1.75e+189]], $MachinePrecision]], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(b * a), $MachinePrecision]), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.3 \cdot 10^{+148} \lor \neg \left(z \leq 1.75 \cdot 10^{+189}\right):\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, b \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\end{array}
\end{array}
if z < -3.3000000000000001e148 or 1.74999999999999998e189 < z Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites91.3%
Taylor expanded in a around inf
Applied rewrites86.2%
if -3.3000000000000001e148 < z < 1.74999999999999998e189Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites91.8%
Final simplification90.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))))
(if (<= z -6.2e+228)
(fma t_1 z y)
(if (<= z 9.6e+221) (fma (- a 0.5) b (+ y x)) (+ (* t_1 z) y)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double tmp;
if (z <= -6.2e+228) {
tmp = fma(t_1, z, y);
} else if (z <= 9.6e+221) {
tmp = fma((a - 0.5), b, (y + x));
} else {
tmp = (t_1 * z) + y;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) tmp = 0.0 if (z <= -6.2e+228) tmp = fma(t_1, z, y); elseif (z <= 9.6e+221) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); else tmp = Float64(Float64(t_1 * z) + y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.2e+228], N[(t$95$1 * z + y), $MachinePrecision], If[LessEqual[z, 9.6e+221], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * z), $MachinePrecision] + y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
\mathbf{if}\;z \leq -6.2 \cdot 10^{+228}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, y\right)\\
\mathbf{elif}\;z \leq 9.6 \cdot 10^{+221}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot z + y\\
\end{array}
\end{array}
if z < -6.1999999999999997e228Initial program 99.6%
Taylor expanded in x around 0
Applied rewrites80.8%
Taylor expanded in y around inf
Applied rewrites73.9%
if -6.1999999999999997e228 < z < 9.60000000000000077e221Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites88.5%
if 9.60000000000000077e221 < z Initial program 99.5%
Taylor expanded in x around 0
Applied rewrites94.8%
Taylor expanded in y around inf
Applied rewrites77.8%
Applied rewrites77.8%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -6.2e+228) (not (<= z 9.6e+221))) (fma (- 1.0 (log t)) z y) (fma (- a 0.5) b (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -6.2e+228) || !(z <= 9.6e+221)) {
tmp = fma((1.0 - log(t)), z, y);
} else {
tmp = fma((a - 0.5), b, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -6.2e+228) || !(z <= 9.6e+221)) tmp = fma(Float64(1.0 - log(t)), z, y); else tmp = fma(Float64(a - 0.5), b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -6.2e+228], N[Not[LessEqual[z, 9.6e+221]], $MachinePrecision]], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + y), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{+228} \lor \neg \left(z \leq 9.6 \cdot 10^{+221}\right):\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\end{array}
\end{array}
if z < -6.1999999999999997e228 or 9.60000000000000077e221 < z Initial program 99.6%
Taylor expanded in x around 0
Applied rewrites88.2%
Taylor expanded in y around inf
Applied rewrites76.0%
if -6.1999999999999997e228 < z < 9.60000000000000077e221Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites88.5%
Final simplification86.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -6.5e+228) (not (<= z 1.25e+222))) (* (- 1.0 (log t)) z) (fma (- a 0.5) b (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -6.5e+228) || !(z <= 1.25e+222)) {
tmp = (1.0 - log(t)) * z;
} else {
tmp = fma((a - 0.5), b, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -6.5e+228) || !(z <= 1.25e+222)) tmp = Float64(Float64(1.0 - log(t)) * z); else tmp = fma(Float64(a - 0.5), b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -6.5e+228], N[Not[LessEqual[z, 1.25e+222]], $MachinePrecision]], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+228} \lor \neg \left(z \leq 1.25 \cdot 10^{+222}\right):\\
\;\;\;\;\left(1 - \log t\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\end{array}
\end{array}
if z < -6.5e228 or 1.25000000000000006e222 < z Initial program 99.6%
Taylor expanded in z around inf
Applied rewrites73.5%
if -6.5e228 < z < 1.25000000000000006e222Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites88.5%
Final simplification86.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)))
(if (<= t_1 -4e+275)
(* b a)
(if (<= t_1 -1e+107)
(fma -0.5 b y)
(if (<= t_1 2e+172) (+ y x) (* b a))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if (t_1 <= -4e+275) {
tmp = b * a;
} else if (t_1 <= -1e+107) {
tmp = fma(-0.5, b, y);
} else if (t_1 <= 2e+172) {
tmp = y + x;
} else {
tmp = b * a;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if (t_1 <= -4e+275) tmp = Float64(b * a); elseif (t_1 <= -1e+107) tmp = fma(-0.5, b, y); elseif (t_1 <= 2e+172) tmp = Float64(y + x); else tmp = Float64(b * a); 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[t$95$1, -4e+275], N[(b * a), $MachinePrecision], If[LessEqual[t$95$1, -1e+107], N[(-0.5 * b + y), $MachinePrecision], If[LessEqual[t$95$1, 2e+172], N[(y + x), $MachinePrecision], N[(b * a), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+275}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{+107}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, y\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+172}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -3.99999999999999984e275 or 2.0000000000000002e172 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in a around inf
Applied rewrites73.3%
if -3.99999999999999984e275 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -9.9999999999999997e106Initial program 100.0%
Taylor expanded in z around 0
Applied rewrites85.0%
Taylor expanded in x around 0
Applied rewrites79.0%
Taylor expanded in a around 0
Applied rewrites51.9%
if -9.9999999999999997e106 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2.0000000000000002e172Initial program 99.8%
Taylor expanded in z around 0
Applied rewrites72.7%
Taylor expanded in b around 0
Applied rewrites59.6%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b))) (if (or (<= t_1 -1e+66) (not (<= t_1 2e+172))) t_1 (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if ((t_1 <= -1e+66) || !(t_1 <= 2e+172)) {
tmp = t_1;
} else {
tmp = y + x;
}
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 = (a - 0.5d0) * b
if ((t_1 <= (-1d+66)) .or. (.not. (t_1 <= 2d+172))) then
tmp = t_1
else
tmp = y + x
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 = (a - 0.5) * b;
double tmp;
if ((t_1 <= -1e+66) || !(t_1 <= 2e+172)) {
tmp = t_1;
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a - 0.5) * b tmp = 0 if (t_1 <= -1e+66) or not (t_1 <= 2e+172): tmp = t_1 else: tmp = y + x return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if ((t_1 <= -1e+66) || !(t_1 <= 2e+172)) tmp = t_1; else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a - 0.5) * b; tmp = 0.0; if ((t_1 <= -1e+66) || ~((t_1 <= 2e+172))) tmp = t_1; else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e+66], N[Not[LessEqual[t$95$1, 2e+172]], $MachinePrecision]], t$95$1, N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+66} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+172}\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -9.99999999999999945e65 or 2.0000000000000002e172 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in b around inf
Applied rewrites81.1%
if -9.99999999999999945e65 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2.0000000000000002e172Initial program 99.8%
Taylor expanded in z around 0
Applied rewrites72.6%
Taylor expanded in b around 0
Applied rewrites61.2%
Final simplification70.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b))) (if (or (<= t_1 -0.02) (not (<= t_1 1e+152))) (fma a b y) (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if ((t_1 <= -0.02) || !(t_1 <= 1e+152)) {
tmp = fma(a, b, y);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if ((t_1 <= -0.02) || !(t_1 <= 1e+152)) tmp = fma(a, b, y); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -0.02], N[Not[LessEqual[t$95$1, 1e+152]], $MachinePrecision]], N[(a * b + y), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -0.02 \lor \neg \left(t\_1 \leq 10^{+152}\right):\\
\;\;\;\;\mathsf{fma}\left(a, b, y\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -0.0200000000000000004 or 1e152 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in z around 0
Applied rewrites87.6%
Taylor expanded in x around 0
Applied rewrites80.9%
Taylor expanded in a around inf
Applied rewrites61.8%
if -0.0200000000000000004 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1e152Initial program 99.8%
Taylor expanded in z around 0
Applied rewrites72.2%
Taylor expanded in b around 0
Applied rewrites62.1%
Final simplification61.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b))) (if (or (<= t_1 -1e+66) (not (<= t_1 2e+172))) (* b a) (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if ((t_1 <= -1e+66) || !(t_1 <= 2e+172)) {
tmp = b * a;
} else {
tmp = y + x;
}
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 = (a - 0.5d0) * b
if ((t_1 <= (-1d+66)) .or. (.not. (t_1 <= 2d+172))) then
tmp = b * a
else
tmp = y + x
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 = (a - 0.5) * b;
double tmp;
if ((t_1 <= -1e+66) || !(t_1 <= 2e+172)) {
tmp = b * a;
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a - 0.5) * b tmp = 0 if (t_1 <= -1e+66) or not (t_1 <= 2e+172): tmp = b * a else: tmp = y + x return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if ((t_1 <= -1e+66) || !(t_1 <= 2e+172)) tmp = Float64(b * a); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a - 0.5) * b; tmp = 0.0; if ((t_1 <= -1e+66) || ~((t_1 <= 2e+172))) tmp = b * a; else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e+66], N[Not[LessEqual[t$95$1, 2e+172]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+66} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+172}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -9.99999999999999945e65 or 2.0000000000000002e172 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in a around inf
Applied rewrites59.7%
if -9.99999999999999945e65 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2.0000000000000002e172Initial program 99.8%
Taylor expanded in z around 0
Applied rewrites72.6%
Taylor expanded in b around 0
Applied rewrites61.2%
Final simplification60.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= b -3.8e-24) (not (<= b 1.7e+111))) (fma (- a 0.5) b x) (fma a b (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((b <= -3.8e-24) || !(b <= 1.7e+111)) {
tmp = fma((a - 0.5), b, x);
} else {
tmp = fma(a, b, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((b <= -3.8e-24) || !(b <= 1.7e+111)) tmp = fma(Float64(a - 0.5), b, x); else tmp = fma(a, b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[b, -3.8e-24], N[Not[LessEqual[b, 1.7e+111]], $MachinePrecision]], N[(N[(a - 0.5), $MachinePrecision] * b + x), $MachinePrecision], N[(a * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-24} \lor \neg \left(b \leq 1.7 \cdot 10^{+111}\right):\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, y + x\right)\\
\end{array}
\end{array}
if b < -3.80000000000000026e-24 or 1.7000000000000001e111 < b Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites88.7%
Taylor expanded in x around inf
Applied rewrites83.1%
if -3.80000000000000026e-24 < b < 1.7000000000000001e111Initial program 99.8%
Taylor expanded in z around 0
Applied rewrites74.1%
Taylor expanded in a around inf
Applied rewrites72.1%
Final simplification76.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= b -1.6e+61) (not (<= b 8.5e+112))) (* (- a 0.5) b) (fma a b (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((b <= -1.6e+61) || !(b <= 8.5e+112)) {
tmp = (a - 0.5) * b;
} else {
tmp = fma(a, b, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((b <= -1.6e+61) || !(b <= 8.5e+112)) tmp = Float64(Float64(a - 0.5) * b); else tmp = fma(a, b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[b, -1.6e+61], N[Not[LessEqual[b, 8.5e+112]], $MachinePrecision]], N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision], N[(a * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+61} \lor \neg \left(b \leq 8.5 \cdot 10^{+112}\right):\\
\;\;\;\;\left(a - 0.5\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, y + x\right)\\
\end{array}
\end{array}
if b < -1.5999999999999999e61 or 8.50000000000000047e112 < b Initial program 100.0%
Taylor expanded in b around inf
Applied rewrites84.3%
if -1.5999999999999999e61 < b < 8.50000000000000047e112Initial program 99.8%
Taylor expanded in z around 0
Applied rewrites73.7%
Taylor expanded in a around inf
Applied rewrites70.9%
Final simplification75.9%
(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 fma(Float64(a - 0.5), b, Float64(y + x)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, y + x\right)
\end{array}
Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites80.2%
(FPCore (x y z t a b) :precision binary64 (+ y x))
double code(double x, double y, double z, double t, double a, double b) {
return y + 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 = y + x
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return y + x;
}
def code(x, y, z, t, a, b): return y + x
function code(x, y, z, t, a, b) return Float64(y + x) end
function tmp = code(x, y, z, t, a, b) tmp = y + x; end
code[x_, y_, z_, t_, a_, b_] := N[(y + x), $MachinePrecision]
\begin{array}{l}
\\
y + x
\end{array}
Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites80.2%
Taylor expanded in b around 0
Applied rewrites38.0%
(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 rewrites17.9%
(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 2025018
(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)))