
(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 (or (<= t_2 -1e-293) (not (<= t_2 0.0)))
(fma t_1 (- y z) x)
(- t (/ (* (- 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 <= -1e-293) || !(t_2 <= 0.0)) {
tmp = fma(t_1, (y - z), x);
} else {
tmp = t - (((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 <= -1e-293) || !(t_2 <= 0.0)) tmp = fma(t_1, Float64(y - z), x); else tmp = Float64(t - Float64(Float64(Float64(t - 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, -1e-293], N[Not[LessEqual[t$95$2, 0.0]], $MachinePrecision]], N[(t$95$1 * N[(y - z), $MachinePrecision] + x), $MachinePrecision], N[(t - N[(N[(N[(t - x), $MachinePrecision] * 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 -1 \cdot 10^{-293} \lor \neg \left(t\_2 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(t\_1, y - z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t - \frac{\left(t - x\right) \cdot \left(y - a\right)}{z}\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -1.0000000000000001e-293 or 0.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 91.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--.f6491.9
Applied rewrites91.9%
if -1.0000000000000001e-293 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 0.0Initial program 3.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f643.9
Applied rewrites3.9%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f643.4
Applied rewrites3.4%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6426.8
Applied rewrites26.8%
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.2
Applied rewrites85.2%
Final simplification91.0%
(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 (- INFINITY))
(/ (* (- t x) y) (- a z))
(if (<= t_2 -1e-293)
(+ x (* (- y z) (/ t (- a z))))
(if (<= t_2 0.0) t (fma t_1 y 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 <= -((double) INFINITY)) {
tmp = ((t - x) * y) / (a - z);
} else if (t_2 <= -1e-293) {
tmp = x + ((y - z) * (t / (a - z)));
} else if (t_2 <= 0.0) {
tmp = t;
} else {
tmp = fma(t_1, y, 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 <= Float64(-Inf)) tmp = Float64(Float64(Float64(t - x) * y) / Float64(a - z)); elseif (t_2 <= -1e-293) tmp = Float64(x + Float64(Float64(y - z) * Float64(t / Float64(a - z)))); elseif (t_2 <= 0.0) tmp = t; else tmp = fma(t_1, y, 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, (-Infinity)], N[(N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -1e-293], N[(x + N[(N[(y - z), $MachinePrecision] * N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], t, N[(t$95$1 * y + 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 -\infty:\\
\;\;\;\;\frac{\left(t - x\right) \cdot y}{a - z}\\
\mathbf{elif}\;t\_2 \leq -1 \cdot 10^{-293}:\\
\;\;\;\;x + \left(y - z\right) \cdot \frac{t}{a - z}\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, y, x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -inf.0Initial program 80.7%
Taylor expanded in y around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6491.9
Applied rewrites91.9%
if -inf.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -1.0000000000000001e-293Initial program 93.0%
Taylor expanded in x around 0
Applied rewrites81.9%
if -1.0000000000000001e-293 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 0.0Initial program 3.9%
Taylor expanded in z around inf
Applied rewrites49.6%
if 0.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial 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.8
Applied rewrites92.8%
Taylor expanded in y around inf
Applied rewrites78.1%
(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 -1e-293) (not (<= t_2 0.0))) (fma t_1 (- y z) x) t)))
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 <= -1e-293) || !(t_2 <= 0.0)) {
tmp = fma(t_1, (y - z), x);
} else {
tmp = t;
}
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 <= -1e-293) || !(t_2 <= 0.0)) tmp = fma(t_1, Float64(y - z), x); else tmp = t; 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, -1e-293], N[Not[LessEqual[t$95$2, 0.0]], $MachinePrecision]], N[(t$95$1 * N[(y - z), $MachinePrecision] + x), $MachinePrecision], t]]]
\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 -1 \cdot 10^{-293} \lor \neg \left(t\_2 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(t\_1, y - z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -1.0000000000000001e-293 or 0.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 91.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--.f6491.9
Applied rewrites91.9%
if -1.0000000000000001e-293 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 0.0Initial program 3.9%
Taylor expanded in z around inf
Applied rewrites49.6%
Final simplification86.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (- t) (/ z (- a z)))))
(if (<= z -1.75e+221)
t_1
(if (<= z -6.6e+150)
(* y (/ (- t x) (- z)))
(if (<= z 1.15e+69) (fma (- t x) (/ y a) x) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = -t * (z / (a - z));
double tmp;
if (z <= -1.75e+221) {
tmp = t_1;
} else if (z <= -6.6e+150) {
tmp = y * ((t - x) / -z);
} else if (z <= 1.15e+69) {
tmp = fma((t - x), (y / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(-t) * Float64(z / Float64(a - z))) tmp = 0.0 if (z <= -1.75e+221) tmp = t_1; elseif (z <= -6.6e+150) tmp = Float64(y * Float64(Float64(t - x) / Float64(-z))); elseif (z <= 1.15e+69) tmp = fma(Float64(t - x), Float64(y / a), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[((-t) * N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.75e+221], t$95$1, If[LessEqual[z, -6.6e+150], N[(y * N[(N[(t - x), $MachinePrecision] / (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.15e+69], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-t\right) \cdot \frac{z}{a - z}\\
\mathbf{if}\;z \leq -1.75 \cdot 10^{+221}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -6.6 \cdot 10^{+150}:\\
\;\;\;\;y \cdot \frac{t - x}{-z}\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+69}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.7500000000000001e221 or 1.15000000000000008e69 < z Initial program 63.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6431.3
Applied rewrites31.3%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6461.1
Applied rewrites61.1%
if -1.7500000000000001e221 < z < -6.59999999999999962e150Initial program 80.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6480.4
Applied rewrites80.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6480.3
Applied rewrites80.3%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6477.6
Applied rewrites77.6%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6463.3
Applied rewrites63.3%
if -6.59999999999999962e150 < z < 1.15000000000000008e69Initial program 87.6%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6468.9
Applied rewrites68.9%
Taylor expanded in y around inf
lower-/.f6465.5
Applied rewrites65.5%
Final simplification64.2%
(FPCore (x y z t a) :precision binary64 (if (<= y -3.1e+32) (* y (/ (- t x) a)) (if (<= y 2.35e-294) t (if (<= y 1.05e+95) x (* t (/ y (- a z)))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -3.1e+32) {
tmp = y * ((t - x) / a);
} else if (y <= 2.35e-294) {
tmp = t;
} else if (y <= 1.05e+95) {
tmp = x;
} else {
tmp = t * (y / (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 (y <= (-3.1d+32)) then
tmp = y * ((t - x) / a)
else if (y <= 2.35d-294) then
tmp = t
else if (y <= 1.05d+95) then
tmp = x
else
tmp = t * (y / (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 (y <= -3.1e+32) {
tmp = y * ((t - x) / a);
} else if (y <= 2.35e-294) {
tmp = t;
} else if (y <= 1.05e+95) {
tmp = x;
} else {
tmp = t * (y / (a - z));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if y <= -3.1e+32: tmp = y * ((t - x) / a) elif y <= 2.35e-294: tmp = t elif y <= 1.05e+95: tmp = x else: tmp = t * (y / (a - z)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (y <= -3.1e+32) tmp = Float64(y * Float64(Float64(t - x) / a)); elseif (y <= 2.35e-294) tmp = t; elseif (y <= 1.05e+95) tmp = x; else tmp = Float64(t * Float64(y / Float64(a - z))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (y <= -3.1e+32) tmp = y * ((t - x) / a); elseif (y <= 2.35e-294) tmp = t; elseif (y <= 1.05e+95) tmp = x; else tmp = t * (y / (a - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -3.1e+32], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.35e-294], t, If[LessEqual[y, 1.05e+95], x, N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+32}:\\
\;\;\;\;y \cdot \frac{t - x}{a}\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{-294}:\\
\;\;\;\;t\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+95}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{y}{a - z}\\
\end{array}
\end{array}
if y < -3.09999999999999993e32Initial program 91.1%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6486.3
Applied rewrites86.3%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6486.2
Applied rewrites86.2%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6476.4
Applied rewrites76.4%
Taylor expanded in z around 0
Applied rewrites47.4%
if -3.09999999999999993e32 < y < 2.3500000000000001e-294Initial program 72.4%
Taylor expanded in z around inf
Applied rewrites43.5%
if 2.3500000000000001e-294 < y < 1.05e95Initial program 75.4%
Taylor expanded in a around inf
Applied rewrites45.9%
if 1.05e95 < y Initial program 91.7%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6444.8
Applied rewrites44.8%
Taylor expanded in y around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6455.9
Applied rewrites55.9%
Final simplification47.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* t (/ y (- a z)))))
(if (<= y -8.8e-60)
t_1
(if (<= y 2.35e-294) t (if (<= y 1.05e+95) x t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t * (y / (a - z));
double tmp;
if (y <= -8.8e-60) {
tmp = t_1;
} else if (y <= 2.35e-294) {
tmp = t;
} else if (y <= 1.05e+95) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
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) :: t_1
real(8) :: tmp
t_1 = t * (y / (a - z))
if (y <= (-8.8d-60)) then
tmp = t_1
else if (y <= 2.35d-294) then
tmp = t
else if (y <= 1.05d+95) then
tmp = x
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = t * (y / (a - z));
double tmp;
if (y <= -8.8e-60) {
tmp = t_1;
} else if (y <= 2.35e-294) {
tmp = t;
} else if (y <= 1.05e+95) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = t * (y / (a - z)) tmp = 0 if y <= -8.8e-60: tmp = t_1 elif y <= 2.35e-294: tmp = t elif y <= 1.05e+95: tmp = x else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(t * Float64(y / Float64(a - z))) tmp = 0.0 if (y <= -8.8e-60) tmp = t_1; elseif (y <= 2.35e-294) tmp = t; elseif (y <= 1.05e+95) tmp = x; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = t * (y / (a - z)); tmp = 0.0; if (y <= -8.8e-60) tmp = t_1; elseif (y <= 2.35e-294) tmp = t; elseif (y <= 1.05e+95) tmp = x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8.8e-60], t$95$1, If[LessEqual[y, 2.35e-294], t, If[LessEqual[y, 1.05e+95], x, t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \frac{y}{a - z}\\
\mathbf{if}\;y \leq -8.8 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{-294}:\\
\;\;\;\;t\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+95}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -8.7999999999999995e-60 or 1.05e95 < y Initial program 90.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6438.8
Applied rewrites38.8%
Taylor expanded in y around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6443.9
Applied rewrites43.9%
if -8.7999999999999995e-60 < y < 2.3500000000000001e-294Initial program 67.5%
Taylor expanded in z around inf
Applied rewrites52.0%
if 2.3500000000000001e-294 < y < 1.05e95Initial program 75.4%
Taylor expanded in a around inf
Applied rewrites45.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.75e+221) (not (<= z 1.2e+126))) (* (- t) (/ z (- a z))) (fma (/ (- t x) (- a z)) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.75e+221) || !(z <= 1.2e+126)) {
tmp = -t * (z / (a - z));
} else {
tmp = fma(((t - x) / (a - z)), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.75e+221) || !(z <= 1.2e+126)) tmp = Float64(Float64(-t) * Float64(z / Float64(a - z))); else tmp = fma(Float64(Float64(t - x) / Float64(a - z)), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.75e+221], N[Not[LessEqual[z, 1.2e+126]], $MachinePrecision]], N[((-t) * N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.75 \cdot 10^{+221} \lor \neg \left(z \leq 1.2 \cdot 10^{+126}\right):\\
\;\;\;\;\left(-t\right) \cdot \frac{z}{a - z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a - z}, y, x\right)\\
\end{array}
\end{array}
if z < -1.7500000000000001e221 or 1.20000000000000006e126 < z Initial program 56.3%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6430.9
Applied rewrites30.9%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6467.2
Applied rewrites67.2%
if -1.7500000000000001e221 < z < 1.20000000000000006e126Initial program 86.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--.f6486.8
Applied rewrites86.8%
Taylor expanded in y around inf
Applied rewrites75.3%
Final simplification73.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -2.1e+37) (not (<= a 8e-32))) (fma (- t x) (/ (- y z) a) x) (* y (/ (- t x) (- a z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -2.1e+37) || !(a <= 8e-32)) {
tmp = fma((t - x), ((y - z) / a), x);
} else {
tmp = y * ((t - x) / (a - z));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -2.1e+37) || !(a <= 8e-32)) tmp = fma(Float64(t - x), Float64(Float64(y - z) / a), x); else tmp = Float64(y * Float64(Float64(t - x) / Float64(a - z))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -2.1e+37], N[Not[LessEqual[a, 8e-32]], $MachinePrecision]], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(y * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.1 \cdot 10^{+37} \lor \neg \left(a \leq 8 \cdot 10^{-32}\right):\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{t - x}{a - z}\\
\end{array}
\end{array}
if a < -2.1000000000000001e37 or 8.00000000000000045e-32 < a Initial program 91.7%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6482.6
Applied rewrites82.6%
if -2.1000000000000001e37 < a < 8.00000000000000045e-32Initial program 71.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6471.3
Applied rewrites71.3%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6471.2
Applied rewrites71.2%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6456.1
Applied rewrites56.1%
Final simplification68.5%
(FPCore (x y z t a) :precision binary64 (if (<= a -2.65e+37) (fma t (/ (- y z) a) x) (if (<= a 8e-32) (* y (/ (- t x) (- a z))) (fma (- t x) (/ y a) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -2.65e+37) {
tmp = fma(t, ((y - z) / a), x);
} else if (a <= 8e-32) {
tmp = y * ((t - x) / (a - z));
} else {
tmp = fma((t - x), (y / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -2.65e+37) tmp = fma(t, Float64(Float64(y - z) / a), x); elseif (a <= 8e-32) tmp = Float64(y * Float64(Float64(t - x) / Float64(a - z))); else tmp = fma(Float64(t - x), Float64(y / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -2.65e+37], N[(t * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[a, 8e-32], N[(y * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.65 \cdot 10^{+37}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y - z}{a}, x\right)\\
\mathbf{elif}\;a \leq 8 \cdot 10^{-32}:\\
\;\;\;\;y \cdot \frac{t - x}{a - z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\end{array}
\end{array}
if a < -2.6500000000000001e37Initial program 96.2%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6490.8
Applied rewrites90.8%
Taylor expanded in x around 0
Applied rewrites85.3%
if -2.6500000000000001e37 < a < 8.00000000000000045e-32Initial program 71.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6471.3
Applied rewrites71.3%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6471.2
Applied rewrites71.2%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6456.1
Applied rewrites56.1%
if 8.00000000000000045e-32 < a Initial program 88.1%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6476.1
Applied rewrites76.1%
Taylor expanded in y around inf
lower-/.f6470.2
Applied rewrites70.2%
Final simplification65.8%
(FPCore (x y z t a) :precision binary64 (if (<= a -6e-29) (fma t (/ (- y z) a) x) (if (<= a 7.5e-32) (/ (* (- t x) y) (- a z)) (fma (- t x) (/ y a) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -6e-29) {
tmp = fma(t, ((y - z) / a), x);
} else if (a <= 7.5e-32) {
tmp = ((t - x) * y) / (a - z);
} else {
tmp = fma((t - x), (y / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -6e-29) tmp = fma(t, Float64(Float64(y - z) / a), x); elseif (a <= 7.5e-32) tmp = Float64(Float64(Float64(t - x) * y) / Float64(a - z)); else tmp = fma(Float64(t - x), Float64(y / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -6e-29], N[(t * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[a, 7.5e-32], N[(N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y - z}{a}, x\right)\\
\mathbf{elif}\;a \leq 7.5 \cdot 10^{-32}:\\
\;\;\;\;\frac{\left(t - x\right) \cdot y}{a - z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\end{array}
\end{array}
if a < -6.0000000000000005e-29Initial program 94.4%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6483.9
Applied rewrites83.9%
Taylor expanded in x around 0
Applied rewrites79.5%
if -6.0000000000000005e-29 < a < 7.49999999999999953e-32Initial program 69.6%
Taylor expanded in y around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6455.7
Applied rewrites55.7%
if 7.49999999999999953e-32 < a Initial program 88.1%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6476.1
Applied rewrites76.1%
Taylor expanded in y around inf
lower-/.f6470.2
Applied rewrites70.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3.5e+91) (not (<= z 1.15e+69))) (* (- t) (/ z (- a z))) (fma (- t x) (/ y a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.5e+91) || !(z <= 1.15e+69)) {
tmp = -t * (z / (a - z));
} else {
tmp = fma((t - x), (y / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3.5e+91) || !(z <= 1.15e+69)) tmp = Float64(Float64(-t) * Float64(z / Float64(a - z))); else tmp = fma(Float64(t - x), Float64(y / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3.5e+91], N[Not[LessEqual[z, 1.15e+69]], $MachinePrecision]], N[((-t) * N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{+91} \lor \neg \left(z \leq 1.15 \cdot 10^{+69}\right):\\
\;\;\;\;\left(-t\right) \cdot \frac{z}{a - z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\end{array}
\end{array}
if z < -3.50000000000000001e91 or 1.15000000000000008e69 < z Initial program 66.2%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6432.2
Applied rewrites32.2%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6453.9
Applied rewrites53.9%
if -3.50000000000000001e91 < z < 1.15000000000000008e69Initial program 88.8%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6470.6
Applied rewrites70.6%
Taylor expanded in y around inf
lower-/.f6467.4
Applied rewrites67.4%
Final simplification62.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3.5e+91) (not (<= z 1.15e+69))) t (fma (- t x) (/ y a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.5e+91) || !(z <= 1.15e+69)) {
tmp = t;
} else {
tmp = fma((t - x), (y / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3.5e+91) || !(z <= 1.15e+69)) tmp = t; else tmp = fma(Float64(t - x), Float64(y / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3.5e+91], N[Not[LessEqual[z, 1.15e+69]], $MachinePrecision]], t, N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{+91} \lor \neg \left(z \leq 1.15 \cdot 10^{+69}\right):\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\end{array}
\end{array}
if z < -3.50000000000000001e91 or 1.15000000000000008e69 < z Initial program 66.2%
Taylor expanded in z around inf
Applied rewrites48.8%
if -3.50000000000000001e91 < z < 1.15000000000000008e69Initial program 88.8%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6470.6
Applied rewrites70.6%
Taylor expanded in y around inf
lower-/.f6467.4
Applied rewrites67.4%
Final simplification60.8%
(FPCore (x y z t a) :precision binary64 (if (<= z -3.5e+91) t (if (<= z 1.15e+69) (fma y (/ (- t x) a) x) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.5e+91) {
tmp = t;
} else if (z <= 1.15e+69) {
tmp = fma(y, ((t - x) / a), x);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3.5e+91) tmp = t; elseif (z <= 1.15e+69) tmp = fma(y, Float64(Float64(t - x) / a), x); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.5e+91], t, If[LessEqual[z, 1.15e+69], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{+91}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+69}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -3.50000000000000001e91 or 1.15000000000000008e69 < z Initial program 66.2%
Taylor expanded in z around inf
Applied rewrites48.8%
if -3.50000000000000001e91 < z < 1.15000000000000008e69Initial program 88.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6466.9
Applied rewrites66.9%
(FPCore (x y z t a) :precision binary64 (if (<= a -3e+48) x (if (<= a -2e-97) (* t (/ (- y z) a)) (if (<= a 4.6e+87) t x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -3e+48) {
tmp = x;
} else if (a <= -2e-97) {
tmp = t * ((y - z) / a);
} else if (a <= 4.6e+87) {
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 <= (-3d+48)) then
tmp = x
else if (a <= (-2d-97)) then
tmp = t * ((y - z) / a)
else if (a <= 4.6d+87) 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 <= -3e+48) {
tmp = x;
} else if (a <= -2e-97) {
tmp = t * ((y - z) / a);
} else if (a <= 4.6e+87) {
tmp = t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -3e+48: tmp = x elif a <= -2e-97: tmp = t * ((y - z) / a) elif a <= 4.6e+87: tmp = t else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -3e+48) tmp = x; elseif (a <= -2e-97) tmp = Float64(t * Float64(Float64(y - z) / a)); elseif (a <= 4.6e+87) tmp = t; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -3e+48) tmp = x; elseif (a <= -2e-97) tmp = t * ((y - z) / a); elseif (a <= 4.6e+87) tmp = t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -3e+48], x, If[LessEqual[a, -2e-97], N[(t * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 4.6e+87], t, x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3 \cdot 10^{+48}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq -2 \cdot 10^{-97}:\\
\;\;\;\;t \cdot \frac{y - z}{a}\\
\mathbf{elif}\;a \leq 4.6 \cdot 10^{+87}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -3e48 or 4.6000000000000003e87 < a Initial program 95.9%
Taylor expanded in a around inf
Applied rewrites59.5%
if -3e48 < a < -2.00000000000000007e-97Initial program 77.4%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6454.3
Applied rewrites54.3%
Taylor expanded in t around inf
sub-divN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f6433.5
Applied rewrites33.5%
if -2.00000000000000007e-97 < a < 4.6000000000000003e87Initial program 70.6%
Taylor expanded in z around inf
Applied rewrites35.8%
(FPCore (x y z t a) :precision binary64 (if (<= a -9.2e+45) x (if (<= a -3.6e-97) (/ (* y t) a) (if (<= a 4.6e+87) t x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -9.2e+45) {
tmp = x;
} else if (a <= -3.6e-97) {
tmp = (y * t) / a;
} else if (a <= 4.6e+87) {
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 <= (-9.2d+45)) then
tmp = x
else if (a <= (-3.6d-97)) then
tmp = (y * t) / a
else if (a <= 4.6d+87) 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 <= -9.2e+45) {
tmp = x;
} else if (a <= -3.6e-97) {
tmp = (y * t) / a;
} else if (a <= 4.6e+87) {
tmp = t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -9.2e+45: tmp = x elif a <= -3.6e-97: tmp = (y * t) / a elif a <= 4.6e+87: tmp = t else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -9.2e+45) tmp = x; elseif (a <= -3.6e-97) tmp = Float64(Float64(y * t) / a); elseif (a <= 4.6e+87) tmp = t; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -9.2e+45) tmp = x; elseif (a <= -3.6e-97) tmp = (y * t) / a; elseif (a <= 4.6e+87) tmp = t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -9.2e+45], x, If[LessEqual[a, -3.6e-97], N[(N[(y * t), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[a, 4.6e+87], t, x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9.2 \cdot 10^{+45}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq -3.6 \cdot 10^{-97}:\\
\;\;\;\;\frac{y \cdot t}{a}\\
\mathbf{elif}\;a \leq 4.6 \cdot 10^{+87}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -9.20000000000000049e45 or 4.6000000000000003e87 < a Initial program 95.9%
Taylor expanded in a around inf
Applied rewrites59.5%
if -9.20000000000000049e45 < a < -3.59999999999999997e-97Initial program 77.4%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6445.8
Applied rewrites45.8%
Taylor expanded in z around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6430.5
Applied rewrites30.5%
if -3.59999999999999997e-97 < a < 4.6000000000000003e87Initial program 70.6%
Taylor expanded in z around inf
Applied rewrites35.8%
(FPCore (x y z t a) :precision binary64 (if (<= a -1.22e+48) x (if (<= a 4.6e+87) t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.22e+48) {
tmp = x;
} else if (a <= 4.6e+87) {
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 <= (-1.22d+48)) then
tmp = x
else if (a <= 4.6d+87) 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 <= -1.22e+48) {
tmp = x;
} else if (a <= 4.6e+87) {
tmp = t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -1.22e+48: tmp = x elif a <= 4.6e+87: tmp = t else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -1.22e+48) tmp = x; elseif (a <= 4.6e+87) tmp = t; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -1.22e+48) tmp = x; elseif (a <= 4.6e+87) tmp = t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -1.22e+48], x, If[LessEqual[a, 4.6e+87], t, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.22 \cdot 10^{+48}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 4.6 \cdot 10^{+87}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.22000000000000004e48 or 4.6000000000000003e87 < a Initial program 95.9%
Taylor expanded in a around inf
Applied rewrites59.5%
if -1.22000000000000004e48 < a < 4.6000000000000003e87Initial program 72.0%
Taylor expanded in z around inf
Applied rewrites32.2%
(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 80.8%
Taylor expanded in z around inf
Applied rewrites23.3%
herbie shell --seed 2025064
(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)))))