
(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 14 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))) (t_2 (/ t_1 (+ (+ a 1.0) (/ (* y b) t)))))
(if (<= t_2 (- INFINITY))
(/ (* y z) (* t (+ 1.0 (+ a (/ (* b y) t)))))
(if (<= t_2 5e+304) (/ t_1 (fma b (/ y t) (+ 1.0 a))) (/ z 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 <= -((double) INFINITY)) {
tmp = (y * z) / (t * (1.0 + (a + ((b * y) / t))));
} else if (t_2 <= 5e+304) {
tmp = t_1 / fma(b, (y / t), (1.0 + a));
} else {
tmp = z / 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 <= Float64(-Inf)) tmp = Float64(Float64(y * z) / Float64(t * Float64(1.0 + Float64(a + Float64(Float64(b * y) / t))))); elseif (t_2 <= 5e+304) tmp = Float64(t_1 / fma(b, Float64(y / t), Float64(1.0 + a))); else tmp = Float64(z / 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, (-Infinity)], N[(N[(y * z), $MachinePrecision] / N[(t * N[(1.0 + N[(a + N[(N[(b * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+304], N[(t$95$1 / N[(b * N[(y / t), $MachinePrecision] + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z / 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 -\infty:\\
\;\;\;\;\frac{y \cdot z}{t \cdot \left(1 + \left(a + \frac{b \cdot y}{t}\right)\right)}\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+304}:\\
\;\;\;\;\frac{t\_1}{\mathsf{fma}\left(b, \frac{y}{t}, 1 + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{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 33.1%
Taylor expanded in y around inf
lower-/.f6457.2
Applied rewrites57.2%
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-*.f6459.0
Applied rewrites59.0%
if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 4.9999999999999997e304Initial program 90.3%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6491.2
Applied rewrites91.2%
if 4.9999999999999997e304 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) Initial program 12.2%
Taylor expanded in y around inf
lower-/.f6481.1
Applied rewrites81.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ x (/ (* y z) t))))
(if (<= a -9.5e+104)
(/ t_1 (fma b (/ y t) a))
(if (<= a -8e-73)
(/ (+ z (/ (* t x) y)) b)
(if (<= a 1.15e-25)
(/ (fma y (/ z t) x) (fma b (/ y t) 1.0))
(/ t_1 (+ a (/ (* y b) t))))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x + ((y * z) / t);
double tmp;
if (a <= -9.5e+104) {
tmp = t_1 / fma(b, (y / t), a);
} else if (a <= -8e-73) {
tmp = (z + ((t * x) / y)) / b;
} else if (a <= 1.15e-25) {
tmp = fma(y, (z / t), x) / fma(b, (y / t), 1.0);
} else {
tmp = t_1 / (a + ((y * b) / t));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(x + Float64(Float64(y * z) / t)) tmp = 0.0 if (a <= -9.5e+104) tmp = Float64(t_1 / fma(b, Float64(y / t), a)); elseif (a <= -8e-73) tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); elseif (a <= 1.15e-25) tmp = Float64(fma(y, Float64(z / t), x) / fma(b, Float64(y / t), 1.0)); else tmp = Float64(t_1 / Float64(a + Float64(Float64(y * b) / t))); 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]}, If[LessEqual[a, -9.5e+104], N[(t$95$1 / N[(b * N[(y / t), $MachinePrecision] + a), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -8e-73], N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], If[LessEqual[a, 1.15e-25], N[(N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision] / N[(b * N[(y / t), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(a + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{y \cdot z}{t}\\
\mathbf{if}\;a \leq -9.5 \cdot 10^{+104}:\\
\;\;\;\;\frac{t\_1}{\mathsf{fma}\left(b, \frac{y}{t}, a\right)}\\
\mathbf{elif}\;a \leq -8 \cdot 10^{-73}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\mathbf{elif}\;a \leq 1.15 \cdot 10^{-25}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, \frac{z}{t}, x\right)}{\mathsf{fma}\left(b, \frac{y}{t}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{a + \frac{y \cdot b}{t}}\\
\end{array}
\end{array}
if a < -9.5e104Initial program 74.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6475.0
Applied rewrites75.0%
Taylor expanded in a around inf
Applied rewrites75.0%
if -9.5e104 < a < -7.99999999999999998e-73Initial program 77.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 rewrites79.5%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6444.8
Applied rewrites44.8%
if -7.99999999999999998e-73 < a < 1.15e-25Initial program 75.5%
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-/.f6474.2
Applied rewrites74.2%
if 1.15e-25 < a Initial program 74.1%
Taylor expanded in a around inf
Applied rewrites70.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (+ x (/ (* y z) t)) (fma b (/ y t) a))))
(if (<= a -9.5e+104)
t_1
(if (<= a -8e-73)
(/ (+ z (/ (* t x) y)) b)
(if (<= a 1.15e-25) (/ (fma y (/ z t) x) (fma b (/ y t) 1.0)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + ((y * z) / t)) / fma(b, (y / t), a);
double tmp;
if (a <= -9.5e+104) {
tmp = t_1;
} else if (a <= -8e-73) {
tmp = (z + ((t * x) / y)) / b;
} else if (a <= 1.15e-25) {
tmp = fma(y, (z / t), x) / fma(b, (y / t), 1.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x + Float64(Float64(y * z) / t)) / fma(b, Float64(y / t), a)) tmp = 0.0 if (a <= -9.5e+104) tmp = t_1; elseif (a <= -8e-73) tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); elseif (a <= 1.15e-25) tmp = Float64(fma(y, Float64(z / t), x) / fma(b, Float64(y / t), 1.0)); else tmp = t_1; 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[(b * N[(y / t), $MachinePrecision] + a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -9.5e+104], t$95$1, If[LessEqual[a, -8e-73], N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], If[LessEqual[a, 1.15e-25], N[(N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision] / N[(b * N[(y / t), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z}{t}}{\mathsf{fma}\left(b, \frac{y}{t}, a\right)}\\
\mathbf{if}\;a \leq -9.5 \cdot 10^{+104}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -8 \cdot 10^{-73}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\mathbf{elif}\;a \leq 1.15 \cdot 10^{-25}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, \frac{z}{t}, x\right)}{\mathsf{fma}\left(b, \frac{y}{t}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -9.5e104 or 1.15e-25 < a Initial program 74.4%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6474.2
Applied rewrites74.2%
Taylor expanded in a around inf
Applied rewrites71.8%
if -9.5e104 < a < -7.99999999999999998e-73Initial program 77.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 rewrites79.5%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6444.8
Applied rewrites44.8%
if -7.99999999999999998e-73 < a < 1.15e-25Initial program 75.5%
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-/.f6474.2
Applied rewrites74.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (+ x (/ (* y z) t)) a)))
(if (<= a -9.5e+104)
t_1
(if (<= a -8e-73)
(/ (+ z (/ (* t x) y)) b)
(if (<= a 1.6e+30) (/ (fma y (/ z t) x) (fma b (/ y t) 1.0)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + ((y * z) / t)) / a;
double tmp;
if (a <= -9.5e+104) {
tmp = t_1;
} else if (a <= -8e-73) {
tmp = (z + ((t * x) / y)) / b;
} else if (a <= 1.6e+30) {
tmp = fma(y, (z / t), x) / fma(b, (y / t), 1.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x + Float64(Float64(y * z) / t)) / a) tmp = 0.0 if (a <= -9.5e+104) tmp = t_1; elseif (a <= -8e-73) tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); elseif (a <= 1.6e+30) tmp = Float64(fma(y, Float64(z / t), x) / fma(b, Float64(y / t), 1.0)); else tmp = t_1; 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] / a), $MachinePrecision]}, If[LessEqual[a, -9.5e+104], t$95$1, If[LessEqual[a, -8e-73], N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], If[LessEqual[a, 1.6e+30], N[(N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision] / N[(b * N[(y / t), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z}{t}}{a}\\
\mathbf{if}\;a \leq -9.5 \cdot 10^{+104}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -8 \cdot 10^{-73}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{+30}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, \frac{z}{t}, x\right)}{\mathsf{fma}\left(b, \frac{y}{t}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -9.5e104 or 1.59999999999999986e30 < a Initial program 74.4%
Taylor expanded in a around inf
Applied rewrites65.2%
if -9.5e104 < a < -7.99999999999999998e-73Initial program 77.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 rewrites79.5%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6444.8
Applied rewrites44.8%
if -7.99999999999999998e-73 < a < 1.59999999999999986e30Initial program 75.3%
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-/.f6471.5
Applied rewrites71.5%
(FPCore (x y z t a b)
:precision binary64
(if (<= b -6.6e-13)
(/ (+ z (/ (* t x) y)) b)
(if (<= b 2.1e-19)
(/ (+ x (/ (* y z) t)) (+ 1.0 a))
(/ x (fma b (/ y t) (+ 1.0 a))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -6.6e-13) {
tmp = (z + ((t * x) / y)) / b;
} else if (b <= 2.1e-19) {
tmp = (x + ((y * z) / t)) / (1.0 + a);
} else {
tmp = x / fma(b, (y / t), (1.0 + a));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -6.6e-13) tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); elseif (b <= 2.1e-19) tmp = Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(1.0 + a)); else tmp = Float64(x / fma(b, Float64(y / t), Float64(1.0 + a))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -6.6e-13], N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], If[LessEqual[b, 2.1e-19], N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(1.0 + a), $MachinePrecision]), $MachinePrecision], N[(x / N[(b * N[(y / t), $MachinePrecision] + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.6 \cdot 10^{-13}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{-19}:\\
\;\;\;\;\frac{x + \frac{y \cdot z}{t}}{1 + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(b, \frac{y}{t}, 1 + a\right)}\\
\end{array}
\end{array}
if b < -6.6000000000000001e-13Initial program 65.8%
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 rewrites73.3%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6457.2
Applied rewrites57.2%
if -6.6000000000000001e-13 < b < 2.0999999999999999e-19Initial program 85.1%
Taylor expanded in y around 0
lower-+.f6474.1
Applied rewrites74.1%
if 2.0999999999999999e-19 < b Initial program 66.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.4
Applied rewrites54.4%
(FPCore (x y z t a b)
:precision binary64
(if (<= t -6e-61)
(/ x (fma b (/ y t) (+ 1.0 a)))
(if (<= t 8.2e-110)
(/ (+ z (/ (* t x) y)) b)
(/ (fma y (/ z t) x) (+ 1.0 a)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -6e-61) {
tmp = x / fma(b, (y / t), (1.0 + a));
} else if (t <= 8.2e-110) {
tmp = (z + ((t * x) / y)) / b;
} else {
tmp = fma(y, (z / t), x) / (1.0 + a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -6e-61) tmp = Float64(x / fma(b, Float64(y / t), Float64(1.0 + a))); elseif (t <= 8.2e-110) tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); else tmp = Float64(fma(y, Float64(z / t), x) / Float64(1.0 + a)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -6e-61], N[(x / N[(b * N[(y / t), $MachinePrecision] + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 8.2e-110], N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], N[(N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision] / N[(1.0 + a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6 \cdot 10^{-61}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(b, \frac{y}{t}, 1 + a\right)}\\
\mathbf{elif}\;t \leq 8.2 \cdot 10^{-110}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, \frac{z}{t}, x\right)}{1 + a}\\
\end{array}
\end{array}
if t < -6.00000000000000024e-61Initial program 83.9%
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-+.f6466.0
Applied rewrites66.0%
if -6.00000000000000024e-61 < t < 8.19999999999999965e-110Initial program 62.7%
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 rewrites56.3%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6466.8
Applied rewrites66.8%
if 8.19999999999999965e-110 < t Initial program 81.4%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6469.8
Applied rewrites69.8%
(FPCore (x y z t a b)
:precision binary64
(if (<= t -6e-61)
(/ x (fma b (/ y t) (+ 1.0 a)))
(if (<= t 3e-135)
(/ (+ z (/ (* t x) y)) b)
(/ x (fma (/ b t) y (+ a 1.0))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -6e-61) {
tmp = x / fma(b, (y / t), (1.0 + a));
} else if (t <= 3e-135) {
tmp = (z + ((t * x) / y)) / b;
} else {
tmp = x / fma((b / t), y, (a + 1.0));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -6e-61) tmp = Float64(x / fma(b, Float64(y / t), Float64(1.0 + a))); elseif (t <= 3e-135) tmp = Float64(Float64(z + Float64(Float64(t * x) / y)) / b); else tmp = Float64(x / fma(Float64(b / t), y, Float64(a + 1.0))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -6e-61], N[(x / N[(b * N[(y / t), $MachinePrecision] + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 3e-135], N[(N[(z + N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], N[(x / N[(N[(b / t), $MachinePrecision] * y + N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6 \cdot 10^{-61}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(b, \frac{y}{t}, 1 + a\right)}\\
\mathbf{elif}\;t \leq 3 \cdot 10^{-135}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(\frac{b}{t}, y, a + 1\right)}\\
\end{array}
\end{array}
if t < -6.00000000000000024e-61Initial program 83.9%
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-+.f6466.0
Applied rewrites66.0%
if -6.00000000000000024e-61 < t < 3.00000000000000012e-135Initial program 61.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 rewrites55.3%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6467.6
Applied rewrites67.6%
if 3.00000000000000012e-135 < t Initial program 81.0%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6482.8
Applied rewrites82.8%
Taylor expanded in x around inf
+-commutativeN/A
+-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
associate-+r+N/A
*-commutativeN/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
+-commutativeN/A
lower-+.f6462.3
Applied rewrites62.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (/ x (fma b (/ y t) (+ 1.0 a))))) (if (<= t -6e-61) t_1 (if (<= t 3.8e-135) (/ (+ 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 <= -6e-61) {
tmp = t_1;
} else if (t <= 3.8e-135) {
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 <= -6e-61) tmp = t_1; elseif (t <= 3.8e-135) 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, -6e-61], t$95$1, If[LessEqual[t, 3.8e-135], 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 -6 \cdot 10^{-61}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3.8 \cdot 10^{-135}:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -6.00000000000000024e-61 or 3.8000000000000003e-135 < t Initial program 82.3%
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-+.f6464.3
Applied rewrites64.3%
if -6.00000000000000024e-61 < t < 3.8000000000000003e-135Initial program 62.0%
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 rewrites55.3%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6467.6
Applied rewrites67.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (+ z (/ (* t x) y)) b)) (t_2 (/ (+ x (/ (* y z) t)) a)))
(if (<= a -9.5e+104)
t_2
(if (<= a -7.2e-74)
t_1
(if (<= a 7e-129)
(/ x (fma b (/ y t) 1.0))
(if (<= a 1.6e+30) t_1 t_2))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z + ((t * x) / y)) / b;
double t_2 = (x + ((y * z) / t)) / a;
double tmp;
if (a <= -9.5e+104) {
tmp = t_2;
} else if (a <= -7.2e-74) {
tmp = t_1;
} else if (a <= 7e-129) {
tmp = x / fma(b, (y / t), 1.0);
} else if (a <= 1.6e+30) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(z + Float64(Float64(t * x) / y)) / b) t_2 = Float64(Float64(x + Float64(Float64(y * z) / t)) / a) tmp = 0.0 if (a <= -9.5e+104) tmp = t_2; elseif (a <= -7.2e-74) tmp = t_1; elseif (a <= 7e-129) tmp = Float64(x / fma(b, Float64(y / t), 1.0)); elseif (a <= 1.6e+30) tmp = t_1; else tmp = t_2; end return 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]}, Block[{t$95$2 = N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[a, -9.5e+104], t$95$2, If[LessEqual[a, -7.2e-74], t$95$1, If[LessEqual[a, 7e-129], N[(x / N[(b * N[(y / t), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.6e+30], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z + \frac{t \cdot x}{y}}{b}\\
t_2 := \frac{x + \frac{y \cdot z}{t}}{a}\\
\mathbf{if}\;a \leq -9.5 \cdot 10^{+104}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;a \leq -7.2 \cdot 10^{-74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 7 \cdot 10^{-129}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(b, \frac{y}{t}, 1\right)}\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{+30}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if a < -9.5e104 or 1.59999999999999986e30 < a Initial program 74.4%
Taylor expanded in a around inf
Applied rewrites65.2%
if -9.5e104 < a < -7.2000000000000005e-74 or 6.9999999999999995e-129 < a < 1.59999999999999986e30Initial program 77.0%
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 rewrites79.3%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6445.1
Applied rewrites45.1%
if -7.2000000000000005e-74 < a < 6.9999999999999995e-129Initial 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 x around inf
Applied rewrites50.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (fma y (/ z t) x) a)))
(if (<= a -9.5e+104)
t_1
(if (<= a -1.22e-56)
(/ z b)
(if (<= a 3100000.0) (/ x (fma b (/ y t) 1.0)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(y, (z / t), x) / a;
double tmp;
if (a <= -9.5e+104) {
tmp = t_1;
} else if (a <= -1.22e-56) {
tmp = z / b;
} else if (a <= 3100000.0) {
tmp = x / fma(b, (y / t), 1.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(y, Float64(z / t), x) / a) tmp = 0.0 if (a <= -9.5e+104) tmp = t_1; elseif (a <= -1.22e-56) tmp = Float64(z / b); elseif (a <= 3100000.0) tmp = Float64(x / fma(b, Float64(y / t), 1.0)); 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] / a), $MachinePrecision]}, If[LessEqual[a, -9.5e+104], t$95$1, If[LessEqual[a, -1.22e-56], N[(z / b), $MachinePrecision], If[LessEqual[a, 3100000.0], N[(x / N[(b * N[(y / t), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\mathsf{fma}\left(y, \frac{z}{t}, x\right)}{a}\\
\mathbf{if}\;a \leq -9.5 \cdot 10^{+104}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -1.22 \cdot 10^{-56}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{elif}\;a \leq 3100000:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(b, \frac{y}{t}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -9.5e104 or 3.1e6 < a Initial program 74.5%
Taylor expanded in a around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6464.1
Applied rewrites64.1%
if -9.5e104 < a < -1.22e-56Initial program 76.8%
Taylor expanded in y around inf
lower-/.f6435.9
Applied rewrites35.9%
if -1.22e-56 < a < 3.1e6Initial program 75.5%
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.5
Applied rewrites73.5%
Taylor expanded in x around inf
Applied rewrites50.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ x (+ 1.0 a))))
(if (<= t -6.5e-61)
t_1
(if (<= t 0.000112) (/ (+ 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 <= -6.5e-61) {
tmp = t_1;
} else if (t <= 0.000112) {
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 <= (-6.5d-61)) then
tmp = t_1
else if (t <= 0.000112d0) 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 <= -6.5e-61) {
tmp = t_1;
} else if (t <= 0.000112) {
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 <= -6.5e-61: tmp = t_1 elif t <= 0.000112: 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 <= -6.5e-61) tmp = t_1; elseif (t <= 0.000112) 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 <= -6.5e-61) tmp = t_1; elseif (t <= 0.000112) 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, -6.5e-61], t$95$1, If[LessEqual[t, 0.000112], 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 -6.5 \cdot 10^{-61}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 0.000112:\\
\;\;\;\;\frac{z + \frac{t \cdot x}{y}}{b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -6.4999999999999994e-61 or 1.11999999999999998e-4 < t Initial program 82.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6457.8
Applied rewrites57.8%
if -6.4999999999999994e-61 < t < 1.11999999999999998e-4Initial program 65.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 rewrites60.5%
Taylor expanded in b around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6463.5
Applied rewrites63.5%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (/ x (+ 1.0 a)))) (if (<= t -4.2e-61) t_1 (if (<= t 4.6e-5) (/ 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 <= -4.2e-61) {
tmp = t_1;
} else if (t <= 4.6e-5) {
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 <= (-4.2d-61)) then
tmp = t_1
else if (t <= 4.6d-5) 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 <= -4.2e-61) {
tmp = t_1;
} else if (t <= 4.6e-5) {
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 <= -4.2e-61: tmp = t_1 elif t <= 4.6e-5: 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 <= -4.2e-61) tmp = t_1; elseif (t <= 4.6e-5) 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 <= -4.2e-61) tmp = t_1; elseif (t <= 4.6e-5) 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, -4.2e-61], t$95$1, If[LessEqual[t, 4.6e-5], N[(z / b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{1 + a}\\
\mathbf{if}\;t \leq -4.2 \cdot 10^{-61}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 4.6 \cdot 10^{-5}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -4.1999999999999998e-61 or 4.6e-5 < t Initial program 82.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6457.8
Applied rewrites57.8%
if -4.1999999999999998e-61 < t < 4.6e-5Initial program 65.9%
Taylor expanded in y around inf
lower-/.f6453.2
Applied rewrites53.2%
(FPCore (x y z t a b) :precision binary64 (if (<= t -9.5e+85) x (if (<= t 3.7e+61) (/ z b) x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -9.5e+85) {
tmp = x;
} else if (t <= 3.7e+61) {
tmp = z / b;
} else {
tmp = x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (t <= (-9.5d+85)) then
tmp = x
else if (t <= 3.7d+61) then
tmp = z / b
else
tmp = x
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 (t <= -9.5e+85) {
tmp = x;
} else if (t <= 3.7e+61) {
tmp = z / b;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -9.5e+85: tmp = x elif t <= 3.7e+61: tmp = z / b else: tmp = x return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -9.5e+85) tmp = x; elseif (t <= 3.7e+61) tmp = Float64(z / b); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -9.5e+85) tmp = x; elseif (t <= 3.7e+61) tmp = z / b; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -9.5e+85], x, If[LessEqual[t, 3.7e+61], N[(z / b), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -9.5 \cdot 10^{+85}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 3.7 \cdot 10^{+61}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -9.49999999999999945e85 or 3.70000000000000003e61 < t Initial program 81.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-/.f6454.3
Applied rewrites54.3%
Taylor expanded in y around 0
Applied rewrites31.7%
if -9.49999999999999945e85 < t < 3.70000000000000003e61Initial program 71.5%
Taylor expanded in y around inf
lower-/.f6446.3
Applied rewrites46.3%
(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 75.3%
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-/.f6446.1
Applied rewrites46.1%
Taylor expanded in y around 0
Applied rewrites19.8%
herbie shell --seed 2025115
(FPCore (x y z t a b)
:name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, B"
:precision binary64
(/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))