
(FPCore (x y z t a b) :precision binary64 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))
double code(double x, double y, double z, double t, double a, double b) {
return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
}
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) / t)) / ((a + 1.0d0) + ((y * b) / t))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
}
def code(x, y, z, t, a, b): return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t))
function code(x, y, z, t, a, b) return Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t))) end
function tmp = code(x, y, z, t, a, b) tmp = (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))
double code(double x, double y, double z, double t, double a, double b) {
return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
}
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) / t)) / ((a + 1.0d0) + ((y * b) / t))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
}
def code(x, y, z, t, a, b): return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t))
function code(x, y, z, t, a, b) return Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t))) end
function tmp = code(x, y, z, t, a, b) tmp = (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\end{array}
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t)))))
(if (<= t_1 (- INFINITY))
(fma y (/ z (fma b y (* t (+ 1.0 a)))) (/ x a))
(if (<= t_1 -1e-321)
t_1
(if (<= t_1 0.0)
(fma (/ (/ x b) y) t (/ z b))
(if (<= t_1 2e+302) t_1 (/ (+ z (/ (* t x) y)) b)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma(y, (z / fma(b, y, (t * (1.0 + a)))), (x / a));
} else if (t_1 <= -1e-321) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = fma(((x / b) / y), t, (z / b));
} else if (t_1 <= 2e+302) {
tmp = t_1;
} else {
tmp = (z + ((t * x) / y)) / b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = fma(y, Float64(z / fma(b, y, Float64(t * Float64(1.0 + a)))), Float64(x / a)); elseif (t_1 <= -1e-321) tmp = t_1; elseif (t_1 <= 0.0) tmp = fma(Float64(Float64(x / b) / y), t, Float64(z / b)); elseif (t_1 <= 2e+302) tmp = t_1; else tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(y * N[(z / N[(b * y + N[(t * N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e-321], t$95$1, If[LessEqual[t$95$1, 0.0], N[(N[(N[(x / b), $MachinePrecision] / y), $MachinePrecision] * t + N[(z / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+302], t$95$1, N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{\mathsf{fma}\left(b, y, t \cdot \left(1 + a\right)\right)}, \frac{x}{a}\right)\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-321}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{x}{b}}{y}, t, \frac{z}{b}\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+302}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < -inf.0Initial program 34.2%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
div-addN/A
+-commutativeN/A
*-commutativeN/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
associate-+r+N/A
Applied rewrites66.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lift-+.f6490.2
Applied rewrites90.2%
Taylor expanded in a around inf
Applied rewrites74.3%
if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < -9.98013e-322 or -0.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 2.0000000000000002e302Initial program 99.2%
if -9.98013e-322 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < -0.0Initial program 53.9%
Taylor expanded in t around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites69.6%
Taylor expanded in x around inf
lift-/.f6471.6
Applied rewrites71.6%
if 2.0000000000000002e302 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) Initial program 12.9%
Taylor expanded in t around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites52.3%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6478.3
Applied rewrites78.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ x (/ (* y z) t)))
(t_2 (/ t_1 (+ 1.0 a)))
(t_3 (/ t_1 (+ (+ a 1.0) (/ (* y b) t)))))
(if (<= t_3 (- INFINITY))
(fma y (/ z (fma b y (* t (+ 1.0 a)))) (/ x a))
(if (<= t_3 -1e-321)
t_2
(if (<= t_3 2e-307)
(fma (/ (/ x b) y) t (/ z b))
(if (<= t_3 2e+302) t_2 (/ (+ z (/ (* t x) y)) b)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x + ((y * z) / t);
double t_2 = t_1 / (1.0 + a);
double t_3 = t_1 / ((a + 1.0) + ((y * b) / t));
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = fma(y, (z / fma(b, y, (t * (1.0 + a)))), (x / a));
} else if (t_3 <= -1e-321) {
tmp = t_2;
} else if (t_3 <= 2e-307) {
tmp = fma(((x / b) / y), t, (z / b));
} else if (t_3 <= 2e+302) {
tmp = t_2;
} else {
tmp = (z + ((t * x) / y)) / b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(x + Float64(Float64(y * z) / t)) t_2 = Float64(t_1 / Float64(1.0 + a)) t_3 = Float64(t_1 / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t))) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = fma(y, Float64(z / fma(b, y, Float64(t * Float64(1.0 + a)))), Float64(x / a)); elseif (t_3 <= -1e-321) tmp = t_2; elseif (t_3 <= 2e-307) tmp = fma(Float64(Float64(x / b) / y), t, Float64(z / b)); elseif (t_3 <= 2e+302) tmp = t_2; else tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(1.0 + a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(y * N[(z / N[(b * y + N[(t * N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -1e-321], t$95$2, If[LessEqual[t$95$3, 2e-307], N[(N[(N[(x / b), $MachinePrecision] / y), $MachinePrecision] * t + N[(z / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2e+302], t$95$2, N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{y \cdot z}{t}\\
t_2 := \frac{t\_1}{1 + a}\\
t_3 := \frac{t\_1}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{\mathsf{fma}\left(b, y, t \cdot \left(1 + a\right)\right)}, \frac{x}{a}\right)\\
\mathbf{elif}\;t\_3 \leq -1 \cdot 10^{-321}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-307}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{x}{b}}{y}, t, \frac{z}{b}\right)\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{+302}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < -inf.0Initial program 34.2%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
div-addN/A
+-commutativeN/A
*-commutativeN/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
associate-+r+N/A
Applied rewrites66.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lift-+.f6490.2
Applied rewrites90.2%
Taylor expanded in a around inf
Applied rewrites74.3%
if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < -9.98013e-322 or 1.99999999999999982e-307 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 2.0000000000000002e302Initial program 99.2%
Taylor expanded in y around 0
lower-+.f6476.5
Applied rewrites76.5%
if -9.98013e-322 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 1.99999999999999982e-307Initial program 54.9%
Taylor expanded in t around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.3%
Taylor expanded in x around inf
lift-/.f6470.3
Applied rewrites70.3%
if 2.0000000000000002e302 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) Initial program 12.9%
Taylor expanded in t around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites52.3%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6478.3
Applied rewrites78.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ x (/ (* y z) t))) (t_2 (/ t_1 (+ (+ a 1.0) (/ (* y b) t)))))
(if (<= t_2 -1e-321)
(+ (/ x (+ 1.0 a)) (* (/ y t) (/ z (+ 1.0 a))))
(if (<= t_2 2e-307)
(fma (/ (/ x b) y) t (/ z b))
(if (<= t_2 2e+302) (/ t_1 (+ 1.0 a)) (/ (+ z (/ (* t x) y)) b))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x + ((y * z) / t);
double t_2 = t_1 / ((a + 1.0) + ((y * b) / t));
double tmp;
if (t_2 <= -1e-321) {
tmp = (x / (1.0 + a)) + ((y / t) * (z / (1.0 + a)));
} else if (t_2 <= 2e-307) {
tmp = fma(((x / b) / y), t, (z / b));
} else if (t_2 <= 2e+302) {
tmp = t_1 / (1.0 + a);
} else {
tmp = (z + ((t * x) / y)) / b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(x + Float64(Float64(y * z) / t)) t_2 = Float64(t_1 / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t))) tmp = 0.0 if (t_2 <= -1e-321) tmp = Float64(Float64(x / Float64(1.0 + a)) + Float64(Float64(y / t) * Float64(z / Float64(1.0 + a)))); elseif (t_2 <= 2e-307) tmp = fma(Float64(Float64(x / b) / y), t, Float64(z / b)); elseif (t_2 <= 2e+302) tmp = Float64(t_1 / Float64(1.0 + a)); else tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e-321], N[(N[(x / N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(y / t), $MachinePrecision] * N[(z / N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e-307], N[(N[(N[(x / b), $MachinePrecision] / y), $MachinePrecision] * t + N[(z / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+302], N[(t$95$1 / N[(1.0 + a), $MachinePrecision]), $MachinePrecision], N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{y \cdot z}{t}\\
t_2 := \frac{t\_1}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{-321}:\\
\;\;\;\;\frac{x}{1 + a} + \frac{y}{t} \cdot \frac{z}{1 + a}\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-307}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{x}{b}}{y}, t, \frac{z}{b}\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+302}:\\
\;\;\;\;\frac{t\_1}{1 + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < -9.98013e-322Initial program 89.3%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
div-addN/A
+-commutativeN/A
*-commutativeN/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
associate-+r+N/A
Applied rewrites91.2%
Taylor expanded in b around 0
lower-+.f64N/A
lower-/.f64N/A
lift-+.f64N/A
times-fracN/A
lower-*.f64N/A
lift-/.f64N/A
lower-/.f64N/A
lift-+.f6470.9
Applied rewrites70.9%
if -9.98013e-322 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 1.99999999999999982e-307Initial program 54.9%
Taylor expanded in t around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.3%
Taylor expanded in x around inf
lift-/.f6470.3
Applied rewrites70.3%
if 1.99999999999999982e-307 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 2.0000000000000002e302Initial program 99.3%
Taylor expanded in y around 0
lower-+.f6477.6
Applied rewrites77.6%
if 2.0000000000000002e302 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) Initial program 12.9%
Taylor expanded in t around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites52.3%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6478.3
Applied rewrites78.3%
(FPCore (x y z t a b) :precision binary64 (if (<= (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))) INFINITY) (fma y (/ z (fma b y (* t (+ 1.0 a)))) (/ x (fma b (/ y t) (+ 1.0 a)))) (/ (+ z (/ (* t x) y)) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t))) <= ((double) INFINITY)) {
tmp = fma(y, (z / fma(b, y, (t * (1.0 + a)))), (x / fma(b, (y / t), (1.0 + a))));
} else {
tmp = (z + ((t * x) / y)) / b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t))) <= Inf) tmp = fma(y, Float64(z / fma(b, y, Float64(t * Float64(1.0 + a)))), Float64(x / fma(b, Float64(y / t), Float64(1.0 + a)))); else tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(y * N[(z / N[(b * y + N[(t * N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x / N[(b * N[(y / t), $MachinePrecision] + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{\mathsf{fma}\left(b, y, t \cdot \left(1 + a\right)\right)}, \frac{x}{\mathsf{fma}\left(b, \frac{y}{t}, 1 + a\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < +inf.0Initial program 82.9%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
div-addN/A
+-commutativeN/A
*-commutativeN/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
associate-+r+N/A
Applied rewrites83.2%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lift-+.f6488.7
Applied rewrites88.7%
if +inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) Initial program 0.0%
Taylor expanded in t around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.1%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6492.6
Applied rewrites92.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (+ z (/ (* t x) y)) b)))
(if (<= y -6e+49)
t_1
(if (<= y 0.0215) (/ (+ x (/ (* y z) t)) (+ 1.0 a)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z + ((t * x) / y)) / b;
double tmp;
if (y <= -6e+49) {
tmp = t_1;
} else if (y <= 0.0215) {
tmp = (x + ((y * z) / t)) / (1.0 + a);
} else {
tmp = t_1;
}
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 = (z + ((t * x) / y)) / b
if (y <= (-6d+49)) then
tmp = t_1
else if (y <= 0.0215d0) then
tmp = (x + ((y * z) / t)) / (1.0d0 + a)
else
tmp = t_1
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 = (z + ((t * x) / y)) / b;
double tmp;
if (y <= -6e+49) {
tmp = t_1;
} else if (y <= 0.0215) {
tmp = (x + ((y * z) / t)) / (1.0 + a);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (z + ((t * x) / y)) / b tmp = 0 if y <= -6e+49: tmp = t_1 elif y <= 0.0215: tmp = (x + ((y * z) / t)) / (1.0 + a) else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(z + Float64(Float64(t * x) / y)) / b) tmp = 0.0 if (y <= -6e+49) tmp = t_1; elseif (y <= 0.0215) tmp = Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(1.0 + a)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (z + ((t * x) / y)) / b; tmp = 0.0; if (y <= -6e+49) tmp = t_1; elseif (y <= 0.0215) tmp = (x + ((y * z) / t)) / (1.0 + a); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]}, If[LessEqual[y, -6e+49], t$95$1, If[LessEqual[y, 0.0215], N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(1.0 + a), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z + \frac{t \cdot x}{y}}{b}\\
\mathbf{if}\;y \leq -6 \cdot 10^{+49}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 0.0215:\\
\;\;\;\;\frac{x + \frac{y \cdot z}{t}}{1 + a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -6.0000000000000005e49 or 0.021499999999999998 < y Initial program 53.9%
Taylor expanded in t around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.5%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
if -6.0000000000000005e49 < y < 0.021499999999999998Initial program 92.4%
Taylor expanded in y around 0
lower-+.f6475.3
Applied rewrites75.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (fma y (/ z t) x) (+ 1.0 a))))
(if (<= t -4.8e+38)
t_1
(if (<= t 1.75e-118) (/ (+ z (/ (* t x) y)) b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(y, (z / t), x) / (1.0 + a);
double tmp;
if (t <= -4.8e+38) {
tmp = t_1;
} else if (t <= 1.75e-118) {
tmp = (z + ((t * x) / y)) / b;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(y, Float64(z / t), x) / Float64(1.0 + a)) tmp = 0.0 if (t <= -4.8e+38) tmp = t_1; elseif (t <= 1.75e-118) tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision] / N[(1.0 + a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -4.8e+38], t$95$1, If[LessEqual[t, 1.75e-118], N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\mathsf{fma}\left(y, \frac{z}{t}, x\right)}{1 + a}\\
\mathbf{if}\;t \leq -4.8 \cdot 10^{+38}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.75 \cdot 10^{-118}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -4.80000000000000035e38 or 1.75e-118 < t Initial program 81.1%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6472.4
Applied rewrites72.4%
if -4.80000000000000035e38 < t < 1.75e-118Initial program 65.9%
Taylor expanded in t around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites45.3%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6462.1
Applied rewrites62.1%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (/ x (fma b (/ y t) (+ 1.0 a))))) (if (<= t -2.6e-20) t_1 (if (<= t 1.2e-38) (/ (+ z (/ (* t x) y)) b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x / fma(b, (y / t), (1.0 + a));
double tmp;
if (t <= -2.6e-20) {
tmp = t_1;
} else if (t <= 1.2e-38) {
tmp = (z + ((t * x) / y)) / b;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(x / fma(b, Float64(y / t), Float64(1.0 + a))) tmp = 0.0 if (t <= -2.6e-20) tmp = t_1; elseif (t <= 1.2e-38) tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x / N[(b * N[(y / t), $MachinePrecision] + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -2.6e-20], t$95$1, If[LessEqual[t, 1.2e-38], N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{\mathsf{fma}\left(b, \frac{y}{t}, 1 + a\right)}\\
\mathbf{if}\;t \leq -2.6 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.2 \cdot 10^{-38}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.59999999999999995e-20 or 1.20000000000000011e-38 < t Initial program 81.7%
Taylor expanded in x around inf
lower-/.f64N/A
associate-+r+N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6468.2
Applied rewrites68.2%
if -2.59999999999999995e-20 < t < 1.20000000000000011e-38Initial program 66.0%
Taylor expanded in t around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.5%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6463.2
Applied rewrites63.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ x (+ 1.0 a))))
(if (<= t -4.6e+53)
t_1
(if (<= t 1.36e-27) (/ (+ z (/ (* t x) y)) b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x / (1.0 + a);
double tmp;
if (t <= -4.6e+53) {
tmp = t_1;
} else if (t <= 1.36e-27) {
tmp = (z + ((t * x) / y)) / b;
} else {
tmp = t_1;
}
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 = x / (1.0d0 + a)
if (t <= (-4.6d+53)) then
tmp = t_1
else if (t <= 1.36d-27) then
tmp = (z + ((t * x) / y)) / b
else
tmp = t_1
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 = x / (1.0 + a);
double tmp;
if (t <= -4.6e+53) {
tmp = t_1;
} else if (t <= 1.36e-27) {
tmp = (z + ((t * x) / y)) / b;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = x / (1.0 + a) tmp = 0 if t <= -4.6e+53: tmp = t_1 elif t <= 1.36e-27: tmp = (z + ((t * x) / y)) / b else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(x / Float64(1.0 + a)) tmp = 0.0 if (t <= -4.6e+53) tmp = t_1; elseif (t <= 1.36e-27) tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = x / (1.0 + a); tmp = 0.0; if (t <= -4.6e+53) tmp = t_1; elseif (t <= 1.36e-27) tmp = (z + ((t * x) / y)) / b; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x / N[(1.0 + a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -4.6e+53], t$95$1, If[LessEqual[t, 1.36e-27], N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{1 + a}\\
\mathbf{if}\;t \leq -4.6 \cdot 10^{+53}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.36 \cdot 10^{-27}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -4.60000000000000039e53 or 1.36e-27 < t Initial program 81.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6459.9
Applied rewrites59.9%
if -4.60000000000000039e53 < t < 1.36e-27Initial program 68.1%
Taylor expanded in t around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites44.5%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6459.8
Applied rewrites59.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ a 1.0) -500000.0) (/ x a) (if (<= (+ a 1.0) 2.0) x (/ x a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a + 1.0) <= -500000.0) {
tmp = x / a;
} else if ((a + 1.0) <= 2.0) {
tmp = x;
} else {
tmp = x / a;
}
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 ((a + 1.0d0) <= (-500000.0d0)) then
tmp = x / a
else if ((a + 1.0d0) <= 2.0d0) then
tmp = x
else
tmp = x / a
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 ((a + 1.0) <= -500000.0) {
tmp = x / a;
} else if ((a + 1.0) <= 2.0) {
tmp = x;
} else {
tmp = x / a;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a + 1.0) <= -500000.0: tmp = x / a elif (a + 1.0) <= 2.0: tmp = x else: tmp = x / a return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a + 1.0) <= -500000.0) tmp = Float64(x / a); elseif (Float64(a + 1.0) <= 2.0) tmp = x; else tmp = Float64(x / a); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a + 1.0) <= -500000.0) tmp = x / a; elseif ((a + 1.0) <= 2.0) tmp = x; else tmp = x / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a + 1.0), $MachinePrecision], -500000.0], N[(x / a), $MachinePrecision], If[LessEqual[N[(a + 1.0), $MachinePrecision], 2.0], x, N[(x / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a + 1 \leq -500000:\\
\;\;\;\;\frac{x}{a}\\
\mathbf{elif}\;a + 1 \leq 2:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{a}\\
\end{array}
\end{array}
if (+.f64 a #s(literal 1 binary64)) < -5e5 or 2 < (+.f64 a #s(literal 1 binary64)) Initial program 74.4%
Taylor expanded in x around inf
lower-/.f64N/A
associate-+r+N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6454.3
Applied rewrites54.3%
Taylor expanded in a around inf
Applied rewrites47.1%
if -5e5 < (+.f64 a #s(literal 1 binary64)) < 2Initial program 74.7%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6473.6
Applied rewrites73.6%
Taylor expanded in y around 0
Applied rewrites34.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (/ x (+ 1.0 a)))) (if (<= t -1.18e+38) t_1 (if (<= t 9.2e-29) (/ z b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x / (1.0 + a);
double tmp;
if (t <= -1.18e+38) {
tmp = t_1;
} else if (t <= 9.2e-29) {
tmp = z / b;
} else {
tmp = t_1;
}
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 = x / (1.0d0 + a)
if (t <= (-1.18d+38)) then
tmp = t_1
else if (t <= 9.2d-29) then
tmp = z / b
else
tmp = t_1
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 = x / (1.0 + a);
double tmp;
if (t <= -1.18e+38) {
tmp = t_1;
} else if (t <= 9.2e-29) {
tmp = z / b;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = x / (1.0 + a) tmp = 0 if t <= -1.18e+38: tmp = t_1 elif t <= 9.2e-29: tmp = z / b else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(x / Float64(1.0 + a)) tmp = 0.0 if (t <= -1.18e+38) tmp = t_1; elseif (t <= 9.2e-29) tmp = Float64(z / b); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = x / (1.0 + a); tmp = 0.0; if (t <= -1.18e+38) tmp = t_1; elseif (t <= 9.2e-29) tmp = z / b; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x / N[(1.0 + a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1.18e+38], t$95$1, If[LessEqual[t, 9.2e-29], N[(z / b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{1 + a}\\
\mathbf{if}\;t \leq -1.18 \cdot 10^{+38}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 9.2 \cdot 10^{-29}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.18e38 or 9.19999999999999965e-29 < t Initial program 81.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6459.5
Applied rewrites59.5%
if -1.18e38 < t < 9.19999999999999965e-29Initial program 67.7%
Taylor expanded in y around inf
lower-/.f6451.5
Applied rewrites51.5%
(FPCore (x y z t a b) :precision binary64 (if (<= y -1.95e-121) (/ z b) (if (<= y 6.9e-10) (/ x a) (/ z b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -1.95e-121) {
tmp = z / b;
} else if (y <= 6.9e-10) {
tmp = x / a;
} else {
tmp = z / 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 (y <= (-1.95d-121)) then
tmp = z / b
else if (y <= 6.9d-10) then
tmp = x / a
else
tmp = z / 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 (y <= -1.95e-121) {
tmp = z / b;
} else if (y <= 6.9e-10) {
tmp = x / a;
} else {
tmp = z / b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -1.95e-121: tmp = z / b elif y <= 6.9e-10: tmp = x / a else: tmp = z / b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -1.95e-121) tmp = Float64(z / b); elseif (y <= 6.9e-10) tmp = Float64(x / a); else tmp = Float64(z / b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (y <= -1.95e-121) tmp = z / b; elseif (y <= 6.9e-10) tmp = x / a; else tmp = z / b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -1.95e-121], N[(z / b), $MachinePrecision], If[LessEqual[y, 6.9e-10], N[(x / a), $MachinePrecision], N[(z / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{-121}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{elif}\;y \leq 6.9 \cdot 10^{-10}:\\
\;\;\;\;\frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\
\end{array}
\end{array}
if y < -1.95e-121 or 6.89999999999999995e-10 < y Initial program 61.2%
Taylor expanded in y around inf
lower-/.f6447.3
Applied rewrites47.3%
if -1.95e-121 < y < 6.89999999999999995e-10Initial program 94.8%
Taylor expanded in x around inf
lower-/.f64N/A
associate-+r+N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6473.1
Applied rewrites73.1%
Taylor expanded in a around inf
Applied rewrites36.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 74.6%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6445.3
Applied rewrites45.3%
Taylor expanded in y around 0
Applied rewrites19.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1
(* 1.0 (* (+ x (* (/ y t) z)) (/ 1.0 (+ (+ a 1.0) (* (/ y t) b)))))))
(if (< t -1.3659085366310088e-271)
t_1
(if (< t 3.036967103737246e-130) (/ z b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 * ((x + ((y / t) * z)) * (1.0 / ((a + 1.0) + ((y / t) * b))));
double tmp;
if (t < -1.3659085366310088e-271) {
tmp = t_1;
} else if (t < 3.036967103737246e-130) {
tmp = z / b;
} else {
tmp = t_1;
}
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 = 1.0d0 * ((x + ((y / t) * z)) * (1.0d0 / ((a + 1.0d0) + ((y / t) * b))))
if (t < (-1.3659085366310088d-271)) then
tmp = t_1
else if (t < 3.036967103737246d-130) then
tmp = z / b
else
tmp = t_1
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 = 1.0 * ((x + ((y / t) * z)) * (1.0 / ((a + 1.0) + ((y / t) * b))));
double tmp;
if (t < -1.3659085366310088e-271) {
tmp = t_1;
} else if (t < 3.036967103737246e-130) {
tmp = z / b;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = 1.0 * ((x + ((y / t) * z)) * (1.0 / ((a + 1.0) + ((y / t) * b)))) tmp = 0 if t < -1.3659085366310088e-271: tmp = t_1 elif t < 3.036967103737246e-130: tmp = z / b else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(1.0 * Float64(Float64(x + Float64(Float64(y / t) * z)) * Float64(1.0 / Float64(Float64(a + 1.0) + Float64(Float64(y / t) * b))))) tmp = 0.0 if (t < -1.3659085366310088e-271) tmp = t_1; elseif (t < 3.036967103737246e-130) tmp = Float64(z / b); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = 1.0 * ((x + ((y / t) * z)) * (1.0 / ((a + 1.0) + ((y / t) * b)))); tmp = 0.0; if (t < -1.3659085366310088e-271) tmp = t_1; elseif (t < 3.036967103737246e-130) tmp = z / b; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 * N[(N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y / t), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t, -1.3659085366310088e-271], t$95$1, If[Less[t, 3.036967103737246e-130], N[(z / b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 \cdot \left(\left(x + \frac{y}{t} \cdot z\right) \cdot \frac{1}{\left(a + 1\right) + \frac{y}{t} \cdot b}\right)\\
\mathbf{if}\;t < -1.3659085366310088 \cdot 10^{-271}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t < 3.036967103737246 \cdot 10^{-130}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2025093
(FPCore (x y z t a b)
:name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, B"
:precision binary64
:alt
(! :herbie-platform default (if (< t -1707385670788761/12500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* 1 (* (+ x (* (/ y t) z)) (/ 1 (+ (+ a 1) (* (/ y t) b))))) (if (< t 1518483551868623/5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ z b) (* 1 (* (+ x (* (/ y t) z)) (/ 1 (+ (+ a 1) (* (/ y t) b))))))))
(/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))