
(FPCore (x y z t a b) :precision binary64 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (((x + y) + z) - (z * log(t))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return (((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\end{array}
Herbie found 16 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 (- (- (log t)) -1.0) z (fma b (- a 0.5) (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
return fma((-log(t) - -1.0), z, fma(b, (a - 0.5), (y + x)));
}
function code(x, y, z, t, a, b) return fma(Float64(Float64(-log(t)) - -1.0), z, fma(b, Float64(a - 0.5), Float64(y + x))) end
code[x_, y_, z_, t_, a_, b_] := N[(N[((-N[Log[t], $MachinePrecision]) - -1.0), $MachinePrecision] * z + N[(b * N[(a - 0.5), $MachinePrecision] + N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(-\log t\right) - -1, z, \mathsf{fma}\left(b, a - 0.5, y + x\right)\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-fma.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites99.9%
(FPCore (x y z t a b) :precision binary64 (+ x (+ y (fma b (- a 0.5) (* z (- 1.0 (log t)))))))
double code(double x, double y, double z, double t, double a, double b) {
return x + (y + fma(b, (a - 0.5), (z * (1.0 - log(t)))));
}
function code(x, y, z, t, a, b) return Float64(x + Float64(y + fma(b, Float64(a - 0.5), Float64(z * Float64(1.0 - log(t)))))) end
code[x_, y_, z_, t_, a_, b_] := N[(x + N[(y + N[(b * N[(a - 0.5), $MachinePrecision] + N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y + \mathsf{fma}\left(b, a - 0.5, z \cdot \left(1 - \log t\right)\right)\right)
\end{array}
Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6499.9
Applied rewrites99.9%
(FPCore (x y z t a b) :precision binary64 (- x (fma (- 0.5 a) b (- (- (* (log t) z) z) y))))
double code(double x, double y, double z, double t, double a, double b) {
return x - fma((0.5 - a), b, (((log(t) * z) - z) - y));
}
function code(x, y, z, t, a, b) return Float64(x - fma(Float64(0.5 - a), b, Float64(Float64(Float64(log(t) * z) - z) - y))) end
code[x_, y_, z_, t_, a_, b_] := N[(x - N[(N[(0.5 - a), $MachinePrecision] * b + N[(N[(N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \mathsf{fma}\left(0.5 - a, b, \left(\log t \cdot z - z\right) - y\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate--l+N/A
add-flipN/A
sub-negate-revN/A
lower--.f64N/A
sub-negate-revN/A
associate--l+N/A
associate--r-N/A
add-flip-revN/A
distribute-neg-outN/A
Applied rewrites99.9%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -1e-64) (- (+ x (+ z (* b (- a 0.5)))) (* z (log t))) (fma (- 1.0 (log t)) z (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) <= -1e-64) {
tmp = (x + (z + (b * (a - 0.5)))) - (z * log(t));
} else {
tmp = fma((1.0 - log(t)), z, fma((a - 0.5), b, y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= -1e-64) tmp = Float64(Float64(x + Float64(z + Float64(b * Float64(a - 0.5)))) - Float64(z * log(t))); else tmp = fma(Float64(1.0 - log(t)), z, fma(Float64(a - 0.5), b, y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -1e-64], N[(N[(x + N[(z + N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -1 \cdot 10^{-64}:\\
\;\;\;\;\left(x + \left(z + b \cdot \left(a - 0.5\right)\right)\right) - z \cdot \log t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y\right)\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -9.99999999999999965e-65Initial program 99.9%
Taylor expanded in y around 0
lower--.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f6479.2
Applied rewrites79.2%
if -9.99999999999999965e-65 < (+.f64 x y) Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f6477.8
Applied rewrites77.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
Applied rewrites77.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -0.5) (fma (- a 0.5) b (+ y x)) (fma (- 1.0 (log t)) z (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) <= -0.5) {
tmp = fma((a - 0.5), b, (y + x));
} else {
tmp = fma((1.0 - log(t)), z, fma((a - 0.5), b, y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= -0.5) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); else tmp = fma(Float64(1.0 - log(t)), z, fma(Float64(a - 0.5), b, y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -0.5], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -0.5:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y\right)\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -0.5Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.4%
if -0.5 < (+.f64 x y) Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f6477.8
Applied rewrites77.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
Applied rewrites77.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)) (t_2 (fma (- a 0.5) b (+ y x))))
(if (<= t_1 -5e+100)
t_2
(if (<= t_1 2e+30) (+ (fma (- 1.0 (log t)) z y) x) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double t_2 = fma((a - 0.5), b, (y + x));
double tmp;
if (t_1 <= -5e+100) {
tmp = t_2;
} else if (t_1 <= 2e+30) {
tmp = fma((1.0 - log(t)), z, y) + x;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) t_2 = fma(Float64(a - 0.5), b, Float64(y + x)) tmp = 0.0 if (t_1 <= -5e+100) tmp = t_2; elseif (t_1 <= 2e+30) tmp = Float64(fma(Float64(1.0 - log(t)), z, y) + x); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+100], t$95$2, If[LessEqual[t$95$1, 2e+30], N[(N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + y), $MachinePrecision] + x), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
t_2 := \mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+100}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+30}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.9999999999999999e100 or 2e30 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.4%
if -4.9999999999999999e100 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e30Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6499.9
Applied rewrites99.9%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6462.9
Applied rewrites62.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6462.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6462.9
Applied rewrites62.9%
(FPCore (x y z t a b) :precision binary64 (if (<= z -3.5e+214) (+ x (* z (- 1.0 (log t)))) (if (<= z 5.2e+225) (fma (- a 0.5) b (+ y x)) (- (+ y z) (* z (log t))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -3.5e+214) {
tmp = x + (z * (1.0 - log(t)));
} else if (z <= 5.2e+225) {
tmp = fma((a - 0.5), b, (y + x));
} else {
tmp = (y + z) - (z * log(t));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -3.5e+214) tmp = Float64(x + Float64(z * Float64(1.0 - log(t)))); elseif (z <= 5.2e+225) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); else tmp = Float64(Float64(y + z) - Float64(z * log(t))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -3.5e+214], N[(x + N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.2e+225], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(y + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{+214}:\\
\;\;\;\;x + z \cdot \left(1 - \log t\right)\\
\mathbf{elif}\;z \leq 5.2 \cdot 10^{+225}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + z\right) - z \cdot \log t\\
\end{array}
\end{array}
if z < -3.5e214Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6499.9
Applied rewrites99.9%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6462.9
Applied rewrites62.9%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f64N/A
lower-log.f6442.9
Applied rewrites42.9%
if -3.5e214 < z < 5.20000000000000009e225Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.4%
if 5.20000000000000009e225 < z Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f6477.8
Applied rewrites77.8%
Taylor expanded in b around 0
lower-+.f6441.4
Applied rewrites41.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ x (* z (- 1.0 (log t))))))
(if (<= z -3.5e+214)
t_1
(if (<= z 9.2e+225) (fma (- a 0.5) b (+ y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x + (z * (1.0 - log(t)));
double tmp;
if (z <= -3.5e+214) {
tmp = t_1;
} else if (z <= 9.2e+225) {
tmp = fma((a - 0.5), b, (y + x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(x + Float64(z * Float64(1.0 - log(t)))) tmp = 0.0 if (z <= -3.5e+214) tmp = t_1; elseif (z <= 9.2e+225) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x + N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.5e+214], t$95$1, If[LessEqual[z, 9.2e+225], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + z \cdot \left(1 - \log t\right)\\
\mathbf{if}\;z \leq -3.5 \cdot 10^{+214}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{+225}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.5e214 or 9.1999999999999998e225 < z Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6499.9
Applied rewrites99.9%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6462.9
Applied rewrites62.9%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f64N/A
lower-log.f6442.9
Applied rewrites42.9%
if -3.5e214 < z < 9.1999999999999998e225Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* z (- 1.0 (log t)))))
(if (<= z -7.4e+264)
t_1
(if (<= z 9.2e+225) (fma (- a 0.5) b (+ y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = z * (1.0 - log(t));
double tmp;
if (z <= -7.4e+264) {
tmp = t_1;
} else if (z <= 9.2e+225) {
tmp = fma((a - 0.5), b, (y + x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(z * Float64(1.0 - log(t))) tmp = 0.0 if (z <= -7.4e+264) tmp = t_1; elseif (z <= 9.2e+225) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.4e+264], t$95$1, If[LessEqual[z, 9.2e+225], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(1 - \log t\right)\\
\mathbf{if}\;z \leq -7.4 \cdot 10^{+264}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{+225}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -7.3999999999999998e264 or 9.1999999999999998e225 < z Initial program 99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f64N/A
lower-log.f6421.7
Applied rewrites21.7%
if -7.3999999999999998e264 < z < 9.1999999999999998e225Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.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 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
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.4%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -5e-70) (+ x (* b (- a 0.5))) (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-70) {
tmp = x + (b * (a - 0.5));
} 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-70) tmp = Float64(x + Float64(b * Float64(a - 0.5))); 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-70], N[(x + N[(b * N[(a - 0.5), $MachinePrecision]), $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^{-70}:\\
\;\;\;\;x + b \cdot \left(a - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) < -4.9999999999999998e-70Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f6459.2
Applied rewrites59.2%
if -4.9999999999999998e-70 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.4%
Taylor expanded in x around 0
Applied rewrites57.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (- a 0.5) b y))) (if (<= a -1.62e+63) t_1 (if (<= a 8.5e+17) (fma -0.5 b (+ y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((a - 0.5), b, y);
double tmp;
if (a <= -1.62e+63) {
tmp = t_1;
} else if (a <= 8.5e+17) {
tmp = fma(-0.5, b, (y + x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(a - 0.5), b, y) tmp = 0.0 if (a <= -1.62e+63) tmp = t_1; elseif (a <= 8.5e+17) tmp = fma(-0.5, b, Float64(y + x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]}, If[LessEqual[a, -1.62e+63], t$95$1, If[LessEqual[a, 8.5e+17], N[(-0.5 * b + N[(y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a - 0.5, b, y\right)\\
\mathbf{if}\;a \leq -1.62 \cdot 10^{+63}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 8.5 \cdot 10^{+17}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -1.62e63 or 8.5e17 < a Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.4%
Taylor expanded in x around 0
Applied rewrites57.8%
if -1.62e63 < a < 8.5e17Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.4%
Taylor expanded in a around 0
Applied rewrites54.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b)) (t_2 (fma (- a 0.5) b y))) (if (<= t_1 -5e+78) t_2 (if (<= t_1 2e+21) (+ x y) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double t_2 = fma((a - 0.5), b, y);
double tmp;
if (t_1 <= -5e+78) {
tmp = t_2;
} else if (t_1 <= 2e+21) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) t_2 = fma(Float64(a - 0.5), b, y) tmp = 0.0 if (t_1 <= -5e+78) tmp = t_2; elseif (t_1 <= 2e+21) tmp = Float64(x + y); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+78], t$95$2, If[LessEqual[t$95$1, 2e+21], N[(x + y), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
t_2 := \mathsf{fma}\left(a - 0.5, b, y\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+78}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+21}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.99999999999999984e78 or 2e21 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.4%
Taylor expanded in x around 0
Applied rewrites57.8%
if -4.99999999999999984e78 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e21Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
Taylor expanded in b around 0
lower-+.f6442.9
Applied rewrites42.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b)) (t_2 (* b (- a 0.5)))) (if (<= t_1 -5e+78) t_2 (if (<= t_1 5e+101) (+ x y) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double t_2 = b * (a - 0.5);
double tmp;
if (t_1 <= -5e+78) {
tmp = t_2;
} else if (t_1 <= 5e+101) {
tmp = x + y;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_1 = (a - 0.5d0) * b
t_2 = b * (a - 0.5d0)
if (t_1 <= (-5d+78)) then
tmp = t_2
else if (t_1 <= 5d+101) then
tmp = x + y
else
tmp = t_2
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 t_2 = b * (a - 0.5);
double tmp;
if (t_1 <= -5e+78) {
tmp = t_2;
} else if (t_1 <= 5e+101) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a - 0.5) * b t_2 = b * (a - 0.5) tmp = 0 if t_1 <= -5e+78: tmp = t_2 elif t_1 <= 5e+101: tmp = x + y else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) t_2 = Float64(b * Float64(a - 0.5)) tmp = 0.0 if (t_1 <= -5e+78) tmp = t_2; elseif (t_1 <= 5e+101) tmp = Float64(x + y); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a - 0.5) * b; t_2 = b * (a - 0.5); tmp = 0.0; if (t_1 <= -5e+78) tmp = t_2; elseif (t_1 <= 5e+101) tmp = x + y; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+78], t$95$2, If[LessEqual[t$95$1, 5e+101], N[(x + y), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
t_2 := b \cdot \left(a - 0.5\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+78}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+101}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.99999999999999984e78 or 4.99999999999999989e101 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6479.4
Applied rewrites79.4%
Taylor expanded in b around inf
lower-*.f64N/A
lower--.f6438.0
Applied rewrites38.0%
if -4.99999999999999984e78 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 4.99999999999999989e101Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
Taylor expanded in b around 0
lower-+.f6442.9
Applied rewrites42.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b))) (if (<= t_1 -4e+194) (* a b) (if (<= t_1 1e+229) (+ x y) (* a b)))))
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+194) {
tmp = a * b;
} else if (t_1 <= 1e+229) {
tmp = x + y;
} else {
tmp = 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) :: t_1
real(8) :: tmp
t_1 = (a - 0.5d0) * b
if (t_1 <= (-4d+194)) then
tmp = a * b
else if (t_1 <= 1d+229) then
tmp = x + y
else
tmp = 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 t_1 = (a - 0.5) * b;
double tmp;
if (t_1 <= -4e+194) {
tmp = a * b;
} else if (t_1 <= 1e+229) {
tmp = x + y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a - 0.5) * b tmp = 0 if t_1 <= -4e+194: tmp = a * b elif t_1 <= 1e+229: tmp = x + y else: tmp = a * b 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+194) tmp = Float64(a * b); elseif (t_1 <= 1e+229) tmp = Float64(x + y); else tmp = Float64(a * b); 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+194) tmp = a * b; elseif (t_1 <= 1e+229) tmp = x + y; else tmp = a * b; 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[LessEqual[t$95$1, -4e+194], N[(a * b), $MachinePrecision], If[LessEqual[t$95$1, 1e+229], N[(x + y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+194}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;t\_1 \leq 10^{+229}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -3.99999999999999978e194 or 9.9999999999999999e228 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in a around inf
lower-*.f6426.4
Applied rewrites26.4%
if -3.99999999999999978e194 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 9.9999999999999999e228Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
Taylor expanded in b around 0
lower-+.f6442.9
Applied rewrites42.9%
(FPCore (x y z t a b) :precision binary64 (+ x y))
double code(double x, double y, double z, double t, double a, double b) {
return x + y;
}
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
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x + y;
}
def code(x, y, z, t, a, b): return x + y
function code(x, y, z, t, a, b) return Float64(x + y) end
function tmp = code(x, y, z, t, a, b) tmp = x + y; end
code[x_, y_, z_, t_, a_, b_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 99.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6479.4
Applied rewrites79.4%
Taylor expanded in b around 0
lower-+.f6442.9
Applied rewrites42.9%
herbie shell --seed 2025143
(FPCore (x y z t a b)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, A"
:precision binary64
(+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))