
(FPCore (x y z t a) :precision binary64 (+ x (* (- y z) (/ (- t x) (- a z)))))
double code(double x, double y, double z, double t, double a) {
return x + ((y - z) * ((t - x) / (a - 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)
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
code = x + ((y - z) * ((t - x) / (a - z)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y - z) * ((t - x) / (a - z)));
}
def code(x, y, z, t, a): return x + ((y - z) * ((t - x) / (a - z)))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y - z) * Float64(Float64(t - x) / Float64(a - z)))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y - z) * ((t - x) / (a - z))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \frac{t - x}{a - z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (* (- y z) (/ (- t x) (- a z)))))
double code(double x, double y, double z, double t, double a) {
return x + ((y - z) * ((t - x) / (a - 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)
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
code = x + ((y - z) * ((t - x) / (a - z)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y - z) * ((t - x) / (a - z)));
}
def code(x, y, z, t, a): return x + ((y - z) * ((t - x) / (a - z)))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y - z) * Float64(Float64(t - x) / Float64(a - z)))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y - z) * ((t - x) / (a - z))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \frac{t - x}{a - z}
\end{array}
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- t x) (- a z))) (t_2 (+ x (* (- y z) t_1))))
(if (<= t_2 -5e-234)
(fma (- (/ t (- a z)) (/ x (- a z))) (- y z) x)
(if (<= t_2 0.0)
(+ t (* (- x) (/ (- a y) z)))
(if (<= t_2 5e+17)
(* x (+ (- 1.0 (/ (- y z) (- a z))) (/ (* t (- y z)) (* x (- a z)))))
(fma t_1 (- y z) x))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) / (a - z);
double t_2 = x + ((y - z) * t_1);
double tmp;
if (t_2 <= -5e-234) {
tmp = fma(((t / (a - z)) - (x / (a - z))), (y - z), x);
} else if (t_2 <= 0.0) {
tmp = t + (-x * ((a - y) / z));
} else if (t_2 <= 5e+17) {
tmp = x * ((1.0 - ((y - z) / (a - z))) + ((t * (y - z)) / (x * (a - z))));
} else {
tmp = fma(t_1, (y - z), x);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) / Float64(a - z)) t_2 = Float64(x + Float64(Float64(y - z) * t_1)) tmp = 0.0 if (t_2 <= -5e-234) tmp = fma(Float64(Float64(t / Float64(a - z)) - Float64(x / Float64(a - z))), Float64(y - z), x); elseif (t_2 <= 0.0) tmp = Float64(t + Float64(Float64(-x) * Float64(Float64(a - y) / z))); elseif (t_2 <= 5e+17) tmp = Float64(x * Float64(Float64(1.0 - Float64(Float64(y - z) / Float64(a - z))) + Float64(Float64(t * Float64(y - z)) / Float64(x * Float64(a - z))))); else tmp = fma(t_1, Float64(y - z), x); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y - z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-234], N[(N[(N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision] - N[(x / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(t + N[((-x) * N[(N[(a - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+17], N[(x * N[(N[(1.0 - N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(x * N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(y - z), $MachinePrecision] + x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - x}{a - z}\\
t_2 := x + \left(y - z\right) \cdot t\_1\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-234}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a - z} - \frac{x}{a - z}, y - z, x\right)\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;t + \left(-x\right) \cdot \frac{a - y}{z}\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+17}:\\
\;\;\;\;x \cdot \left(\left(1 - \frac{y - z}{a - z}\right) + \frac{t \cdot \left(y - z\right)}{x \cdot \left(a - z\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, y - z, x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -4.99999999999999979e-234Initial program 92.7%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6492.9
Applied rewrites92.9%
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
sub-divN/A
lower--.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6492.9
Applied rewrites92.9%
if -4.99999999999999979e-234 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 0.0Initial program 6.4%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f647.6
Applied rewrites7.6%
Taylor expanded in z around -inf
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lift--.f64N/A
lower--.f6483.5
Applied rewrites83.5%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6498.8
Applied rewrites98.8%
if 0.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 5e17Initial program 77.1%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6477.1
Applied rewrites77.1%
Taylor expanded in x around inf
lower-*.f64N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
sub-divN/A
mul-1-negN/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lower-/.f64N/A
Applied rewrites97.9%
if 5e17 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 94.7%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6494.7
Applied rewrites94.7%
Final simplification95.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- t x) (- a z))) (t_2 (+ x (* (- y z) t_1))))
(if (or (<= t_2 -5e-234) (not (<= t_2 0.0)))
(fma t_1 (- y z) x)
(+ t (* (- x) (/ (- a y) z))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) / (a - z);
double t_2 = x + ((y - z) * t_1);
double tmp;
if ((t_2 <= -5e-234) || !(t_2 <= 0.0)) {
tmp = fma(t_1, (y - z), x);
} else {
tmp = t + (-x * ((a - y) / z));
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) / Float64(a - z)) t_2 = Float64(x + Float64(Float64(y - z) * t_1)) tmp = 0.0 if ((t_2 <= -5e-234) || !(t_2 <= 0.0)) tmp = fma(t_1, Float64(y - z), x); else tmp = Float64(t + Float64(Float64(-x) * Float64(Float64(a - y) / z))); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y - z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -5e-234], N[Not[LessEqual[t$95$2, 0.0]], $MachinePrecision]], N[(t$95$1 * N[(y - z), $MachinePrecision] + x), $MachinePrecision], N[(t + N[((-x) * N[(N[(a - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - x}{a - z}\\
t_2 := x + \left(y - z\right) \cdot t\_1\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-234} \lor \neg \left(t\_2 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(t\_1, y - z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t + \left(-x\right) \cdot \frac{a - y}{z}\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -4.99999999999999979e-234 or 0.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 90.7%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6490.8
Applied rewrites90.8%
if -4.99999999999999979e-234 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 0.0Initial program 6.4%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f647.6
Applied rewrites7.6%
Taylor expanded in z around -inf
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lift--.f64N/A
lower--.f6483.5
Applied rewrites83.5%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6498.8
Applied rewrites98.8%
Final simplification91.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- t x) (- a z))) (t_2 (+ x (* (- y z) t_1))))
(if (or (<= t_2 -5e-234) (not (<= t_2 0.0)))
(fma t_1 (- y z) x)
(+ t (/ (* x (- y a)) z)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) / (a - z);
double t_2 = x + ((y - z) * t_1);
double tmp;
if ((t_2 <= -5e-234) || !(t_2 <= 0.0)) {
tmp = fma(t_1, (y - z), x);
} else {
tmp = t + ((x * (y - a)) / z);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) / Float64(a - z)) t_2 = Float64(x + Float64(Float64(y - z) * t_1)) tmp = 0.0 if ((t_2 <= -5e-234) || !(t_2 <= 0.0)) tmp = fma(t_1, Float64(y - z), x); else tmp = Float64(t + Float64(Float64(x * Float64(y - a)) / z)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y - z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -5e-234], N[Not[LessEqual[t$95$2, 0.0]], $MachinePrecision]], N[(t$95$1 * N[(y - z), $MachinePrecision] + x), $MachinePrecision], N[(t + N[(N[(x * N[(y - a), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - x}{a - z}\\
t_2 := x + \left(y - z\right) \cdot t\_1\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-234} \lor \neg \left(t\_2 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(t\_1, y - z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t + \frac{x \cdot \left(y - a\right)}{z}\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -4.99999999999999979e-234 or 0.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 90.7%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6490.8
Applied rewrites90.8%
if -4.99999999999999979e-234 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 0.0Initial program 6.4%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f647.6
Applied rewrites7.6%
Taylor expanded in z around -inf
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lift--.f64N/A
lower--.f6483.5
Applied rewrites83.5%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lift--.f6483.5
Applied rewrites83.5%
Final simplification89.8%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- t x) (- a z))) (t_2 (+ x (* (- y z) t_1))))
(if (<= t_2 -5e-234)
(fma (- (/ t (- a z)) (/ x (- a z))) (- y z) x)
(if (<= t_2 0.0) (+ t (* (- x) (/ (- a y) z))) (fma t_1 (- y z) x)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) / (a - z);
double t_2 = x + ((y - z) * t_1);
double tmp;
if (t_2 <= -5e-234) {
tmp = fma(((t / (a - z)) - (x / (a - z))), (y - z), x);
} else if (t_2 <= 0.0) {
tmp = t + (-x * ((a - y) / z));
} else {
tmp = fma(t_1, (y - z), x);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) / Float64(a - z)) t_2 = Float64(x + Float64(Float64(y - z) * t_1)) tmp = 0.0 if (t_2 <= -5e-234) tmp = fma(Float64(Float64(t / Float64(a - z)) - Float64(x / Float64(a - z))), Float64(y - z), x); elseif (t_2 <= 0.0) tmp = Float64(t + Float64(Float64(-x) * Float64(Float64(a - y) / z))); else tmp = fma(t_1, Float64(y - z), x); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y - z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-234], N[(N[(N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision] - N[(x / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(t + N[((-x) * N[(N[(a - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(y - z), $MachinePrecision] + x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - x}{a - z}\\
t_2 := x + \left(y - z\right) \cdot t\_1\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-234}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a - z} - \frac{x}{a - z}, y - z, x\right)\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;t + \left(-x\right) \cdot \frac{a - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, y - z, x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -4.99999999999999979e-234Initial program 92.7%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6492.9
Applied rewrites92.9%
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
sub-divN/A
lower--.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6492.9
Applied rewrites92.9%
if -4.99999999999999979e-234 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 0.0Initial program 6.4%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f647.6
Applied rewrites7.6%
Taylor expanded in z around -inf
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lift--.f64N/A
lower--.f6483.5
Applied rewrites83.5%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6498.8
Applied rewrites98.8%
if 0.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 88.8%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6488.9
Applied rewrites88.9%
Final simplification91.9%
(FPCore (x y z t a)
:precision binary64
(if (<= a -9e-90)
(fma (- t x) (/ (- y z) a) x)
(if (<= a 6e-78)
(- t (/ (* y (- t x)) z))
(if (<= a 1.35e+82) (* t (/ (- y z) (- a z))) (fma y (/ (- t x) a) x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -9e-90) {
tmp = fma((t - x), ((y - z) / a), x);
} else if (a <= 6e-78) {
tmp = t - ((y * (t - x)) / z);
} else if (a <= 1.35e+82) {
tmp = t * ((y - z) / (a - z));
} else {
tmp = fma(y, ((t - x) / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -9e-90) tmp = fma(Float64(t - x), Float64(Float64(y - z) / a), x); elseif (a <= 6e-78) tmp = Float64(t - Float64(Float64(y * Float64(t - x)) / z)); elseif (a <= 1.35e+82) tmp = Float64(t * Float64(Float64(y - z) / Float64(a - z))); else tmp = fma(y, Float64(Float64(t - x) / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -9e-90], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[a, 6e-78], N[(t - N[(N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.35e+82], N[(t * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{-90}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\mathbf{elif}\;a \leq 6 \cdot 10^{-78}:\\
\;\;\;\;t - \frac{y \cdot \left(t - x\right)}{z}\\
\mathbf{elif}\;a \leq 1.35 \cdot 10^{+82}:\\
\;\;\;\;t \cdot \frac{y - z}{a - z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\end{array}
\end{array}
if a < -9.00000000000000017e-90Initial program 80.5%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6468.1
Applied rewrites68.1%
if -9.00000000000000017e-90 < a < 5.99999999999999975e-78Initial program 69.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6467.6
Applied rewrites67.6%
Taylor expanded in z around inf
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift--.f6486.5
Applied rewrites86.5%
if 5.99999999999999975e-78 < a < 1.35e82Initial program 78.9%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6479.1
Applied rewrites79.1%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6472.3
Applied rewrites72.3%
if 1.35e82 < a Initial program 95.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6484.3
Applied rewrites84.3%
Final simplification78.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma y (/ (- t x) a) x)))
(if (<= a -2.35e+148)
t_1
(if (<= a -4e-68)
(* t (/ (- y z) (- a z)))
(if (<= a 5.8e+80) (fma (- y) (/ (- t x) z) t) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(y, ((t - x) / a), x);
double tmp;
if (a <= -2.35e+148) {
tmp = t_1;
} else if (a <= -4e-68) {
tmp = t * ((y - z) / (a - z));
} else if (a <= 5.8e+80) {
tmp = fma(-y, ((t - x) / z), t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(y, Float64(Float64(t - x) / a), x) tmp = 0.0 if (a <= -2.35e+148) tmp = t_1; elseif (a <= -4e-68) tmp = Float64(t * Float64(Float64(y - z) / Float64(a - z))); elseif (a <= 5.8e+80) tmp = fma(Float64(-y), Float64(Float64(t - x) / z), t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -2.35e+148], t$95$1, If[LessEqual[a, -4e-68], N[(t * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5.8e+80], N[((-y) * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{if}\;a \leq -2.35 \cdot 10^{+148}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -4 \cdot 10^{-68}:\\
\;\;\;\;t \cdot \frac{y - z}{a - z}\\
\mathbf{elif}\;a \leq 5.8 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{t - x}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -2.3499999999999999e148 or 5.79999999999999971e80 < a Initial program 94.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6480.1
Applied rewrites80.1%
if -2.3499999999999999e148 < a < -4.00000000000000027e-68Initial program 64.1%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6464.9
Applied rewrites64.9%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6456.9
Applied rewrites56.9%
if -4.00000000000000027e-68 < a < 5.79999999999999971e80Initial program 73.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6463.5
Applied rewrites63.5%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift--.f6446.2
Applied rewrites46.2%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6477.6
Applied rewrites77.6%
Final simplification75.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma y (/ (- t x) a) x)))
(if (<= a -4.8e+119)
t_1
(if (<= a -0.088)
(* (- x) (/ (- a y) z))
(if (<= a 400000.0) (* (- t) (- (/ y z) 1.0)) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(y, ((t - x) / a), x);
double tmp;
if (a <= -4.8e+119) {
tmp = t_1;
} else if (a <= -0.088) {
tmp = -x * ((a - y) / z);
} else if (a <= 400000.0) {
tmp = -t * ((y / z) - 1.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(y, Float64(Float64(t - x) / a), x) tmp = 0.0 if (a <= -4.8e+119) tmp = t_1; elseif (a <= -0.088) tmp = Float64(Float64(-x) * Float64(Float64(a - y) / z)); elseif (a <= 400000.0) tmp = Float64(Float64(-t) * Float64(Float64(y / z) - 1.0)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -4.8e+119], t$95$1, If[LessEqual[a, -0.088], N[((-x) * N[(N[(a - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 400000.0], N[((-t) * N[(N[(y / z), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{if}\;a \leq -4.8 \cdot 10^{+119}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -0.088:\\
\;\;\;\;\left(-x\right) \cdot \frac{a - y}{z}\\
\mathbf{elif}\;a \leq 400000:\\
\;\;\;\;\left(-t\right) \cdot \left(\frac{y}{z} - 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -4.8e119 or 4e5 < a Initial program 93.2%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6473.3
Applied rewrites73.3%
if -4.8e119 < a < -0.087999999999999995Initial program 51.0%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6452.2
Applied rewrites52.2%
Taylor expanded in z around -inf
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lift--.f64N/A
lower--.f6441.8
Applied rewrites41.8%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6450.7
Applied rewrites50.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lift-/.f64N/A
lift--.f6450.7
Applied rewrites50.7%
if -0.087999999999999995 < a < 4e5Initial program 72.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6462.2
Applied rewrites62.2%
Taylor expanded in t around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6455.9
Applied rewrites55.9%
Final simplification62.6%
(FPCore (x y z t a)
:precision binary64
(if (<= a -4.1e-91)
(+ x (* (- y z) (/ t (- a z))))
(if (<= a 9.5e-44)
(- t (/ (* y (- t x)) z))
(+ x (* y (/ (- t x) (- a z)))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -4.1e-91) {
tmp = x + ((y - z) * (t / (a - z)));
} else if (a <= 9.5e-44) {
tmp = t - ((y * (t - x)) / z);
} else {
tmp = x + (y * ((t - x) / (a - z)));
}
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)
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) :: tmp
if (a <= (-4.1d-91)) then
tmp = x + ((y - z) * (t / (a - z)))
else if (a <= 9.5d-44) then
tmp = t - ((y * (t - x)) / z)
else
tmp = x + (y * ((t - x) / (a - z)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -4.1e-91) {
tmp = x + ((y - z) * (t / (a - z)));
} else if (a <= 9.5e-44) {
tmp = t - ((y * (t - x)) / z);
} else {
tmp = x + (y * ((t - x) / (a - z)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -4.1e-91: tmp = x + ((y - z) * (t / (a - z))) elif a <= 9.5e-44: tmp = t - ((y * (t - x)) / z) else: tmp = x + (y * ((t - x) / (a - z))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -4.1e-91) tmp = Float64(x + Float64(Float64(y - z) * Float64(t / Float64(a - z)))); elseif (a <= 9.5e-44) tmp = Float64(t - Float64(Float64(y * Float64(t - x)) / z)); else tmp = Float64(x + Float64(y * Float64(Float64(t - x) / Float64(a - z)))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -4.1e-91) tmp = x + ((y - z) * (t / (a - z))); elseif (a <= 9.5e-44) tmp = t - ((y * (t - x)) / z); else tmp = x + (y * ((t - x) / (a - z))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -4.1e-91], N[(x + N[(N[(y - z), $MachinePrecision] * N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 9.5e-44], N[(t - N[(N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.1 \cdot 10^{-91}:\\
\;\;\;\;x + \left(y - z\right) \cdot \frac{t}{a - z}\\
\mathbf{elif}\;a \leq 9.5 \cdot 10^{-44}:\\
\;\;\;\;t - \frac{y \cdot \left(t - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{t - x}{a - z}\\
\end{array}
\end{array}
if a < -4.10000000000000024e-91Initial program 80.5%
Taylor expanded in x around 0
Applied rewrites72.2%
if -4.10000000000000024e-91 < a < 9.49999999999999924e-44Initial program 69.7%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6468.0
Applied rewrites68.0%
Taylor expanded in z around inf
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift--.f6485.9
Applied rewrites85.9%
if 9.49999999999999924e-44 < a Initial program 91.0%
Taylor expanded in y around inf
Applied rewrites81.5%
Final simplification80.2%
(FPCore (x y z t a)
:precision binary64
(if (<= a -9e-90)
(fma (- t x) (/ (- y z) a) x)
(if (<= a 9.5e-44)
(- t (/ (* y (- t x)) z))
(+ x (* y (/ (- t x) (- a z)))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -9e-90) {
tmp = fma((t - x), ((y - z) / a), x);
} else if (a <= 9.5e-44) {
tmp = t - ((y * (t - x)) / z);
} else {
tmp = x + (y * ((t - x) / (a - z)));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -9e-90) tmp = fma(Float64(t - x), Float64(Float64(y - z) / a), x); elseif (a <= 9.5e-44) tmp = Float64(t - Float64(Float64(y * Float64(t - x)) / z)); else tmp = Float64(x + Float64(y * Float64(Float64(t - x) / Float64(a - z)))); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -9e-90], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[a, 9.5e-44], N[(t - N[(N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{-90}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\mathbf{elif}\;a \leq 9.5 \cdot 10^{-44}:\\
\;\;\;\;t - \frac{y \cdot \left(t - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{t - x}{a - z}\\
\end{array}
\end{array}
if a < -9.00000000000000017e-90Initial program 80.5%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6468.1
Applied rewrites68.1%
if -9.00000000000000017e-90 < a < 9.49999999999999924e-44Initial program 69.7%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6468.0
Applied rewrites68.0%
Taylor expanded in z around inf
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift--.f6485.9
Applied rewrites85.9%
if 9.49999999999999924e-44 < a Initial program 91.0%
Taylor expanded in y around inf
Applied rewrites81.5%
Final simplification78.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -4.8e+119) (not (<= a 5.8e+80))) (fma y (/ (- t x) a) x) (fma (- y) (/ (- t x) z) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -4.8e+119) || !(a <= 5.8e+80)) {
tmp = fma(y, ((t - x) / a), x);
} else {
tmp = fma(-y, ((t - x) / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -4.8e+119) || !(a <= 5.8e+80)) tmp = fma(y, Float64(Float64(t - x) / a), x); else tmp = fma(Float64(-y), Float64(Float64(t - x) / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -4.8e+119], N[Not[LessEqual[a, 5.8e+80]], $MachinePrecision]], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[((-y) * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.8 \cdot 10^{+119} \lor \neg \left(a \leq 5.8 \cdot 10^{+80}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{t - x}{z}, t\right)\\
\end{array}
\end{array}
if a < -4.8e119 or 5.79999999999999971e80 < a Initial program 95.0%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6478.8
Applied rewrites78.8%
if -4.8e119 < a < 5.79999999999999971e80Initial program 70.4%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6456.7
Applied rewrites56.7%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift--.f6439.7
Applied rewrites39.7%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6470.9
Applied rewrites70.9%
Final simplification73.7%
(FPCore (x y z t a)
:precision binary64
(if (<= z -1.35e+82)
t
(if (<= z 1.16e+58)
(fma y (/ t a) x)
(if (<= z 3.9e+157) (/ (* x y) z) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.35e+82) {
tmp = t;
} else if (z <= 1.16e+58) {
tmp = fma(y, (t / a), x);
} else if (z <= 3.9e+157) {
tmp = (x * y) / z;
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.35e+82) tmp = t; elseif (z <= 1.16e+58) tmp = fma(y, Float64(t / a), x); elseif (z <= 3.9e+157) tmp = Float64(Float64(x * y) / z); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.35e+82], t, If[LessEqual[z, 1.16e+58], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 3.9e+157], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], t]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+82}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq 1.16 \cdot 10^{+58}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{elif}\;z \leq 3.9 \cdot 10^{+157}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -1.35e82 or 3.89999999999999971e157 < z Initial program 58.3%
Taylor expanded in z around inf
Applied rewrites41.7%
if -1.35e82 < z < 1.1600000000000001e58Initial program 89.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6467.1
Applied rewrites67.1%
Taylor expanded in x around 0
Applied rewrites58.8%
if 1.1600000000000001e58 < z < 3.89999999999999971e157Initial program 84.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6468.3
Applied rewrites68.3%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f6440.8
Applied rewrites40.8%
(FPCore (x y z t a) :precision binary64 (if (<= a -9e-90) (fma (- t x) (/ (- y z) a) x) (if (<= a 5.8e+80) (fma (- y) (/ (- t x) z) t) (fma y (/ (- t x) a) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -9e-90) {
tmp = fma((t - x), ((y - z) / a), x);
} else if (a <= 5.8e+80) {
tmp = fma(-y, ((t - x) / z), t);
} else {
tmp = fma(y, ((t - x) / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -9e-90) tmp = fma(Float64(t - x), Float64(Float64(y - z) / a), x); elseif (a <= 5.8e+80) tmp = fma(Float64(-y), Float64(Float64(t - x) / z), t); else tmp = fma(y, Float64(Float64(t - x) / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -9e-90], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[a, 5.8e+80], N[((-y) * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{-90}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\mathbf{elif}\;a \leq 5.8 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{t - x}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\end{array}
\end{array}
if a < -9.00000000000000017e-90Initial program 80.5%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6468.1
Applied rewrites68.1%
if -9.00000000000000017e-90 < a < 5.79999999999999971e80Initial program 72.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6464.3
Applied rewrites64.3%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift--.f6447.1
Applied rewrites47.1%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6479.0
Applied rewrites79.0%
if 5.79999999999999971e80 < a Initial program 95.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6484.3
Applied rewrites84.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -5.7e-12) (not (<= a 400000.0))) (fma y (/ (- t x) a) x) (* (- t) (- (/ y z) 1.0))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -5.7e-12) || !(a <= 400000.0)) {
tmp = fma(y, ((t - x) / a), x);
} else {
tmp = -t * ((y / z) - 1.0);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -5.7e-12) || !(a <= 400000.0)) tmp = fma(y, Float64(Float64(t - x) / a), x); else tmp = Float64(Float64(-t) * Float64(Float64(y / z) - 1.0)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -5.7e-12], N[Not[LessEqual[a, 400000.0]], $MachinePrecision]], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[((-t) * N[(N[(y / z), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.7 \cdot 10^{-12} \lor \neg \left(a \leq 400000\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-t\right) \cdot \left(\frac{y}{z} - 1\right)\\
\end{array}
\end{array}
if a < -5.7000000000000003e-12 or 4e5 < a Initial program 86.2%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6465.2
Applied rewrites65.2%
if -5.7000000000000003e-12 < a < 4e5Initial program 71.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6463.0
Applied rewrites63.0%
Taylor expanded in t around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6455.7
Applied rewrites55.7%
Final simplification60.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -5.2e-93) (not (<= a 5.5e-89))) (fma y (/ (- t x) a) x) (* y (/ (- x t) z))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -5.2e-93) || !(a <= 5.5e-89)) {
tmp = fma(y, ((t - x) / a), x);
} else {
tmp = y * ((x - t) / z);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -5.2e-93) || !(a <= 5.5e-89)) tmp = fma(y, Float64(Float64(t - x) / a), x); else tmp = Float64(y * Float64(Float64(x - t) / z)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -5.2e-93], N[Not[LessEqual[a, 5.5e-89]], $MachinePrecision]], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(y * N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.2 \cdot 10^{-93} \lor \neg \left(a \leq 5.5 \cdot 10^{-89}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x - t}{z}\\
\end{array}
\end{array}
if a < -5.1999999999999997e-93 or 5.50000000000000012e-89 < a Initial program 84.0%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6460.0
Applied rewrites60.0%
if -5.1999999999999997e-93 < a < 5.50000000000000012e-89Initial program 70.2%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6470.4
Applied rewrites70.4%
Taylor expanded in z around -inf
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lift--.f64N/A
lower--.f6488.8
Applied rewrites88.8%
Taylor expanded in y around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6452.9
Applied rewrites52.9%
Final simplification57.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -4.6e-91) (not (<= a 2300000.0))) (fma y (/ t a) x) (* y (/ (- x t) z))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -4.6e-91) || !(a <= 2300000.0)) {
tmp = fma(y, (t / a), x);
} else {
tmp = y * ((x - t) / z);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -4.6e-91) || !(a <= 2300000.0)) tmp = fma(y, Float64(t / a), x); else tmp = Float64(y * Float64(Float64(x - t) / z)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -4.6e-91], N[Not[LessEqual[a, 2300000.0]], $MachinePrecision]], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], N[(y * N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.6 \cdot 10^{-91} \lor \neg \left(a \leq 2300000\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x - t}{z}\\
\end{array}
\end{array}
if a < -4.59999999999999991e-91 or 2.3e6 < a Initial program 85.6%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6464.0
Applied rewrites64.0%
Taylor expanded in x around 0
Applied rewrites57.9%
if -4.59999999999999991e-91 < a < 2.3e6Initial program 70.9%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6471.1
Applied rewrites71.1%
Taylor expanded in z around -inf
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lift--.f64N/A
lower--.f6485.8
Applied rewrites85.8%
Taylor expanded in y around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6449.0
Applied rewrites49.0%
Final simplification54.0%
(FPCore (x y z t a) :precision binary64 (if (<= a -1150000.0) x (if (<= a 4.2e+70) t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1150000.0) {
tmp = x;
} else if (a <= 4.2e+70) {
tmp = t;
} 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)
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) :: tmp
if (a <= (-1150000.0d0)) then
tmp = x
else if (a <= 4.2d+70) then
tmp = t
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1150000.0) {
tmp = x;
} else if (a <= 4.2e+70) {
tmp = t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -1150000.0: tmp = x elif a <= 4.2e+70: tmp = t else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -1150000.0) tmp = x; elseif (a <= 4.2e+70) tmp = t; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -1150000.0) tmp = x; elseif (a <= 4.2e+70) tmp = t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -1150000.0], x, If[LessEqual[a, 4.2e+70], t, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1150000:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 4.2 \cdot 10^{+70}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.15e6 or 4.20000000000000015e70 < a Initial program 88.5%
Taylor expanded in a around inf
Applied rewrites49.2%
if -1.15e6 < a < 4.20000000000000015e70Initial program 72.3%
Taylor expanded in z around inf
Applied rewrites35.7%
(FPCore (x y z t a) :precision binary64 t)
double code(double x, double y, double z, double t, double a) {
return 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)
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
code = t
end function
public static double code(double x, double y, double z, double t, double a) {
return t;
}
def code(x, y, z, t, a): return t
function code(x, y, z, t, a) return t end
function tmp = code(x, y, z, t, a) tmp = t; end
code[x_, y_, z_, t_, a_] := t
\begin{array}{l}
\\
t
\end{array}
Initial program 79.2%
Taylor expanded in z around inf
Applied rewrites23.6%
herbie shell --seed 2025051
(FPCore (x y z t a)
:name "Numeric.Signal:interpolate from hsignal-0.2.7.1"
:precision binary64
(+ x (* (- y z) (/ (- t x) (- a z)))))