
(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 (+ -0.5 a) b (fma (- 1.0 (log t)) z (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
return fma((-0.5 + a), b, fma((1.0 - log(t)), z, (y + x)));
}
function code(x, y, z, t, a, b) return fma(Float64(-0.5 + a), b, fma(Float64(1.0 - log(t)), z, Float64(y + x))) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(-0.5 + a), $MachinePrecision] * b + N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.5 + a, b, \mathsf{fma}\left(1 - \log t, z, y + x\right)\right)
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b))))
(if (<= t_1 -2e+191)
(+ x (* b a))
(if (<= t_1 -1e-113)
(+ x (* -0.5 b))
(if (<= t_1 4e+297) (fma -0.5 b y) (* (+ -0.5 a) b))))))
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 <= -2e+191) {
tmp = x + (b * a);
} else if (t_1 <= -1e-113) {
tmp = x + (-0.5 * b);
} else if (t_1 <= 4e+297) {
tmp = fma(-0.5, b, y);
} else {
tmp = (-0.5 + a) * b;
}
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 <= -2e+191) tmp = Float64(x + Float64(b * a)); elseif (t_1 <= -1e-113) tmp = Float64(x + Float64(-0.5 * b)); elseif (t_1 <= 4e+297) tmp = fma(-0.5, b, y); else tmp = Float64(Float64(-0.5 + a) * b); 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, -2e+191], N[(x + N[(b * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e-113], N[(x + N[(-0.5 * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+297], N[(-0.5 * b + y), $MachinePrecision], N[(N[(-0.5 + a), $MachinePrecision] * b), $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 -2 \cdot 10^{+191}:\\
\;\;\;\;x + b \cdot a\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-113}:\\
\;\;\;\;x + -0.5 \cdot b\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+297}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-0.5 + a\right) \cdot b\\
\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)) < -2.00000000000000015e191Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites57.6%
Taylor expanded in a around inf
*-commutativeN/A
*-commutativeN/A
lower-*.f6454.8
Applied rewrites54.8%
if -2.00000000000000015e191 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < -9.99999999999999979e-114Initial program 99.7%
Taylor expanded in x around inf
Applied rewrites49.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f6442.1
Applied rewrites42.1%
if -9.99999999999999979e-114 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < 4.0000000000000001e297Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites48.5%
Taylor expanded in a around 0
Applied rewrites36.8%
if 4.0000000000000001e297 < (+.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 b around inf
distribute-rgt-out--N/A
fp-cancel-sub-signN/A
metadata-evalN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6481.3
Applied rewrites81.3%
(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 -2e+191)
(+ x (* b a))
(if (<= t_1 -1e-113) (fma -0.5 b (+ x y)) (fma (+ -0.5 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 <= -2e+191) {
tmp = x + (b * a);
} else if (t_1 <= -1e-113) {
tmp = fma(-0.5, b, (x + y));
} else {
tmp = fma((-0.5 + 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 <= -2e+191) tmp = Float64(x + Float64(b * a)); elseif (t_1 <= -1e-113) tmp = fma(-0.5, b, Float64(x + y)); else tmp = fma(Float64(-0.5 + 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, -2e+191], N[(x + N[(b * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e-113], N[(-0.5 * b + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 + a), $MachinePrecision] * 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 -2 \cdot 10^{+191}:\\
\;\;\;\;x + b \cdot a\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-113}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 + 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)) < -2.00000000000000015e191Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites57.6%
Taylor expanded in a around inf
*-commutativeN/A
*-commutativeN/A
lower-*.f6454.8
Applied rewrites54.8%
if -2.00000000000000015e191 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < -9.99999999999999979e-114Initial program 99.7%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lower-neg.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in b around inf
*-commutativeN/A
associate--l+N/A
+-commutativeN/A
associate--r-N/A
lower-*.f64N/A
associate--r-N/A
+-commutativeN/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-/.f6489.8
Applied rewrites89.8%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-+.f6470.8
Applied rewrites70.8%
Taylor expanded in a around 0
Applied rewrites63.4%
if -9.99999999999999979e-114 < (+.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 x around 0
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites55.3%
Final simplification56.7%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))) (t_2 (* (- a 0.5) b)))
(if (<= t_2 -4e+206)
(fma (+ -0.5 a) b (* t_1 z))
(if (<= t_2 1e+100)
(+ (fma t_1 z y) (fma -0.5 b x))
(- (+ z (+ y x)) (* (- 0.5 a) b))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double t_2 = (a - 0.5) * b;
double tmp;
if (t_2 <= -4e+206) {
tmp = fma((-0.5 + a), b, (t_1 * z));
} else if (t_2 <= 1e+100) {
tmp = fma(t_1, z, y) + fma(-0.5, b, x);
} else {
tmp = (z + (y + x)) - ((0.5 - a) * b);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) t_2 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if (t_2 <= -4e+206) tmp = fma(Float64(-0.5 + a), b, Float64(t_1 * z)); elseif (t_2 <= 1e+100) tmp = Float64(fma(t_1, z, y) + fma(-0.5, b, x)); else tmp = Float64(Float64(z + Float64(y + x)) - Float64(Float64(0.5 - a) * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+206], N[(N[(-0.5 + a), $MachinePrecision] * b + N[(t$95$1 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+100], N[(N[(t$95$1 * z + y), $MachinePrecision] + N[(-0.5 * b + x), $MachinePrecision]), $MachinePrecision], N[(N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 - a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
t_2 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{+206}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 + a, b, t\_1 \cdot z\right)\\
\mathbf{elif}\;t\_2 \leq 10^{+100}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, y\right) + \mathsf{fma}\left(-0.5, b, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z + \left(y + x\right)\right) - \left(0.5 - a\right) \cdot b\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.0000000000000002e206Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in z around inf
Applied rewrites98.2%
if -4.0000000000000002e206 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1.00000000000000002e100Initial program 99.8%
Taylor expanded in a around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
+-commutativeN/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites96.2%
if 1.00000000000000002e100 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lower-neg.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
associate-*r*N/A
distribute-lft-out--N/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6490.7
Applied rewrites90.7%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)))
(if (or (<= t_1 -2e-21) (not (<= t_1 1e+100)))
(- (+ z (+ y x)) (* (- 0.5 a) b))
(fma (- 1.0 (log t)) z (+ y x)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if ((t_1 <= -2e-21) || !(t_1 <= 1e+100)) {
tmp = (z + (y + x)) - ((0.5 - a) * b);
} else {
tmp = fma((1.0 - log(t)), z, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if ((t_1 <= -2e-21) || !(t_1 <= 1e+100)) tmp = Float64(Float64(z + Float64(y + x)) - Float64(Float64(0.5 - a) * b)); else tmp = fma(Float64(1.0 - log(t)), z, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e-21], N[Not[LessEqual[t$95$1, 1e+100]], $MachinePrecision]], N[(N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 - a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-21} \lor \neg \left(t\_1 \leq 10^{+100}\right):\\
\;\;\;\;\left(z + \left(y + x\right)\right) - \left(0.5 - a\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y + x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.99999999999999982e-21 or 1.00000000000000002e100 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lower-neg.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
associate-*r*N/A
distribute-lft-out--N/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6487.5
Applied rewrites87.5%
if -1.99999999999999982e-21 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1.00000000000000002e100Initial program 99.8%
Taylor expanded in b around 0
fp-cancel-sub-sign-invN/A
associate-+r+N/A
fp-cancel-sub-sign-invN/A
*-lft-identityN/A
associate--l+N/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-rgt1-inN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
remove-double-negN/A
Applied rewrites95.0%
Final simplification90.7%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)))
(if (or (<= t_1 -2e-21) (not (<= t_1 1e+100)))
(- (+ z (+ y x)) (* (- 0.5 a) b))
(+ (fma (- 1.0 (log t)) z y) x))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if ((t_1 <= -2e-21) || !(t_1 <= 1e+100)) {
tmp = (z + (y + x)) - ((0.5 - a) * b);
} else {
tmp = fma((1.0 - log(t)), z, y) + x;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if ((t_1 <= -2e-21) || !(t_1 <= 1e+100)) tmp = Float64(Float64(z + Float64(y + x)) - Float64(Float64(0.5 - a) * b)); else tmp = Float64(fma(Float64(1.0 - log(t)), z, y) + x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e-21], N[Not[LessEqual[t$95$1, 1e+100]], $MachinePrecision]], N[(N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 - a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + y), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-21} \lor \neg \left(t\_1 \leq 10^{+100}\right):\\
\;\;\;\;\left(z + \left(y + x\right)\right) - \left(0.5 - a\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y\right) + x\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.99999999999999982e-21 or 1.00000000000000002e100 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lower-neg.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
associate-*r*N/A
distribute-lft-out--N/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6487.5
Applied rewrites87.5%
if -1.99999999999999982e-21 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1.00000000000000002e100Initial program 99.8%
Taylor expanded in b around 0
fp-cancel-sub-sign-invN/A
associate-+r+N/A
fp-cancel-sub-sign-invN/A
*-lft-identityN/A
associate--l+N/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-rgt1-inN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
remove-double-negN/A
Applied rewrites95.0%
lift-fma.f64N/A
lift-+.f64N/A
associate-+r+N/A
lower-+.f64N/A
lower-fma.f6495.0
Applied rewrites95.0%
Final simplification90.7%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -1e-113) (+ x (* (- a 0.5) b)) (fma (+ -0.5 a) 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-113) {
tmp = x + ((a - 0.5) * b);
} else {
tmp = fma((-0.5 + a), 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-113) tmp = Float64(x + Float64(Float64(a - 0.5) * b)); else tmp = fma(Float64(-0.5 + a), 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-113], N[(x + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 + a), $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^{-113}:\\
\;\;\;\;x + \left(a - 0.5\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 + a, b, y\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) < -9.99999999999999979e-114Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites54.1%
if -9.99999999999999979e-114 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites55.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)) -1e-113) x y))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((((x + y) + z) - (z * log(t))) + ((a - 0.5) * b)) <= -1e-113) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (((((x + y) + z) - (z * log(t))) + ((a - 0.5d0) * b)) <= (-1d-113)) then
tmp = x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b)) <= -1e-113) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)) <= -1e-113: tmp = x else: tmp = y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) <= -1e-113) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((((x + y) + z) - (z * log(t))) + ((a - 0.5) * b)) <= -1e-113) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], -1e-113], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \leq -1 \cdot 10^{-113}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < -9.99999999999999979e-114Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites21.1%
if -9.99999999999999979e-114 < (+.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.2%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) 2e-10) (fma (- 1.0 (log t)) z (fma (+ -0.5 a) b x)) (- (+ z (+ y x)) (* (- 0.5 a) b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= 2e-10) {
tmp = fma((1.0 - log(t)), z, fma((-0.5 + a), b, x));
} else {
tmp = (z + (y + x)) - ((0.5 - a) * b);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= 2e-10) tmp = fma(Float64(1.0 - log(t)), z, fma(Float64(-0.5 + a), b, x)); else tmp = Float64(Float64(z + Float64(y + x)) - Float64(Float64(0.5 - a) * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], 2e-10], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(N[(-0.5 + a), $MachinePrecision] * b + x), $MachinePrecision]), $MachinePrecision], N[(N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 - a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(-0.5 + a, b, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z + \left(y + x\right)\right) - \left(0.5 - a\right) \cdot b\\
\end{array}
\end{array}
if (+.f64 x y) < 2.00000000000000007e-10Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites82.2%
if 2.00000000000000007e-10 < (+.f64 x y) Initial program 100.0%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lower-neg.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
associate-*r*N/A
distribute-lft-out--N/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6488.2
Applied rewrites88.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -1.05e+180) (not (<= z 3.9e+168))) (fma (- 1.0 (log t)) z x) (- (+ z (+ y x)) (* (- 0.5 a) b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -1.05e+180) || !(z <= 3.9e+168)) {
tmp = fma((1.0 - log(t)), z, x);
} else {
tmp = (z + (y + x)) - ((0.5 - a) * b);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -1.05e+180) || !(z <= 3.9e+168)) tmp = fma(Float64(1.0 - log(t)), z, x); else tmp = Float64(Float64(z + Float64(y + x)) - Float64(Float64(0.5 - a) * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -1.05e+180], N[Not[LessEqual[z, 3.9e+168]], $MachinePrecision]], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 - a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+180} \lor \neg \left(z \leq 3.9 \cdot 10^{+168}\right):\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z + \left(y + x\right)\right) - \left(0.5 - a\right) \cdot b\\
\end{array}
\end{array}
if z < -1.05e180 or 3.89999999999999999e168 < z Initial program 99.6%
Taylor expanded in b around 0
fp-cancel-sub-sign-invN/A
associate-+r+N/A
fp-cancel-sub-sign-invN/A
*-lft-identityN/A
associate--l+N/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-rgt1-inN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
remove-double-negN/A
Applied rewrites73.8%
Taylor expanded in x around inf
Applied rewrites69.2%
if -1.05e180 < z < 3.89999999999999999e168Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lower-neg.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
associate-*r*N/A
distribute-lft-out--N/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6490.3
Applied rewrites90.3%
Final simplification86.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -2.1e+182) (not (<= z 1.1e+229))) (* (- 1.0 (log t)) z) (- (+ z (+ y x)) (* (- 0.5 a) b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -2.1e+182) || !(z <= 1.1e+229)) {
tmp = (1.0 - log(t)) * z;
} else {
tmp = (z + (y + x)) - ((0.5 - 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 ((z <= (-2.1d+182)) .or. (.not. (z <= 1.1d+229))) then
tmp = (1.0d0 - log(t)) * z
else
tmp = (z + (y + x)) - ((0.5d0 - 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 ((z <= -2.1e+182) || !(z <= 1.1e+229)) {
tmp = (1.0 - Math.log(t)) * z;
} else {
tmp = (z + (y + x)) - ((0.5 - a) * b);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z <= -2.1e+182) or not (z <= 1.1e+229): tmp = (1.0 - math.log(t)) * z else: tmp = (z + (y + x)) - ((0.5 - a) * b) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -2.1e+182) || !(z <= 1.1e+229)) tmp = Float64(Float64(1.0 - log(t)) * z); else tmp = Float64(Float64(z + Float64(y + x)) - Float64(Float64(0.5 - a) * b)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((z <= -2.1e+182) || ~((z <= 1.1e+229))) tmp = (1.0 - log(t)) * z; else tmp = (z + (y + x)) - ((0.5 - a) * b); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -2.1e+182], N[Not[LessEqual[z, 1.1e+229]], $MachinePrecision]], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 - a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{+182} \lor \neg \left(z \leq 1.1 \cdot 10^{+229}\right):\\
\;\;\;\;\left(1 - \log t\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left(z + \left(y + x\right)\right) - \left(0.5 - a\right) \cdot b\\
\end{array}
\end{array}
if z < -2.0999999999999999e182 or 1.10000000000000002e229 < z Initial program 99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6466.3
Applied rewrites66.3%
if -2.0999999999999999e182 < z < 1.10000000000000002e229Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lower-neg.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
associate-*r*N/A
distribute-lft-out--N/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6489.2
Applied rewrites89.2%
Final simplification85.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b))) (if (or (<= t_1 -4e+206) (not (<= t_1 1e+213))) (* (+ -0.5 a) b) (+ 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 <= -4e+206) || !(t_1 <= 1e+213)) {
tmp = (-0.5 + a) * b;
} 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 <= (-4d+206)) .or. (.not. (t_1 <= 1d+213))) then
tmp = ((-0.5d0) + a) * b
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 <= -4e+206) || !(t_1 <= 1e+213)) {
tmp = (-0.5 + a) * b;
} 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 <= -4e+206) or not (t_1 <= 1e+213): tmp = (-0.5 + a) * b 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 <= -4e+206) || !(t_1 <= 1e+213)) tmp = Float64(Float64(-0.5 + a) * b); 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 <= -4e+206) || ~((t_1 <= 1e+213))) tmp = (-0.5 + a) * b; 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, -4e+206], N[Not[LessEqual[t$95$1, 1e+213]], $MachinePrecision]], N[(N[(-0.5 + a), $MachinePrecision] * b), $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 -4 \cdot 10^{+206} \lor \neg \left(t\_1 \leq 10^{+213}\right):\\
\;\;\;\;\left(-0.5 + a\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.0000000000000002e206 or 9.99999999999999984e212 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in b around inf
distribute-rgt-out--N/A
fp-cancel-sub-signN/A
metadata-evalN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6485.4
Applied rewrites85.4%
if -4.0000000000000002e206 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 9.99999999999999984e212Initial program 99.8%
Taylor expanded in b around 0
fp-cancel-sub-sign-invN/A
associate-+r+N/A
fp-cancel-sub-sign-invN/A
*-lft-identityN/A
associate--l+N/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-rgt1-inN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
remove-double-negN/A
Applied rewrites83.1%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f6459.1
Applied rewrites59.1%
Final simplification66.2%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b))) (if (or (<= t_1 -4e+206) (not (<= t_1 4e+247))) (* 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 <= -4e+206) || !(t_1 <= 4e+247)) {
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 <= (-4d+206)) .or. (.not. (t_1 <= 4d+247))) 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 <= -4e+206) || !(t_1 <= 4e+247)) {
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 <= -4e+206) or not (t_1 <= 4e+247): 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 <= -4e+206) || !(t_1 <= 4e+247)) 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 <= -4e+206) || ~((t_1 <= 4e+247))) 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, -4e+206], N[Not[LessEqual[t$95$1, 4e+247]], $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 -4 \cdot 10^{+206} \lor \neg \left(t\_1 \leq 4 \cdot 10^{+247}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.0000000000000002e206 or 3.99999999999999981e247 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6481.4
Applied rewrites81.4%
if -4.0000000000000002e206 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 3.99999999999999981e247Initial program 99.8%
Taylor expanded in b around 0
fp-cancel-sub-sign-invN/A
associate-+r+N/A
fp-cancel-sub-sign-invN/A
*-lft-identityN/A
associate--l+N/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-rgt1-inN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
remove-double-negN/A
Applied rewrites81.1%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f6456.8
Applied rewrites56.8%
Final simplification62.4%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -2e+51) (+ x (* b a)) (fma (+ -0.5 a) b y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= -2e+51) {
tmp = x + (b * a);
} else {
tmp = fma((-0.5 + a), b, y);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= -2e+51) tmp = Float64(x + Float64(b * a)); else tmp = fma(Float64(-0.5 + a), b, y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -2e+51], N[(x + N[(b * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 + a), $MachinePrecision] * b + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -2 \cdot 10^{+51}:\\
\;\;\;\;x + b \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 + a, b, y\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -2e51Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites51.4%
Taylor expanded in a around inf
*-commutativeN/A
*-commutativeN/A
lower-*.f6444.1
Applied rewrites44.1%
if -2e51 < (+.f64 x y) Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites56.2%
(FPCore (x y z t a b) :precision binary64 (- (+ z (+ y x)) (* (- 0.5 a) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (z + (y + x)) - ((0.5 - a) * 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 = (z + (y + x)) - ((0.5d0 - a) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (z + (y + x)) - ((0.5 - a) * b);
}
def code(x, y, z, t, a, b): return (z + (y + x)) - ((0.5 - a) * b)
function code(x, y, z, t, a, b) return Float64(Float64(z + Float64(y + x)) - Float64(Float64(0.5 - a) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = (z + (y + x)) - ((0.5 - a) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 - a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(z + \left(y + x\right)\right) - \left(0.5 - a\right) \cdot b
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lower-neg.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
associate-*r*N/A
distribute-lft-out--N/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6479.2
Applied rewrites79.2%
(FPCore (x y z t a b) :precision binary64 (fma (- a 0.5) b (+ y x)))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, (y + x));
}
function code(x, y, z, t, a, b) return fma(Float64(a - 0.5), b, Float64(y + x)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, y + x\right)
\end{array}
Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6478.4
Applied rewrites78.4%
(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 b around 0
fp-cancel-sub-sign-invN/A
associate-+r+N/A
fp-cancel-sub-sign-invN/A
*-lft-identityN/A
associate--l+N/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-rgt1-inN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
remove-double-negN/A
Applied rewrites64.2%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f6444.6
Applied rewrites44.6%
(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 rewrites24.0%
(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 2025026
(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)))