
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (((x + y) + z) - (z * log(t))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return (((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (+ (+ (fma (- 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%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)))
(if (or (<= t_1 -2e+105) (not (<= t_1 2e+129)))
(+ (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 <= -2e+105) || !(t_1 <= 2e+129)) {
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 <= -2e+105) || !(t_1 <= 2e+129)) tmp = Float64(fma(Float64(a - 0.5), b, y) + x); else tmp = Float64(Float64(Float64(y + x) + 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, -2e+105], N[Not[LessEqual[t$95$1, 2e+129]], $MachinePrecision]], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] + z), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $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^{+105} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+129}\right):\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y + x\right) + z\right) - \log t \cdot z\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.9999999999999999e105 or 2e129 < (*.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.1
Applied rewrites94.1%
if -1.9999999999999999e105 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e129Initial 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.f6494.4
Applied rewrites94.4%
Final simplification94.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))))
(if (<= b -8e+64)
(+ (fma t_1 z x) (* (- a 0.5) b))
(if (<= b 2e+133)
(+ (+ (fma t_1 z y) x) (* a b))
(* (- (+ (/ (+ y x) b) a) 0.5) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double tmp;
if (b <= -8e+64) {
tmp = fma(t_1, z, x) + ((a - 0.5) * b);
} else if (b <= 2e+133) {
tmp = (fma(t_1, z, y) + x) + (a * b);
} else {
tmp = ((((y + x) / b) + a) - 0.5) * b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) tmp = 0.0 if (b <= -8e+64) tmp = Float64(fma(t_1, z, x) + Float64(Float64(a - 0.5) * b)); elseif (b <= 2e+133) tmp = Float64(Float64(fma(t_1, z, y) + x) + Float64(a * b)); else tmp = Float64(Float64(Float64(Float64(Float64(y + x) / b) + a) - 0.5) * b); 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[b, -8e+64], N[(N[(t$95$1 * z + x), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e+133], N[(N[(N[(t$95$1 * z + y), $MachinePrecision] + x), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(y + x), $MachinePrecision] / b), $MachinePrecision] + a), $MachinePrecision] - 0.5), $MachinePrecision] * b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
\mathbf{if}\;b \leq -8 \cdot 10^{+64}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, x\right) + \left(a - 0.5\right) \cdot b\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+133}:\\
\;\;\;\;\left(\mathsf{fma}\left(t\_1, z, y\right) + x\right) + a \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\frac{y + x}{b} + a\right) - 0.5\right) \cdot b\\
\end{array}
\end{array}
if b < -8.00000000000000017e64Initial 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.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6494.5
Applied rewrites94.5%
if -8.00000000000000017e64 < b < 2e133Initial 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 a around inf
Applied rewrites98.9%
if 2e133 < 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--.f6497.2
Applied rewrites97.2%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6497.2
Applied rewrites97.2%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -5e-63) (+ 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))) <= -5e-63) {
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))) <= -5e-63) 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], -5e-63], 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 -5 \cdot 10^{-63}:\\
\;\;\;\;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))) < -5.0000000000000002e-63Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites62.0%
if -5.0000000000000002e-63 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6475.8
Applied rewrites75.8%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
lift-fma.f64N/A
lift--.f6458.3
Applied rewrites58.3%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)) -5e-63) 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-63) {
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-63)) 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-63) {
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-63: 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-63) 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-63) 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-63], 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^{-63}:\\
\;\;\;\;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)) < -5.0000000000000002e-63Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites22.9%
if -5.0000000000000002e-63 < (+.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 rewrites22.7%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))))
(if (<= (+ x y) 4e-127)
(+ (fma t_1 z x) (* (- a 0.5) b))
(fma a b (fma 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 ((x + y) <= 4e-127) {
tmp = fma(t_1, z, x) + ((a - 0.5) * b);
} else {
tmp = fma(a, b, fma(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 (Float64(x + y) <= 4e-127) tmp = Float64(fma(t_1, z, x) + Float64(Float64(a - 0.5) * b)); else tmp = fma(a, b, fma(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[N[(x + y), $MachinePrecision], 4e-127], N[(N[(t$95$1 * z + x), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(a * b + N[(t$95$1 * z + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
\mathbf{if}\;x + y \leq 4 \cdot 10^{-127}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, x\right) + \left(a - 0.5\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(t\_1, z, y\right)\right)\\
\end{array}
\end{array}
if (+.f64 x y) < 4.0000000000000001e-127Initial 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 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6483.5
Applied rewrites83.5%
if 4.0000000000000001e-127 < (+.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.f64100.0
Applied rewrites100.0%
Taylor expanded in a around inf
Applied rewrites90.1%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-fma.f6468.9
Applied rewrites68.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6468.9
Applied rewrites68.9%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -5e-63) (+ (* b a) 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))) <= -5e-63) {
tmp = (b * a) + 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))) <= -5e-63) tmp = Float64(Float64(b * a) + 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], -5e-63], N[(N[(b * a), $MachinePrecision] + 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 -5 \cdot 10^{-63}:\\
\;\;\;\;b \cdot a + x\\
\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))) < -5.0000000000000002e-63Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6481.1
Applied rewrites81.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6454.1
Applied rewrites54.1%
if -5.0000000000000002e-63 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6475.8
Applied rewrites75.8%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
lift-fma.f64N/A
lift--.f6458.3
Applied rewrites58.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -4.85e+213) (not (<= z 7.6e+242))) (* (- 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 <= -4.85e+213) || !(z <= 7.6e+242)) {
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 <= -4.85e+213) || !(z <= 7.6e+242)) 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, -4.85e+213], N[Not[LessEqual[z, 7.6e+242]], $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 -4.85 \cdot 10^{+213} \lor \neg \left(z \leq 7.6 \cdot 10^{+242}\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 < -4.8499999999999998e213 or 7.60000000000000015e242 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6481.7
Applied rewrites81.7%
if -4.8499999999999998e213 < z < 7.60000000000000015e242Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6487.9
Applied rewrites87.9%
Final simplification87.1%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b))) (if (or (<= t_1 -1e+183) (not (<= t_1 4e+187))) 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+183) || !(t_1 <= 4e+187)) {
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+183)) .or. (.not. (t_1 <= 4d+187))) 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+183) || !(t_1 <= 4e+187)) {
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+183) or not (t_1 <= 4e+187): 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+183) || !(t_1 <= 4e+187)) 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+183) || ~((t_1 <= 4e+187))) 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+183], N[Not[LessEqual[t$95$1, 4e+187]], $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^{+183} \lor \neg \left(t\_1 \leq 4 \cdot 10^{+187}\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -9.99999999999999947e182 or 3.99999999999999963e187 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in b around inf
*-commutativeN/A
lift-*.f64N/A
lift--.f6491.1
Applied rewrites91.1%
if -9.99999999999999947e182 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 3.99999999999999963e187Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6468.2
Applied rewrites68.2%
Taylor expanded in y around inf
Applied rewrites57.9%
Final simplification69.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b))) (if (or (<= t_1 -1e+183) (not (<= t_1 1e+216))) (* 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+183) || !(t_1 <= 1e+216)) {
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+183)) .or. (.not. (t_1 <= 1d+216))) 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+183) || !(t_1 <= 1e+216)) {
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+183) or not (t_1 <= 1e+216): 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+183) || !(t_1 <= 1e+216)) 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+183) || ~((t_1 <= 1e+216))) 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+183], N[Not[LessEqual[t$95$1, 1e+216]], $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^{+183} \lor \neg \left(t\_1 \leq 10^{+216}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -9.99999999999999947e182 or 1e216 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6474.9
Applied rewrites74.9%
if -9.99999999999999947e182 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1e216Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6468.8
Applied rewrites68.8%
Taylor expanded in y around inf
Applied rewrites57.5%
Final simplification63.3%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -1e-89) (+ (* b a) x) (if (<= (+ x y) 1e-91) (* (- a 0.5) b) (+ y (* a b)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= -1e-89) {
tmp = (b * a) + x;
} else if ((x + y) <= 1e-91) {
tmp = (a - 0.5) * b;
} else {
tmp = y + (a * b);
}
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) <= (-1d-89)) then
tmp = (b * a) + x
else if ((x + y) <= 1d-91) then
tmp = (a - 0.5d0) * b
else
tmp = y + (a * b)
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) <= -1e-89) {
tmp = (b * a) + x;
} else if ((x + y) <= 1e-91) {
tmp = (a - 0.5) * b;
} else {
tmp = y + (a * b);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x + y) <= -1e-89: tmp = (b * a) + x elif (x + y) <= 1e-91: tmp = (a - 0.5) * b else: tmp = y + (a * b) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= -1e-89) tmp = Float64(Float64(b * a) + x); elseif (Float64(x + y) <= 1e-91) tmp = Float64(Float64(a - 0.5) * b); else tmp = Float64(y + Float64(a * b)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x + y) <= -1e-89) tmp = (b * a) + x; elseif ((x + y) <= 1e-91) tmp = (a - 0.5) * b; else tmp = y + (a * b); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -1e-89], N[(N[(b * a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 1e-91], N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision], N[(y + N[(a * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -1 \cdot 10^{-89}:\\
\;\;\;\;b \cdot a + x\\
\mathbf{elif}\;x + y \leq 10^{-91}:\\
\;\;\;\;\left(a - 0.5\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;y + a \cdot b\\
\end{array}
\end{array}
if (+.f64 x y) < -1.00000000000000004e-89Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.8
Applied rewrites78.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6451.4
Applied rewrites51.4%
if -1.00000000000000004e-89 < (+.f64 x y) < 1.00000000000000002e-91Initial program 99.8%
Taylor expanded in b around inf
*-commutativeN/A
lift-*.f64N/A
lift--.f6452.4
Applied rewrites52.4%
if 1.00000000000000002e-91 < (+.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.f64100.0
Applied rewrites100.0%
Taylor expanded in a around inf
Applied rewrites89.8%
Taylor expanded in y around inf
Applied rewrites52.4%
(FPCore (x y z t a b) :precision binary64 (+ (fma (- a 0.5) b y) x))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, y) + x;
}
function code(x, y, z, t, a, b) return Float64(fma(Float64(a - 0.5), b, y) + x) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, y\right) + x
\end{array}
Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.0
Applied rewrites78.0%
(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
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.0
Applied rewrites78.0%
Taylor expanded in y around inf
Applied rewrites40.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 rewrites21.4%
(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 2025051
(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)))