
(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}
Sampling outcomes in binary64 precision:
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)) (+ (+ a 1.0) (/ (* y b) t)))))
(if (<= t_1 (- INFINITY))
(* y (/ z (fma (+ 1.0 a) t (* b y))))
(if (<= t_1 2e+287)
t_1
(if (<= t_1 INFINITY)
(* (/ (+ (/ y t) (/ x z)) (fma (/ y t) b (+ 1.0 a))) z)
(/ z 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 = y * (z / fma((1.0 + a), t, (b * y)));
} else if (t_1 <= 2e+287) {
tmp = t_1;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (((y / t) + (x / z)) / fma((y / t), b, (1.0 + a))) * z;
} else {
tmp = z / 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 = Float64(y * Float64(z / fma(Float64(1.0 + a), t, Float64(b * y)))); elseif (t_1 <= 2e+287) tmp = t_1; elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(Float64(y / t) + Float64(x / z)) / fma(Float64(y / t), b, Float64(1.0 + a))) * z); else tmp = Float64(z / 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[(N[(1.0 + a), $MachinePrecision] * t + N[(b * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+287], t$95$1, If[LessEqual[t$95$1, Infinity], N[(N[(N[(N[(y / t), $MachinePrecision] + N[(x / z), $MachinePrecision]), $MachinePrecision] / N[(N[(y / t), $MachinePrecision] * b + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(z / 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:\\
\;\;\;\;y \cdot \frac{z}{\mathsf{fma}\left(1 + a, t, b \cdot y\right)}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+287}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\frac{y}{t} + \frac{x}{z}}{\mathsf{fma}\left(\frac{y}{t}, b, 1 + a\right)} \cdot z\\
\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 31.0%
Taylor expanded in x around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-+r+N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6438.9
Applied rewrites38.9%
Taylor expanded in x around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6421.9
Applied rewrites21.9%
Applied rewrites90.6%
Taylor expanded in y around 0
Applied rewrites90.6%
if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 2.0000000000000002e287Initial program 95.3%
if 2.0000000000000002e287 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < +inf.0Initial program 32.1%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.2%
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 y around inf
lower-/.f64100.0
Applied rewrites100.0%
(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))
(* y (/ z (fma (+ 1.0 a) t (* b y))))
(if (<= t_1 1e+292) t_1 (/ z 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 = y * (z / fma((1.0 + a), t, (b * y)));
} else if (t_1 <= 1e+292) {
tmp = t_1;
} else {
tmp = z / 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 = Float64(y * Float64(z / fma(Float64(1.0 + a), t, Float64(b * y)))); elseif (t_1 <= 1e+292) tmp = t_1; else tmp = Float64(z / 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[(N[(1.0 + a), $MachinePrecision] * t + N[(b * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+292], t$95$1, N[(z / 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:\\
\;\;\;\;y \cdot \frac{z}{\mathsf{fma}\left(1 + a, t, b \cdot y\right)}\\
\mathbf{elif}\;t\_1 \leq 10^{+292}:\\
\;\;\;\;t\_1\\
\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 31.0%
Taylor expanded in x around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-+r+N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6438.9
Applied rewrites38.9%
Taylor expanded in x around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6421.9
Applied rewrites21.9%
Applied rewrites90.6%
Taylor expanded in y around 0
Applied rewrites90.6%
if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 1e292Initial program 95.3%
if 1e292 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) Initial program 12.1%
Taylor expanded in y around inf
lower-/.f6475.2
Applied rewrites75.2%
(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))
(* y (/ z (fma (+ 1.0 a) t (* b y))))
(if (<= t_1 INFINITY)
(/ (fma (/ y t) z x) (fma (/ y t) b (+ 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)) / ((a + 1.0) + ((y * b) / t));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = y * (z / fma((1.0 + a), t, (b * y)));
} else if (t_1 <= ((double) INFINITY)) {
tmp = fma((y / t), z, x) / fma((y / t), b, (1.0 + a));
} else {
tmp = z / 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 = Float64(y * Float64(z / fma(Float64(1.0 + a), t, Float64(b * y)))); elseif (t_1 <= Inf) tmp = Float64(fma(Float64(y / t), z, x) / fma(Float64(y / t), b, 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[(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[(N[(1.0 + a), $MachinePrecision] * t + N[(b * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision] / N[(N[(y / t), $MachinePrecision] * b + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z / 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:\\
\;\;\;\;y \cdot \frac{z}{\mathsf{fma}\left(1 + a, t, b \cdot y\right)}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, 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 31.0%
Taylor expanded in x around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-+r+N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6438.9
Applied rewrites38.9%
Taylor expanded in x around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6421.9
Applied rewrites21.9%
Applied rewrites90.6%
Taylor expanded in y around 0
Applied rewrites90.6%
if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < +inf.0Initial program 88.4%
Taylor expanded in x around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-+r+N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6487.5
Applied rewrites87.5%
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 y around inf
lower-/.f64100.0
Applied rewrites100.0%
(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))
(* y (/ z (fma (+ 1.0 a) t (* b y))))
(if (<= t_1 INFINITY)
(/ (fma (/ y t) z x) (fma (/ b t) y (+ 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)) / ((a + 1.0) + ((y * b) / t));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = y * (z / fma((1.0 + a), t, (b * y)));
} else if (t_1 <= ((double) INFINITY)) {
tmp = fma((y / t), z, x) / fma((b / t), y, (1.0 + a));
} else {
tmp = z / 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 = Float64(y * Float64(z / fma(Float64(1.0 + a), t, Float64(b * y)))); elseif (t_1 <= Inf) tmp = Float64(fma(Float64(y / t), z, x) / fma(Float64(b / t), y, 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[(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[(N[(1.0 + a), $MachinePrecision] * t + N[(b * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision] / N[(N[(b / t), $MachinePrecision] * y + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z / 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:\\
\;\;\;\;y \cdot \frac{z}{\mathsf{fma}\left(1 + a, t, b \cdot y\right)}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{b}{t}, y, 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 31.0%
Taylor expanded in x around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-+r+N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6438.9
Applied rewrites38.9%
Taylor expanded in x around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6421.9
Applied rewrites21.9%
Applied rewrites90.6%
Taylor expanded in y around 0
Applied rewrites90.6%
if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < +inf.0Initial program 88.4%
Taylor expanded in x around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-+r+N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6487.5
Applied rewrites87.5%
Applied rewrites83.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 y around inf
lower-/.f64100.0
Applied rewrites100.0%
(FPCore (x y z t a b)
:precision binary64
(if (<= t -8e+106)
(/ (fma (/ y t) z x) (+ 1.0 a))
(if (or (<= t -2.25e-110) (not (<= t 2.1e-23)))
(/ x (fma (/ y t) b (+ 1.0 a)))
(* y (/ z (fma (+ 1.0 a) t (* b y)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -8e+106) {
tmp = fma((y / t), z, x) / (1.0 + a);
} else if ((t <= -2.25e-110) || !(t <= 2.1e-23)) {
tmp = x / fma((y / t), b, (1.0 + a));
} else {
tmp = y * (z / fma((1.0 + a), t, (b * y)));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -8e+106) tmp = Float64(fma(Float64(y / t), z, x) / Float64(1.0 + a)); elseif ((t <= -2.25e-110) || !(t <= 2.1e-23)) tmp = Float64(x / fma(Float64(y / t), b, Float64(1.0 + a))); else tmp = Float64(y * Float64(z / fma(Float64(1.0 + a), t, Float64(b * y)))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -8e+106], N[(N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision] / N[(1.0 + a), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t, -2.25e-110], N[Not[LessEqual[t, 2.1e-23]], $MachinePrecision]], N[(x / N[(N[(y / t), $MachinePrecision] * b + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(z / N[(N[(1.0 + a), $MachinePrecision] * t + N[(b * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -8 \cdot 10^{+106}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{1 + a}\\
\mathbf{elif}\;t \leq -2.25 \cdot 10^{-110} \lor \neg \left(t \leq 2.1 \cdot 10^{-23}\right):\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(\frac{y}{t}, b, 1 + a\right)}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z}{\mathsf{fma}\left(1 + a, t, b \cdot y\right)}\\
\end{array}
\end{array}
if t < -8.00000000000000073e106Initial program 79.8%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6489.2
Applied rewrites89.2%
if -8.00000000000000073e106 < t < -2.25e-110 or 2.1000000000000001e-23 < t Initial program 92.3%
Taylor expanded in x around inf
lower-/.f64N/A
associate-+r+N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6478.0
Applied rewrites78.0%
if -2.25e-110 < t < 2.1000000000000001e-23Initial program 62.3%
Taylor expanded in x around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-+r+N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6453.4
Applied rewrites53.4%
Taylor expanded in x around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6436.4
Applied rewrites36.4%
Applied rewrites49.6%
Taylor expanded in y around 0
Applied rewrites67.3%
Final simplification75.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -2.25e-110) (not (<= t 2.1e-23))) (/ x (fma (/ y t) b (+ 1.0 a))) (* y (/ z (fma (+ 1.0 a) t (* b y))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -2.25e-110) || !(t <= 2.1e-23)) {
tmp = x / fma((y / t), b, (1.0 + a));
} else {
tmp = y * (z / fma((1.0 + a), t, (b * y)));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -2.25e-110) || !(t <= 2.1e-23)) tmp = Float64(x / fma(Float64(y / t), b, Float64(1.0 + a))); else tmp = Float64(y * Float64(z / fma(Float64(1.0 + a), t, Float64(b * y)))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -2.25e-110], N[Not[LessEqual[t, 2.1e-23]], $MachinePrecision]], N[(x / N[(N[(y / t), $MachinePrecision] * b + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(z / N[(N[(1.0 + a), $MachinePrecision] * t + N[(b * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.25 \cdot 10^{-110} \lor \neg \left(t \leq 2.1 \cdot 10^{-23}\right):\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(\frac{y}{t}, b, 1 + a\right)}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z}{\mathsf{fma}\left(1 + a, t, b \cdot y\right)}\\
\end{array}
\end{array}
if t < -2.25e-110 or 2.1000000000000001e-23 < t Initial program 88.6%
Taylor expanded in x around inf
lower-/.f64N/A
associate-+r+N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6478.1
Applied rewrites78.1%
if -2.25e-110 < t < 2.1000000000000001e-23Initial program 62.3%
Taylor expanded in x around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-+r+N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6453.4
Applied rewrites53.4%
Taylor expanded in x around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6436.4
Applied rewrites36.4%
Applied rewrites49.6%
Taylor expanded in y around 0
Applied rewrites67.3%
Final simplification73.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -1.9e-17) (not (<= t 3.2e-7))) (/ x (+ 1.0 a)) (* y (/ z (fma (+ 1.0 a) t (* b y))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -1.9e-17) || !(t <= 3.2e-7)) {
tmp = x / (1.0 + a);
} else {
tmp = y * (z / fma((1.0 + a), t, (b * y)));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -1.9e-17) || !(t <= 3.2e-7)) tmp = Float64(x / Float64(1.0 + a)); else tmp = Float64(y * Float64(z / fma(Float64(1.0 + a), t, Float64(b * y)))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -1.9e-17], N[Not[LessEqual[t, 3.2e-7]], $MachinePrecision]], N[(x / N[(1.0 + a), $MachinePrecision]), $MachinePrecision], N[(y * N[(z / N[(N[(1.0 + a), $MachinePrecision] * t + N[(b * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.9 \cdot 10^{-17} \lor \neg \left(t \leq 3.2 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{x}{1 + a}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z}{\mathsf{fma}\left(1 + a, t, b \cdot y\right)}\\
\end{array}
\end{array}
if t < -1.9000000000000001e-17 or 3.2000000000000001e-7 < t Initial program 87.2%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6469.2
Applied rewrites69.2%
if -1.9000000000000001e-17 < t < 3.2000000000000001e-7Initial program 67.1%
Taylor expanded in x around 0
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-+r+N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6458.5
Applied rewrites58.5%
Taylor expanded in x around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6436.8
Applied rewrites36.8%
Applied rewrites46.8%
Taylor expanded in y around 0
Applied rewrites63.0%
Final simplification66.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -470.0) (not (<= t 3.2e-7))) (/ x (+ 1.0 a)) (/ (fma t (/ x y) z) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -470.0) || !(t <= 3.2e-7)) {
tmp = x / (1.0 + a);
} else {
tmp = fma(t, (x / y), z) / b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -470.0) || !(t <= 3.2e-7)) tmp = Float64(x / Float64(1.0 + a)); else tmp = Float64(fma(t, Float64(x / y), z) / b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -470.0], N[Not[LessEqual[t, 3.2e-7]], $MachinePrecision]], N[(x / N[(1.0 + a), $MachinePrecision]), $MachinePrecision], N[(N[(t * N[(x / y), $MachinePrecision] + z), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -470 \lor \neg \left(t \leq 3.2 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{x}{1 + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t, \frac{x}{y}, z\right)}{b}\\
\end{array}
\end{array}
if t < -470 or 3.2000000000000001e-7 < t Initial program 88.0%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6471.3
Applied rewrites71.3%
if -470 < t < 3.2000000000000001e-7Initial program 67.4%
Taylor expanded in y around -inf
lower-+.f64N/A
Applied rewrites54.1%
Taylor expanded in b around inf
Applied rewrites61.0%
Final simplification65.9%
(FPCore (x y z t a b)
:precision binary64
(if (<= t -5e+252)
(fma (- (* a x) x) a x)
(if (<= t -470.0)
(/ x a)
(if (<= t 2.4e+37) (/ z b) (if (<= t 6.8e+226) (/ x a) (/ x 1.0))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -5e+252) {
tmp = fma(((a * x) - x), a, x);
} else if (t <= -470.0) {
tmp = x / a;
} else if (t <= 2.4e+37) {
tmp = z / b;
} else if (t <= 6.8e+226) {
tmp = x / a;
} else {
tmp = x / 1.0;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -5e+252) tmp = fma(Float64(Float64(a * x) - x), a, x); elseif (t <= -470.0) tmp = Float64(x / a); elseif (t <= 2.4e+37) tmp = Float64(z / b); elseif (t <= 6.8e+226) tmp = Float64(x / a); else tmp = Float64(x / 1.0); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -5e+252], N[(N[(N[(a * x), $MachinePrecision] - x), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[t, -470.0], N[(x / a), $MachinePrecision], If[LessEqual[t, 2.4e+37], N[(z / b), $MachinePrecision], If[LessEqual[t, 6.8e+226], N[(x / a), $MachinePrecision], N[(x / 1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5 \cdot 10^{+252}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot x - x, a, x\right)\\
\mathbf{elif}\;t \leq -470:\\
\;\;\;\;\frac{x}{a}\\
\mathbf{elif}\;t \leq 2.4 \cdot 10^{+37}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{elif}\;t \leq 6.8 \cdot 10^{+226}:\\
\;\;\;\;\frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{1}\\
\end{array}
\end{array}
if t < -4.9999999999999997e252Initial program 79.1%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6479.5
Applied rewrites79.5%
Taylor expanded in a around 0
Applied rewrites58.9%
if -4.9999999999999997e252 < t < -470 or 2.4e37 < t < 6.79999999999999958e226Initial program 88.0%
Taylor expanded in a around inf
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6447.6
Applied rewrites47.6%
Taylor expanded in x around inf
Applied rewrites43.2%
if -470 < t < 2.4e37Initial program 68.7%
Taylor expanded in y around inf
lower-/.f6453.7
Applied rewrites53.7%
if 6.79999999999999958e226 < t Initial program 94.7%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6489.6
Applied rewrites89.6%
Taylor expanded in a around 0
Applied rewrites62.8%
(FPCore (x y z t a b)
:precision binary64
(if (<= t -5e+252)
(fma (- x) a x)
(if (<= t -470.0)
(/ x a)
(if (<= t 2.4e+37) (/ z b) (if (<= t 6.8e+226) (/ x a) (/ x 1.0))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -5e+252) {
tmp = fma(-x, a, x);
} else if (t <= -470.0) {
tmp = x / a;
} else if (t <= 2.4e+37) {
tmp = z / b;
} else if (t <= 6.8e+226) {
tmp = x / a;
} else {
tmp = x / 1.0;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -5e+252) tmp = fma(Float64(-x), a, x); elseif (t <= -470.0) tmp = Float64(x / a); elseif (t <= 2.4e+37) tmp = Float64(z / b); elseif (t <= 6.8e+226) tmp = Float64(x / a); else tmp = Float64(x / 1.0); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -5e+252], N[((-x) * a + x), $MachinePrecision], If[LessEqual[t, -470.0], N[(x / a), $MachinePrecision], If[LessEqual[t, 2.4e+37], N[(z / b), $MachinePrecision], If[LessEqual[t, 6.8e+226], N[(x / a), $MachinePrecision], N[(x / 1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5 \cdot 10^{+252}:\\
\;\;\;\;\mathsf{fma}\left(-x, a, x\right)\\
\mathbf{elif}\;t \leq -470:\\
\;\;\;\;\frac{x}{a}\\
\mathbf{elif}\;t \leq 2.4 \cdot 10^{+37}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{elif}\;t \leq 6.8 \cdot 10^{+226}:\\
\;\;\;\;\frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{1}\\
\end{array}
\end{array}
if t < -4.9999999999999997e252Initial program 79.1%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6479.5
Applied rewrites79.5%
Taylor expanded in a around 0
Applied rewrites58.0%
if -4.9999999999999997e252 < t < -470 or 2.4e37 < t < 6.79999999999999958e226Initial program 88.0%
Taylor expanded in a around inf
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6447.6
Applied rewrites47.6%
Taylor expanded in x around inf
Applied rewrites43.2%
if -470 < t < 2.4e37Initial program 68.7%
Taylor expanded in y around inf
lower-/.f6453.7
Applied rewrites53.7%
if 6.79999999999999958e226 < t Initial program 94.7%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6489.6
Applied rewrites89.6%
Taylor expanded in a around 0
Applied rewrites62.8%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -6e-21) (not (<= t 3.4e-23))) (/ x (+ 1.0 a)) (/ z b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -6e-21) || !(t <= 3.4e-23)) {
tmp = x / (1.0 + 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 ((t <= (-6d-21)) .or. (.not. (t <= 3.4d-23))) then
tmp = x / (1.0d0 + 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 ((t <= -6e-21) || !(t <= 3.4e-23)) {
tmp = x / (1.0 + a);
} else {
tmp = z / b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (t <= -6e-21) or not (t <= 3.4e-23): tmp = x / (1.0 + a) else: tmp = z / b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -6e-21) || !(t <= 3.4e-23)) tmp = Float64(x / Float64(1.0 + a)); else tmp = Float64(z / b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((t <= -6e-21) || ~((t <= 3.4e-23))) tmp = x / (1.0 + a); else tmp = z / b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -6e-21], N[Not[LessEqual[t, 3.4e-23]], $MachinePrecision]], N[(x / N[(1.0 + a), $MachinePrecision]), $MachinePrecision], N[(z / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6 \cdot 10^{-21} \lor \neg \left(t \leq 3.4 \cdot 10^{-23}\right):\\
\;\;\;\;\frac{x}{1 + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\
\end{array}
\end{array}
if t < -5.99999999999999982e-21 or 3.4000000000000001e-23 < t Initial program 87.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6468.6
Applied rewrites68.6%
if -5.99999999999999982e-21 < t < 3.4000000000000001e-23Initial program 66.0%
Taylor expanded in y around inf
lower-/.f6458.0
Applied rewrites58.0%
Final simplification63.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= a -390000000.0) (not (<= a 2.2e-20))) (/ x a) (fma (- x) a x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a <= -390000000.0) || !(a <= 2.2e-20)) {
tmp = x / a;
} else {
tmp = fma(-x, a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((a <= -390000000.0) || !(a <= 2.2e-20)) tmp = Float64(x / a); else tmp = fma(Float64(-x), a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[a, -390000000.0], N[Not[LessEqual[a, 2.2e-20]], $MachinePrecision]], N[(x / a), $MachinePrecision], N[((-x) * a + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -390000000 \lor \neg \left(a \leq 2.2 \cdot 10^{-20}\right):\\
\;\;\;\;\frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-x, a, x\right)\\
\end{array}
\end{array}
if a < -3.9e8 or 2.19999999999999991e-20 < a Initial program 73.8%
Taylor expanded in a around inf
lower-/.f64N/A
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6460.9
Applied rewrites60.9%
Taylor expanded in x around inf
Applied rewrites46.1%
if -3.9e8 < a < 2.19999999999999991e-20Initial program 80.7%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6443.0
Applied rewrites43.0%
Taylor expanded in a around 0
Applied rewrites42.9%
Final simplification44.5%
(FPCore (x y z t a b) :precision binary64 (fma (- x) a x))
double code(double x, double y, double z, double t, double a, double b) {
return fma(-x, a, x);
}
function code(x, y, z, t, a, b) return fma(Float64(-x), a, x) end
code[x_, y_, z_, t_, a_, b_] := N[((-x) * a + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-x, a, x\right)
\end{array}
Initial program 77.3%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6444.8
Applied rewrites44.8%
Taylor expanded in a around 0
Applied rewrites22.9%
(FPCore (x y z t a b) :precision binary64 (* (- x) a))
double code(double x, double y, double z, double t, double a, double b) {
return -x * a;
}
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 * a
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return -x * a;
}
def code(x, y, z, t, a, b): return -x * a
function code(x, y, z, t, a, b) return Float64(Float64(-x) * a) end
function tmp = code(x, y, z, t, a, b) tmp = -x * a; end
code[x_, y_, z_, t_, a_, b_] := N[((-x) * a), $MachinePrecision]
\begin{array}{l}
\\
\left(-x\right) \cdot a
\end{array}
Initial program 77.3%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6444.8
Applied rewrites44.8%
Taylor expanded in a around 0
Applied rewrites22.9%
Taylor expanded in a around inf
Applied rewrites4.7%
(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 2024359
(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))))