
(FPCore (x y z t a b) :precision binary64 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
def code(x, y, z, t, a, b): return ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y)))) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * (t - a))) / (y + (z * (b - y))); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
def code(x, y, z, t, a, b): return ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y)))) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * (t - a))) / (y + (z * (b - y))); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\end{array}
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (- b y) z y)))
(if (or (<= z -1.95e+59) (not (<= z 1400000000.0)))
(-
(fma (/ x z) (/ y (- b y)) (/ t (- b y)))
(fma (/ y z) (/ (- t a) (pow (- b y) 2.0)) (/ a (- b y))))
(fma x (/ y t_1) (/ (* (- t a) z) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((b - y), z, y);
double tmp;
if ((z <= -1.95e+59) || !(z <= 1400000000.0)) {
tmp = fma((x / z), (y / (b - y)), (t / (b - y))) - fma((y / z), ((t - a) / pow((b - y), 2.0)), (a / (b - y)));
} else {
tmp = fma(x, (y / t_1), (((t - a) * z) / t_1));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(b - y), z, y) tmp = 0.0 if ((z <= -1.95e+59) || !(z <= 1400000000.0)) tmp = Float64(fma(Float64(x / z), Float64(y / Float64(b - y)), Float64(t / Float64(b - y))) - fma(Float64(y / z), Float64(Float64(t - a) / (Float64(b - y) ^ 2.0)), Float64(a / Float64(b - y)))); else tmp = fma(x, Float64(y / t_1), Float64(Float64(Float64(t - a) * z) / t_1)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b - y), $MachinePrecision] * z + y), $MachinePrecision]}, If[Or[LessEqual[z, -1.95e+59], N[Not[LessEqual[z, 1400000000.0]], $MachinePrecision]], N[(N[(N[(x / z), $MachinePrecision] * N[(y / N[(b - y), $MachinePrecision]), $MachinePrecision] + N[(t / N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(y / z), $MachinePrecision] * N[(N[(t - a), $MachinePrecision] / N[Power[N[(b - y), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(a / N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / t$95$1), $MachinePrecision] + N[(N[(N[(t - a), $MachinePrecision] * z), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b - y, z, y\right)\\
\mathbf{if}\;z \leq -1.95 \cdot 10^{+59} \lor \neg \left(z \leq 1400000000\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \frac{y}{b - y}, \frac{t}{b - y}\right) - \mathsf{fma}\left(\frac{y}{z}, \frac{t - a}{{\left(b - y\right)}^{2}}, \frac{a}{b - y}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{t\_1}, \frac{\left(t - a\right) \cdot z}{t\_1}\right)\\
\end{array}
\end{array}
if z < -1.95000000000000011e59 or 1.4e9 < z Initial program 36.3%
Taylor expanded in z around inf
lower--.f64N/A
+-commutativeN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f64N/A
+-commutativeN/A
times-fracN/A
lower-fma.f64N/A
Applied rewrites90.2%
if -1.95000000000000011e59 < z < 1.4e9Initial program 90.1%
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-add-revN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
Applied rewrites97.1%
Final simplification94.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y))))))
(if (<= t_1 (- INFINITY))
(* (fma (/ z x) (/ (- t a) (fma (- b y) z y)) 1.0) x)
(if (<= t_1 -1e-269)
t_1
(if (<= t_1 0.0)
(/ (/ (fma (- t a) z (* y x)) b) z)
(if (<= t_1 5e+307) t_1 (/ (- t a) (- b y))))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma((z / x), ((t - a) / fma((b - y), z, y)), 1.0) * x;
} else if (t_1 <= -1e-269) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = (fma((t - a), z, (y * x)) / b) / z;
} else if (t_1 <= 5e+307) {
tmp = t_1;
} else {
tmp = (t - a) / (b - y);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(fma(Float64(z / x), Float64(Float64(t - a) / fma(Float64(b - y), z, y)), 1.0) * x); elseif (t_1 <= -1e-269) tmp = t_1; elseif (t_1 <= 0.0) tmp = Float64(Float64(fma(Float64(t - a), z, Float64(y * x)) / b) / z); elseif (t_1 <= 5e+307) tmp = t_1; else tmp = Float64(Float64(t - a) / Float64(b - y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(z / x), $MachinePrecision] * N[(N[(t - a), $MachinePrecision] / N[(N[(b - y), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$1, -1e-269], t$95$1, If[LessEqual[t$95$1, 0.0], N[(N[(N[(N[(t - a), $MachinePrecision] * z + N[(y * x), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$1, 5e+307], t$95$1, N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{x}, \frac{t - a}{\mathsf{fma}\left(b - y, z, y\right)}, 1\right) \cdot x\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-269}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(t - a, z, y \cdot x\right)}{b}}{z}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+307}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t - a}{b - y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -inf.0Initial program 28.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites92.0%
Taylor expanded in z around 0
Applied rewrites72.9%
if -inf.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -9.9999999999999996e-270 or 0.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 5e307Initial program 99.6%
if -9.9999999999999996e-270 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 0.0Initial program 19.3%
Taylor expanded in b around inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6473.9
Applied rewrites73.9%
if 5e307 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) Initial program 14.3%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f64N/A
lift--.f6472.0
Applied rewrites72.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
(t_2 (/ (- t a) (- b y))))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 -1e-269)
t_1
(if (<= t_1 0.0)
(/ (/ (fma (- t a) z (* y x)) b) z)
(if (<= t_1 5e+307) t_1 t_2))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
double t_2 = (t - a) / (b - y);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= -1e-269) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = (fma((t - a), z, (y * x)) / b) / z;
} else if (t_1 <= 5e+307) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y)))) t_2 = Float64(Float64(t - a) / Float64(b - y)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= -1e-269) tmp = t_1; elseif (t_1 <= 0.0) tmp = Float64(Float64(fma(Float64(t - a), z, Float64(y * x)) / b) / z); elseif (t_1 <= 5e+307) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, -1e-269], t$95$1, If[LessEqual[t$95$1, 0.0], N[(N[(N[(N[(t - a), $MachinePrecision] * z + N[(y * x), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$1, 5e+307], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\\
t_2 := \frac{t - a}{b - y}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-269}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(t - a, z, y \cdot x\right)}{b}}{z}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+307}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -inf.0 or 5e307 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) Initial program 18.6%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f64N/A
lift--.f6470.9
Applied rewrites70.9%
if -inf.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -9.9999999999999996e-270 or 0.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 5e307Initial program 99.6%
if -9.9999999999999996e-270 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 0.0Initial program 19.3%
Taylor expanded in b around inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6473.9
Applied rewrites73.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (- b y) z y)) (t_2 (/ (- t a) (- b y))))
(if (<= z -2.35e+120)
t_2
(if (<= z 3e+68)
(fma x (/ y t_1) (/ (* (- t a) z) t_1))
(fma
(/ (- (* x (/ y (- b y))) (/ (* (- t a) y) (pow (- b y) 2.0))) (- z))
-1.0
t_2)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((b - y), z, y);
double t_2 = (t - a) / (b - y);
double tmp;
if (z <= -2.35e+120) {
tmp = t_2;
} else if (z <= 3e+68) {
tmp = fma(x, (y / t_1), (((t - a) * z) / t_1));
} else {
tmp = fma((((x * (y / (b - y))) - (((t - a) * y) / pow((b - y), 2.0))) / -z), -1.0, t_2);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(b - y), z, y) t_2 = Float64(Float64(t - a) / Float64(b - y)) tmp = 0.0 if (z <= -2.35e+120) tmp = t_2; elseif (z <= 3e+68) tmp = fma(x, Float64(y / t_1), Float64(Float64(Float64(t - a) * z) / t_1)); else tmp = fma(Float64(Float64(Float64(x * Float64(y / Float64(b - y))) - Float64(Float64(Float64(t - a) * y) / (Float64(b - y) ^ 2.0))) / Float64(-z)), -1.0, t_2); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b - y), $MachinePrecision] * z + y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.35e+120], t$95$2, If[LessEqual[z, 3e+68], N[(x * N[(y / t$95$1), $MachinePrecision] + N[(N[(N[(t - a), $MachinePrecision] * z), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x * N[(y / N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(t - a), $MachinePrecision] * y), $MachinePrecision] / N[Power[N[(b - y), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-z)), $MachinePrecision] * -1.0 + t$95$2), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b - y, z, y\right)\\
t_2 := \frac{t - a}{b - y}\\
\mathbf{if}\;z \leq -2.35 \cdot 10^{+120}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \leq 3 \cdot 10^{+68}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{t\_1}, \frac{\left(t - a\right) \cdot z}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x \cdot \frac{y}{b - y} - \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}}{-z}, -1, t\_2\right)\\
\end{array}
\end{array}
if z < -2.34999999999999997e120Initial program 19.4%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f64N/A
lift--.f6481.6
Applied rewrites81.6%
if -2.34999999999999997e120 < z < 3.0000000000000002e68Initial program 87.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-add-revN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
Applied rewrites93.6%
if 3.0000000000000002e68 < z Initial program 32.1%
Taylor expanded in z around -inf
associate--l+N/A
*-commutativeN/A
div-subN/A
lower-fma.f64N/A
Applied rewrites80.1%
Final simplification89.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (- b y) z y)))
(if (or (<= z -2.35e+120) (not (<= z 2.35e+129)))
(/ (- t a) (- b y))
(fma x (/ y t_1) (/ (* (- t a) z) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((b - y), z, y);
double tmp;
if ((z <= -2.35e+120) || !(z <= 2.35e+129)) {
tmp = (t - a) / (b - y);
} else {
tmp = fma(x, (y / t_1), (((t - a) * z) / t_1));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(b - y), z, y) tmp = 0.0 if ((z <= -2.35e+120) || !(z <= 2.35e+129)) tmp = Float64(Float64(t - a) / Float64(b - y)); else tmp = fma(x, Float64(y / t_1), Float64(Float64(Float64(t - a) * z) / t_1)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b - y), $MachinePrecision] * z + y), $MachinePrecision]}, If[Or[LessEqual[z, -2.35e+120], N[Not[LessEqual[z, 2.35e+129]], $MachinePrecision]], N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / t$95$1), $MachinePrecision] + N[(N[(N[(t - a), $MachinePrecision] * z), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b - y, z, y\right)\\
\mathbf{if}\;z \leq -2.35 \cdot 10^{+120} \lor \neg \left(z \leq 2.35 \cdot 10^{+129}\right):\\
\;\;\;\;\frac{t - a}{b - y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{t\_1}, \frac{\left(t - a\right) \cdot z}{t\_1}\right)\\
\end{array}
\end{array}
if z < -2.34999999999999997e120 or 2.35000000000000004e129 < z Initial program 23.1%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f64N/A
lift--.f6483.7
Applied rewrites83.7%
if -2.34999999999999997e120 < z < 2.35000000000000004e129Initial program 84.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-add-revN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
Applied rewrites91.3%
Final simplification89.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -1.95e+59) (not (<= z 2.15e-14))) (/ (- t a) (- b y)) (fma x 1.0 (/ (* (- t a) z) (fma (- b y) z y)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -1.95e+59) || !(z <= 2.15e-14)) {
tmp = (t - a) / (b - y);
} else {
tmp = fma(x, 1.0, (((t - a) * z) / fma((b - y), z, y)));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -1.95e+59) || !(z <= 2.15e-14)) tmp = Float64(Float64(t - a) / Float64(b - y)); else tmp = fma(x, 1.0, Float64(Float64(Float64(t - a) * z) / fma(Float64(b - y), z, y))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -1.95e+59], N[Not[LessEqual[z, 2.15e-14]], $MachinePrecision]], N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision], N[(x * 1.0 + N[(N[(N[(t - a), $MachinePrecision] * z), $MachinePrecision] / N[(N[(b - y), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{+59} \lor \neg \left(z \leq 2.15 \cdot 10^{-14}\right):\\
\;\;\;\;\frac{t - a}{b - y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 1, \frac{\left(t - a\right) \cdot z}{\mathsf{fma}\left(b - y, z, y\right)}\right)\\
\end{array}
\end{array}
if z < -1.95000000000000011e59 or 2.14999999999999999e-14 < z Initial program 38.0%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f64N/A
lift--.f6473.6
Applied rewrites73.6%
if -1.95000000000000011e59 < z < 2.14999999999999999e-14Initial program 89.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-add-revN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
Applied rewrites97.1%
Taylor expanded in z around 0
Applied rewrites83.8%
Final simplification79.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- t a) (- b y))))
(if (<= z -7.5e-50)
t_1
(if (<= z 2.3e-230)
(/ (fma (- t a) z (* y x)) (fma (- y) z y))
(if (<= z 2.15e-14) (fma (/ (- t a) y) z x) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t - a) / (b - y);
double tmp;
if (z <= -7.5e-50) {
tmp = t_1;
} else if (z <= 2.3e-230) {
tmp = fma((t - a), z, (y * x)) / fma(-y, z, y);
} else if (z <= 2.15e-14) {
tmp = fma(((t - a) / y), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t - a) / Float64(b - y)) tmp = 0.0 if (z <= -7.5e-50) tmp = t_1; elseif (z <= 2.3e-230) tmp = Float64(fma(Float64(t - a), z, Float64(y * x)) / fma(Float64(-y), z, y)); elseif (z <= 2.15e-14) tmp = fma(Float64(Float64(t - a) / y), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.5e-50], t$95$1, If[LessEqual[z, 2.3e-230], N[(N[(N[(t - a), $MachinePrecision] * z + N[(y * x), $MachinePrecision]), $MachinePrecision] / N[((-y) * z + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.15e-14], N[(N[(N[(t - a), $MachinePrecision] / y), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - a}{b - y}\\
\mathbf{if}\;z \leq -7.5 \cdot 10^{-50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{-230}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t - a, z, y \cdot x\right)}{\mathsf{fma}\left(-y, z, y\right)}\\
\mathbf{elif}\;z \leq 2.15 \cdot 10^{-14}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - a}{y}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -7.5e-50 or 2.14999999999999999e-14 < z Initial program 45.8%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f64N/A
lift--.f6471.1
Applied rewrites71.1%
if -7.5e-50 < z < 2.2999999999999998e-230Initial program 93.7%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f6475.6
Applied rewrites75.6%
if 2.2999999999999998e-230 < z < 2.14999999999999999e-14Initial program 83.6%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
div-add-revN/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6456.2
Applied rewrites56.2%
Taylor expanded in x around 0
Applied rewrites74.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- t a) (- b y))))
(if (<= z -7.5e-50)
t_1
(if (<= z 2.3e-230)
(/ (fma x y (* z (- t a))) y)
(if (<= z 2.15e-14) (fma (/ (- t a) y) z x) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t - a) / (b - y);
double tmp;
if (z <= -7.5e-50) {
tmp = t_1;
} else if (z <= 2.3e-230) {
tmp = fma(x, y, (z * (t - a))) / y;
} else if (z <= 2.15e-14) {
tmp = fma(((t - a) / y), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t - a) / Float64(b - y)) tmp = 0.0 if (z <= -7.5e-50) tmp = t_1; elseif (z <= 2.3e-230) tmp = Float64(fma(x, y, Float64(z * Float64(t - a))) / y); elseif (z <= 2.15e-14) tmp = fma(Float64(Float64(t - a) / y), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.5e-50], t$95$1, If[LessEqual[z, 2.3e-230], N[(N[(x * y + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[z, 2.15e-14], N[(N[(N[(t - a), $MachinePrecision] / y), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - a}{b - y}\\
\mathbf{if}\;z \leq -7.5 \cdot 10^{-50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{-230}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)}{y}\\
\mathbf{elif}\;z \leq 2.15 \cdot 10^{-14}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - a}{y}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -7.5e-50 or 2.14999999999999999e-14 < z Initial program 45.8%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f64N/A
lift--.f6471.1
Applied rewrites71.1%
if -7.5e-50 < z < 2.2999999999999998e-230Initial program 93.7%
Taylor expanded in z around 0
Applied rewrites75.6%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
lift--.f6475.6
Applied rewrites75.6%
if 2.2999999999999998e-230 < z < 2.14999999999999999e-14Initial program 83.6%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
div-add-revN/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6456.2
Applied rewrites56.2%
Taylor expanded in x around 0
Applied rewrites74.8%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -1.4e-49) (not (<= z 2.15e-14))) (/ (- t a) (- b y)) (fma (/ (- t a) y) z x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -1.4e-49) || !(z <= 2.15e-14)) {
tmp = (t - a) / (b - y);
} else {
tmp = fma(((t - a) / y), z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -1.4e-49) || !(z <= 2.15e-14)) tmp = Float64(Float64(t - a) / Float64(b - y)); else tmp = fma(Float64(Float64(t - a) / y), z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -1.4e-49], N[Not[LessEqual[z, 2.15e-14]], $MachinePrecision]], N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t - a), $MachinePrecision] / y), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{-49} \lor \neg \left(z \leq 2.15 \cdot 10^{-14}\right):\\
\;\;\;\;\frac{t - a}{b - y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - a}{y}, z, x\right)\\
\end{array}
\end{array}
if z < -1.39999999999999999e-49 or 2.14999999999999999e-14 < z Initial program 45.8%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f64N/A
lift--.f6471.1
Applied rewrites71.1%
if -1.39999999999999999e-49 < z < 2.14999999999999999e-14Initial program 89.9%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
div-add-revN/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6458.6
Applied rewrites58.6%
Taylor expanded in x around 0
Applied rewrites70.6%
Final simplification70.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -2.3e-53) (not (<= z 3.4e-16))) (/ (- t a) (- b y)) (fma (/ t y) z x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -2.3e-53) || !(z <= 3.4e-16)) {
tmp = (t - a) / (b - y);
} else {
tmp = fma((t / y), z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -2.3e-53) || !(z <= 3.4e-16)) tmp = Float64(Float64(t - a) / Float64(b - y)); else tmp = fma(Float64(t / y), z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -2.3e-53], N[Not[LessEqual[z, 3.4e-16]], $MachinePrecision]], N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision], N[(N[(t / y), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{-53} \lor \neg \left(z \leq 3.4 \cdot 10^{-16}\right):\\
\;\;\;\;\frac{t - a}{b - y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{y}, z, x\right)\\
\end{array}
\end{array}
if z < -2.3000000000000001e-53 or 3.4e-16 < z Initial program 45.8%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f64N/A
lift--.f6471.1
Applied rewrites71.1%
if -2.3000000000000001e-53 < z < 3.4e-16Initial program 89.9%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
div-add-revN/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6458.6
Applied rewrites58.6%
Taylor expanded in t around inf
Applied rewrites57.4%
Final simplification64.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -2.1e-53) (not (<= z 3.3e-16))) (/ (- t a) (- b y)) (fma x z x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -2.1e-53) || !(z <= 3.3e-16)) {
tmp = (t - a) / (b - y);
} else {
tmp = fma(x, z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -2.1e-53) || !(z <= 3.3e-16)) tmp = Float64(Float64(t - a) / Float64(b - y)); else tmp = fma(x, z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -2.1e-53], N[Not[LessEqual[z, 3.3e-16]], $MachinePrecision]], N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision], N[(x * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{-53} \lor \neg \left(z \leq 3.3 \cdot 10^{-16}\right):\\
\;\;\;\;\frac{t - a}{b - y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\end{array}
\end{array}
if z < -2.09999999999999977e-53 or 3.29999999999999988e-16 < z Initial program 45.8%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f64N/A
lift--.f6471.1
Applied rewrites71.1%
if -2.09999999999999977e-53 < z < 3.29999999999999988e-16Initial program 89.9%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
div-add-revN/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6458.6
Applied rewrites58.6%
Taylor expanded in y around inf
Applied rewrites43.8%
Final simplification58.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -2.1e-12) (not (<= y 205.0))) (/ (- x) (- z 1.0)) (/ (- t a) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -2.1e-12) || !(y <= 205.0)) {
tmp = -x / (z - 1.0);
} else {
tmp = (t - a) / b;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((y <= (-2.1d-12)) .or. (.not. (y <= 205.0d0))) then
tmp = -x / (z - 1.0d0)
else
tmp = (t - a) / b
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -2.1e-12) || !(y <= 205.0)) {
tmp = -x / (z - 1.0);
} else {
tmp = (t - a) / b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (y <= -2.1e-12) or not (y <= 205.0): tmp = -x / (z - 1.0) else: tmp = (t - a) / b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -2.1e-12) || !(y <= 205.0)) tmp = Float64(Float64(-x) / Float64(z - 1.0)); else tmp = Float64(Float64(t - a) / b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((y <= -2.1e-12) || ~((y <= 205.0))) tmp = -x / (z - 1.0); else tmp = (t - a) / b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -2.1e-12], N[Not[LessEqual[y, 205.0]], $MachinePrecision]], N[((-x) / N[(z - 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t - a), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{-12} \lor \neg \left(y \leq 205\right):\\
\;\;\;\;\frac{-x}{z - 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t - a}{b}\\
\end{array}
\end{array}
if y < -2.09999999999999994e-12 or 205 < y Initial program 62.1%
Taylor expanded in y around -inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f6450.0
Applied rewrites50.0%
if -2.09999999999999994e-12 < y < 205Initial program 71.7%
Taylor expanded in y around 0
lower-/.f64N/A
lift--.f6449.4
Applied rewrites49.4%
Final simplification49.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -2.2e-53) (not (<= z 2.1e-22))) (/ (- t a) b) x))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -2.2e-53) || !(z <= 2.1e-22)) {
tmp = (t - a) / 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 ((z <= (-2.2d-53)) .or. (.not. (z <= 2.1d-22))) then
tmp = (t - a) / 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 ((z <= -2.2e-53) || !(z <= 2.1e-22)) {
tmp = (t - a) / b;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z <= -2.2e-53) or not (z <= 2.1e-22): tmp = (t - a) / b else: tmp = x return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -2.2e-53) || !(z <= 2.1e-22)) tmp = Float64(Float64(t - a) / b); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((z <= -2.2e-53) || ~((z <= 2.1e-22))) tmp = (t - a) / b; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -2.2e-53], N[Not[LessEqual[z, 2.1e-22]], $MachinePrecision]], N[(N[(t - a), $MachinePrecision] / b), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{-53} \lor \neg \left(z \leq 2.1 \cdot 10^{-22}\right):\\
\;\;\;\;\frac{t - a}{b}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.20000000000000018e-53 or 2.10000000000000008e-22 < z Initial program 45.9%
Taylor expanded in y around 0
lower-/.f64N/A
lift--.f6447.4
Applied rewrites47.4%
if -2.20000000000000018e-53 < z < 2.10000000000000008e-22Initial program 90.4%
Taylor expanded in z around 0
Applied rewrites43.6%
Final simplification45.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -1.95e-50) (not (<= z 8.2e-16))) (/ t (- b y)) (fma x z x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -1.95e-50) || !(z <= 8.2e-16)) {
tmp = t / (b - y);
} else {
tmp = fma(x, z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -1.95e-50) || !(z <= 8.2e-16)) tmp = Float64(t / Float64(b - y)); else tmp = fma(x, z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -1.95e-50], N[Not[LessEqual[z, 8.2e-16]], $MachinePrecision]], N[(t / N[(b - y), $MachinePrecision]), $MachinePrecision], N[(x * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{-50} \lor \neg \left(z \leq 8.2 \cdot 10^{-16}\right):\\
\;\;\;\;\frac{t}{b - y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\end{array}
\end{array}
if z < -1.9500000000000001e-50 or 8.20000000000000012e-16 < z Initial program 45.8%
Taylor expanded in t around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6426.7
Applied rewrites26.7%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f6437.9
Applied rewrites37.9%
if -1.9500000000000001e-50 < z < 8.20000000000000012e-16Initial program 89.9%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
div-add-revN/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6458.6
Applied rewrites58.6%
Taylor expanded in y around inf
Applied rewrites43.8%
Final simplification40.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -1.95e-50) (not (<= z 2.1e-22))) (/ t b) x))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -1.95e-50) || !(z <= 2.1e-22)) {
tmp = t / 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 ((z <= (-1.95d-50)) .or. (.not. (z <= 2.1d-22))) then
tmp = t / 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 ((z <= -1.95e-50) || !(z <= 2.1e-22)) {
tmp = t / b;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z <= -1.95e-50) or not (z <= 2.1e-22): tmp = t / b else: tmp = x return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -1.95e-50) || !(z <= 2.1e-22)) tmp = Float64(t / b); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((z <= -1.95e-50) || ~((z <= 2.1e-22))) tmp = t / b; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -1.95e-50], N[Not[LessEqual[z, 2.1e-22]], $MachinePrecision]], N[(t / b), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{-50} \lor \neg \left(z \leq 2.1 \cdot 10^{-22}\right):\\
\;\;\;\;\frac{t}{b}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.9500000000000001e-50 or 2.10000000000000008e-22 < z Initial program 45.9%
Taylor expanded in b around inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6433.0
Applied rewrites33.0%
Taylor expanded in t around inf
lower-/.f6426.0
Applied rewrites26.0%
if -1.9500000000000001e-50 < z < 2.10000000000000008e-22Initial program 90.4%
Taylor expanded in z around 0
Applied rewrites43.6%
Final simplification34.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 66.8%
Taylor expanded in z around 0
Applied rewrites23.1%
(FPCore (x y z t a b) :precision binary64 (- (/ (+ (* z t) (* y x)) (+ y (* z (- b y)))) (/ a (+ (- b y) (/ y z)))))
double code(double x, double y, double z, double t, double a, double b) {
return (((z * t) + (y * x)) / (y + (z * (b - y)))) - (a / ((b - y) + (y / z)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (((z * t) + (y * x)) / (y + (z * (b - y)))) - (a / ((b - y) + (y / z)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((z * t) + (y * x)) / (y + (z * (b - y)))) - (a / ((b - y) + (y / z)));
}
def code(x, y, z, t, a, b): return (((z * t) + (y * x)) / (y + (z * (b - y)))) - (a / ((b - y) + (y / z)))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(z * t) + Float64(y * x)) / Float64(y + Float64(z * Float64(b - y)))) - Float64(a / Float64(Float64(b - y) + Float64(y / z)))) end
function tmp = code(x, y, z, t, a, b) tmp = (((z * t) + (y * x)) / (y + (z * (b - y)))) - (a / ((b - y) + (y / z))); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(z * t), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / N[(N[(b - y), $MachinePrecision] + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{z \cdot t + y \cdot x}{y + z \cdot \left(b - y\right)} - \frac{a}{\left(b - y\right) + \frac{y}{z}}
\end{array}
herbie shell --seed 2025037
(FPCore (x y z t a b)
:name "Development.Shake.Progress:decay from shake-0.15.5"
:precision binary64
:alt
(! :herbie-platform default (- (/ (+ (* z t) (* y x)) (+ y (* z (- b y)))) (/ a (+ (- b y) (/ y z)))))
(/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))