
(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 18 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 (- 1.0 (log t)) z y) x) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (fma((1.0 - log(t)), z, y) + x) + ((a - 0.5) * b);
}
function code(x, y, z, t, a, b) return Float64(Float64(fma(Float64(1.0 - log(t)), z, y) + x) + Float64(Float64(a - 0.5) * b)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + y), $MachinePrecision] + x), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(1 - \log t, z, y\right) + x\right) + \left(a - 0.5\right) \cdot b
\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
lower--.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Final simplification99.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 -6e+306)
(* b a)
(if (<= t_1 -1e-131) x (if (<= t_1 4e+291) (fma -0.5 b y) (fma a b y))))))
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 <= -6e+306) {
tmp = b * a;
} else if (t_1 <= -1e-131) {
tmp = x;
} else if (t_1 <= 4e+291) {
tmp = fma(-0.5, b, y);
} else {
tmp = fma(a, b, y);
}
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 <= -6e+306) tmp = Float64(b * a); elseif (t_1 <= -1e-131) tmp = x; elseif (t_1 <= 4e+291) tmp = fma(-0.5, b, y); else tmp = fma(a, b, y); end return 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, -6e+306], N[(b * a), $MachinePrecision], If[LessEqual[t$95$1, -1e-131], x, If[LessEqual[t$95$1, 4e+291], N[(-0.5 * b + y), $MachinePrecision], N[(a * b + y), $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 -6 \cdot 10^{+306}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-131}:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+291}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, y\right)\\
\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)) < -6.00000000000000042e306Initial program 100.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
if -6.00000000000000042e306 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < -9.9999999999999999e-132Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites21.4%
if -9.9999999999999999e-132 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < 3.9999999999999998e291Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
Applied rewrites49.1%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6449.1
*-commutative49.1
Applied rewrites49.1%
Taylor expanded in a around 0
Applied rewrites43.0%
if 3.9999999999999998e291 < (+.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 z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites82.2%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6482.2
*-commutative82.2
Applied rewrites82.2%
Taylor expanded in a around inf
Applied rewrites82.2%
(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 -6e+306)
(* b a)
(if (<= t_1 -1e-131) x (if (<= t_1 INFINITY) (fma -0.5 b 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 <= -6e+306) {
tmp = b * a;
} else if (t_1 <= -1e-131) {
tmp = x;
} else if (t_1 <= ((double) INFINITY)) {
tmp = fma(-0.5, b, 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 <= -6e+306) tmp = Float64(b * a); elseif (t_1 <= -1e-131) tmp = x; elseif (t_1 <= Inf) tmp = fma(-0.5, b, y); else tmp = Float64(b * a); end return 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, -6e+306], N[(b * a), $MachinePrecision], If[LessEqual[t$95$1, -1e-131], x, If[LessEqual[t$95$1, Infinity], N[(-0.5 * b + y), $MachinePrecision], 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 -6 \cdot 10^{+306}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-131}:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, y\right)\\
\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)) < -6.00000000000000042e306 or +inf.0 < (+.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-*.f64100.0
Applied rewrites100.0%
if -6.00000000000000042e306 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < -9.9999999999999999e-132Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites21.4%
if -9.9999999999999999e-132 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < +inf.0Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites55.2%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6455.2
*-commutative55.2
Applied rewrites55.2%
Taylor expanded in a around 0
Applied rewrites39.7%
(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 -6e+306)
(* b a)
(if (<= t_1 -5e-145) x (if (<= t_1 INFINITY) 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 <= -6e+306) {
tmp = b * a;
} else if (t_1 <= -5e-145) {
tmp = x;
} else if (t_1 <= ((double) INFINITY)) {
tmp = y;
} else {
tmp = b * a;
}
return tmp;
}
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 <= -6e+306) {
tmp = b * a;
} else if (t_1 <= -5e-145) {
tmp = x;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
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 <= -6e+306: tmp = b * a elif t_1 <= -5e-145: tmp = x elif t_1 <= math.inf: 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 <= -6e+306) tmp = Float64(b * a); elseif (t_1 <= -5e-145) tmp = x; elseif (t_1 <= Inf) 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 <= -6e+306) tmp = b * a; elseif (t_1 <= -5e-145) tmp = x; elseif (t_1 <= Inf) 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, -6e+306], N[(b * a), $MachinePrecision], If[LessEqual[t$95$1, -5e-145], x, If[LessEqual[t$95$1, Infinity], 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 -6 \cdot 10^{+306}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-145}:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;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)) < -6.00000000000000042e306 or +inf.0 < (+.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-*.f64100.0
Applied rewrites100.0%
if -6.00000000000000042e306 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < -4.9999999999999998e-145Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites21.3%
if -4.9999999999999998e-145 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < +inf.0Initial program 99.8%
Taylor expanded in y around inf
Applied rewrites21.5%
(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-131)
(+ x (* a b))
(if (<= t_1 4e+291) (fma -0.5 b y) (fma a b y)))))
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-131) {
tmp = x + (a * b);
} else if (t_1 <= 4e+291) {
tmp = fma(-0.5, b, y);
} else {
tmp = fma(a, b, y);
}
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-131) tmp = Float64(x + Float64(a * b)); elseif (t_1 <= 4e+291) tmp = fma(-0.5, b, y); else tmp = fma(a, b, y); end return 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-131], N[(x + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+291], N[(-0.5 * b + y), $MachinePrecision], N[(a * b + y), $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^{-131}:\\
\;\;\;\;x + a \cdot b\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+291}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, y\right)\\
\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.9999999999999999e-132Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites55.6%
Taylor expanded in a around inf
Applied rewrites47.6%
if -9.9999999999999999e-132 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < 3.9999999999999998e291Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
Applied rewrites49.1%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6449.1
*-commutative49.1
Applied rewrites49.1%
Taylor expanded in a around 0
Applied rewrites43.0%
if 3.9999999999999998e291 < (+.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 z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites82.2%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6482.2
*-commutative82.2
Applied rewrites82.2%
Taylor expanded in a around inf
Applied rewrites82.2%
Final simplification48.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)) (t_2 (fma (- a 0.5) b y)))
(if (<= t_1 -5e+96)
(+ t_2 x)
(if (<= t_1 1e+154) (+ (+ (fma (- 1.0 (log t)) z y) x) (* -0.5 b)) 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, y);
double tmp;
if (t_1 <= -5e+96) {
tmp = t_2 + x;
} else if (t_1 <= 1e+154) {
tmp = (fma((1.0 - log(t)), z, y) + x) + (-0.5 * b);
} 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, y) tmp = 0.0 if (t_1 <= -5e+96) tmp = Float64(t_2 + x); elseif (t_1 <= 1e+154) tmp = Float64(Float64(fma(Float64(1.0 - log(t)), z, y) + x) + Float64(-0.5 * b)); 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 + y), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+96], N[(t$95$2 + x), $MachinePrecision], If[LessEqual[t$95$1, 1e+154], N[(N[(N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + y), $MachinePrecision] + x), $MachinePrecision] + N[(-0.5 * b), $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, y\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+96}:\\
\;\;\;\;t\_2 + x\\
\mathbf{elif}\;t\_1 \leq 10^{+154}:\\
\;\;\;\;\left(\mathsf{fma}\left(1 - \log t, z, y\right) + x\right) + -0.5 \cdot b\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -5.0000000000000004e96Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6498.4
Applied rewrites98.4%
if -5.0000000000000004e96 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1.00000000000000004e154Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6499.8
Applied rewrites99.8%
Taylor expanded in a around 0
lower-*.f6495.5
Applied rewrites95.5%
if 1.00000000000000004e154 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites96.9%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6496.9
*-commutative96.9
Applied rewrites96.9%
Final simplification96.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)) (t_2 (fma (- a 0.5) b y)))
(if (<= t_1 -5e+96)
(+ t_2 x)
(if (<= t_1 1e+154) (- (+ (+ (fma -0.5 b z) y) x) (* (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, y);
double tmp;
if (t_1 <= -5e+96) {
tmp = t_2 + x;
} else if (t_1 <= 1e+154) {
tmp = ((fma(-0.5, b, z) + y) + x) - (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, y) tmp = 0.0 if (t_1 <= -5e+96) tmp = Float64(t_2 + x); elseif (t_1 <= 1e+154) tmp = Float64(Float64(Float64(fma(-0.5, b, z) + y) + x) - 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 + y), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+96], N[(t$95$2 + x), $MachinePrecision], If[LessEqual[t$95$1, 1e+154], N[(N[(N[(N[(-0.5 * b + z), $MachinePrecision] + y), $MachinePrecision] + x), $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, y\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+96}:\\
\;\;\;\;t\_2 + x\\
\mathbf{elif}\;t\_1 \leq 10^{+154}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-0.5, b, z\right) + y\right) + x\right) - \log t \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -5.0000000000000004e96Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6498.4
Applied rewrites98.4%
if -5.0000000000000004e96 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1.00000000000000004e154Initial program 99.8%
Taylor expanded in a around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6495.5
Applied rewrites95.5%
if 1.00000000000000004e154 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites96.9%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6496.9
*-commutative96.9
Applied rewrites96.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)))
(if (or (<= t_1 -5e+96) (not (<= t_1 5e+102)))
(+ (fma (- a 0.5) b y) x)
(+ (+ y x) (- z (* (log t) z))))))
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 <= -5e+96) || !(t_1 <= 5e+102)) {
tmp = fma((a - 0.5), b, y) + x;
} else {
tmp = (y + x) + (z - (log(t) * z));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if ((t_1 <= -5e+96) || !(t_1 <= 5e+102)) tmp = Float64(fma(Float64(a - 0.5), b, y) + x); else tmp = Float64(Float64(y + x) + Float64(z - Float64(log(t) * z))); 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, -5e+96], N[Not[LessEqual[t$95$1, 5e+102]], $MachinePrecision]], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision], N[(N[(y + x), $MachinePrecision] + N[(z - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+96} \lor \neg \left(t\_1 \leq 5 \cdot 10^{+102}\right):\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;\left(y + x\right) + \left(z - \log t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -5.0000000000000004e96 or 5e102 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6494.6
Applied rewrites94.6%
if -5.0000000000000004e96 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 5e102Initial 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.f6491.0
Applied rewrites91.0%
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
associate--l+N/A
+-commutativeN/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower--.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f6491.0
Applied rewrites91.0%
Final simplification92.5%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -1e-131) (+ x (* (- a 0.5) b)) (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-131) {
tmp = x + ((a - 0.5) * b);
} 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-131) tmp = Float64(x + Float64(Float64(a - 0.5) * b)); 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-131], N[(x + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $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^{-131}:\\
\;\;\;\;x + \left(a - 0.5\right) \cdot b\\
\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.9999999999999999e-132Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites50.6%
if -9.9999999999999999e-132 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites60.0%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6460.0
*-commutative60.0
Applied rewrites60.0%
Final simplification55.5%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)) -5e-145) 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)) <= -5e-145) {
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)) <= (-5d-145)) 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)) <= -5e-145) {
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)) <= -5e-145: 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)) <= -5e-145) 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)) <= -5e-145) 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], -5e-145], 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 -5 \cdot 10^{-145}:\\
\;\;\;\;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)) < -4.9999999999999998e-145Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites18.3%
if -4.9999999999999998e-145 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) Initial program 99.8%
Taylor expanded in y around inf
Applied rewrites21.5%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -4e+58) (+ x (* a b)) (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))) <= -4e+58) {
tmp = x + (a * b);
} 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))) <= -4e+58) tmp = Float64(x + Float64(a * b)); 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], -4e+58], N[(x + N[(a * b), $MachinePrecision]), $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 -4 \cdot 10^{+58}:\\
\;\;\;\;x + a \cdot b\\
\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))) < -3.99999999999999978e58Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites44.3%
Taylor expanded in a around inf
Applied rewrites40.2%
if -3.99999999999999978e58 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites61.2%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6461.2
*-commutative61.2
Applied rewrites61.2%
Final simplification53.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -3e+216) (not (<= z 9e+171))) (+ x (- z (* (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 <= -3e+216) || !(z <= 9e+171)) {
tmp = x + (z - (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 <= -3e+216) || !(z <= 9e+171)) tmp = Float64(x + Float64(z - Float64(log(t) * z))); else tmp = Float64(fma(Float64(a - 0.5), b, y) + x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -3e+216], N[Not[LessEqual[z, 9e+171]], $MachinePrecision]], N[(x + N[(z - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{+216} \lor \neg \left(z \leq 9 \cdot 10^{+171}\right):\\
\;\;\;\;x + \left(z - \log t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\end{array}
\end{array}
if z < -2.9999999999999998e216 or 8.99999999999999937e171 < z Initial program 99.7%
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.f6493.1
Applied rewrites93.1%
Taylor expanded in x around inf
+-commutative84.3
Applied rewrites84.3%
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
associate--l+N/A
*-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f6484.3
Applied rewrites84.3%
if -2.9999999999999998e216 < z < 8.99999999999999937e171Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6487.4
Applied rewrites87.4%
Final simplification86.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -2.05e+242) (not (<= z 2.7e+172))) (- z (* (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 <= -2.05e+242) || !(z <= 2.7e+172)) {
tmp = z - (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 <= -2.05e+242) || !(z <= 2.7e+172)) tmp = Float64(z - Float64(log(t) * z)); else tmp = Float64(fma(Float64(a - 0.5), b, y) + x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -2.05e+242], N[Not[LessEqual[z, 2.7e+172]], $MachinePrecision]], N[(z - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.05 \cdot 10^{+242} \lor \neg \left(z \leq 2.7 \cdot 10^{+172}\right):\\
\;\;\;\;z - \log t \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\end{array}
\end{array}
if z < -2.0499999999999999e242 or 2.7e172 < z Initial program 99.7%
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.f6494.7
Applied rewrites94.7%
Taylor expanded in z around inf
+-commutative81.3
Applied rewrites81.3%
if -2.0499999999999999e242 < z < 2.7e172Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6486.6
Applied rewrites86.6%
Final simplification85.8%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -2.05e+242) (not (<= z 2.7e+172))) (* (- 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 <= -2.05e+242) || !(z <= 2.7e+172)) {
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 <= -2.05e+242) || !(z <= 2.7e+172)) tmp = Float64(Float64(1.0 - log(t)) * z); else tmp = Float64(fma(Float64(a - 0.5), b, y) + x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -2.05e+242], N[Not[LessEqual[z, 2.7e+172]], $MachinePrecision]], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.05 \cdot 10^{+242} \lor \neg \left(z \leq 2.7 \cdot 10^{+172}\right):\\
\;\;\;\;\left(1 - \log t\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\end{array}
\end{array}
if z < -2.0499999999999999e242 or 2.7e172 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6481.2
Applied rewrites81.2%
if -2.0499999999999999e242 < z < 2.7e172Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6486.6
Applied rewrites86.6%
Final simplification85.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -2000.0) (+ x (* -0.5 b)) (if (<= (+ x y) 2e-44) (* (- a 0.5) b) (fma a b y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= -2000.0) {
tmp = x + (-0.5 * b);
} else if ((x + y) <= 2e-44) {
tmp = (a - 0.5) * b;
} else {
tmp = fma(a, b, y);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= -2000.0) tmp = Float64(x + Float64(-0.5 * b)); elseif (Float64(x + y) <= 2e-44) tmp = Float64(Float64(a - 0.5) * b); else tmp = fma(a, b, y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -2000.0], N[(x + N[(-0.5 * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 2e-44], N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision], N[(a * b + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -2000:\\
\;\;\;\;x + -0.5 \cdot b\\
\mathbf{elif}\;x + y \leq 2 \cdot 10^{-44}:\\
\;\;\;\;\left(a - 0.5\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, y\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -2e3Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites54.7%
Taylor expanded in a around 0
lower-*.f6435.7
Applied rewrites35.7%
if -2e3 < (+.f64 x y) < 1.99999999999999991e-44Initial program 99.8%
Taylor expanded in b around inf
*-commutativeN/A
lift-*.f64N/A
lift--.f6455.8
Applied rewrites55.8%
if 1.99999999999999991e-44 < (+.f64 x y) Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites54.4%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6454.4
*-commutative54.4
Applied rewrites54.4%
Taylor expanded in a around inf
Applied rewrites46.0%
Final simplification44.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -2e+118) x (if (<= (+ x y) 2e-44) (* (- a 0.5) b) (fma a b y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= -2e+118) {
tmp = x;
} else if ((x + y) <= 2e-44) {
tmp = (a - 0.5) * b;
} else {
tmp = fma(a, b, y);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= -2e+118) tmp = x; elseif (Float64(x + y) <= 2e-44) tmp = Float64(Float64(a - 0.5) * b); else tmp = fma(a, b, y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -2e+118], x, If[LessEqual[N[(x + y), $MachinePrecision], 2e-44], N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision], N[(a * b + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -2 \cdot 10^{+118}:\\
\;\;\;\;x\\
\mathbf{elif}\;x + y \leq 2 \cdot 10^{-44}:\\
\;\;\;\;\left(a - 0.5\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, y\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -1.99999999999999993e118Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites29.9%
if -1.99999999999999993e118 < (+.f64 x y) < 1.99999999999999991e-44Initial program 99.8%
Taylor expanded in b around inf
*-commutativeN/A
lift-*.f64N/A
lift--.f6453.9
Applied rewrites53.9%
if 1.99999999999999991e-44 < (+.f64 x y) Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites54.4%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6454.4
*-commutative54.4
Applied rewrites54.4%
Taylor expanded in a around inf
Applied rewrites46.0%
(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--.f6476.8
Applied rewrites76.8%
(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 rewrites21.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 2025043
(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)))