
(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 20 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 (+ x (* (- y z) (/ (- t x) (- a z))))) (t_2 (/ (- t x) z)))
(if (or (<= t_1 -1e-273) (not (<= t_1 0.0)))
(fma (- t x) (/ (- y z) (- a z)) x)
(+
(+ (fma (- y) t_2 (* (* (- (- t x)) (/ (- y a) z)) (/ a z))) t)
(* a t_2)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + ((y - z) * ((t - x) / (a - z)));
double t_2 = (t - x) / z;
double tmp;
if ((t_1 <= -1e-273) || !(t_1 <= 0.0)) {
tmp = fma((t - x), ((y - z) / (a - z)), x);
} else {
tmp = (fma(-y, t_2, ((-(t - x) * ((y - a) / z)) * (a / z))) + t) + (a * t_2);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(y - z) * Float64(Float64(t - x) / Float64(a - z)))) t_2 = Float64(Float64(t - x) / z) tmp = 0.0 if ((t_1 <= -1e-273) || !(t_1 <= 0.0)) tmp = fma(Float64(t - x), Float64(Float64(y - z) / Float64(a - z)), x); else tmp = Float64(Float64(fma(Float64(-y), t_2, Float64(Float64(Float64(-Float64(t - x)) * Float64(Float64(y - a) / z)) * Float64(a / z))) + t) + Float64(a * t_2)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e-273], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[((-y) * t$95$2 + N[(N[((-N[(t - x), $MachinePrecision]) * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] * N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision] + N[(a * t$95$2), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(y - z\right) \cdot \frac{t - x}{a - z}\\
t_2 := \frac{t - x}{z}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-273} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a - z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-y, t\_2, \left(\left(-\left(t - x\right)\right) \cdot \frac{y - a}{z}\right) \cdot \frac{a}{z}\right) + t\right) + a \cdot t\_2\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -1e-273 or 0.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 90.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6494.3
Applied rewrites94.3%
if -1e-273 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 0.0Initial program 3.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f643.4
Applied rewrites3.4%
Taylor expanded in x around 0
Applied rewrites3.0%
Taylor expanded in z around inf
Applied rewrites99.9%
Final simplification95.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (* (- y z) (/ (- t x) (- a z))))))
(if (or (<= t_1 -1e-273) (not (<= t_1 0.0)))
(fma (- t x) (/ (- y z) (- a z)) x)
(fma (- (- t x)) (/ (- y a) z) t))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + ((y - z) * ((t - x) / (a - z)));
double tmp;
if ((t_1 <= -1e-273) || !(t_1 <= 0.0)) {
tmp = fma((t - x), ((y - z) / (a - z)), x);
} else {
tmp = fma(-(t - x), ((y - a) / z), t);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(y - z) * Float64(Float64(t - x) / Float64(a - z)))) tmp = 0.0 if ((t_1 <= -1e-273) || !(t_1 <= 0.0)) tmp = fma(Float64(t - x), Float64(Float64(y - z) / Float64(a - z)), x); else tmp = fma(Float64(-Float64(t - x)), Float64(Float64(y - a) / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e-273], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[((-N[(t - x), $MachinePrecision]) * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(y - z\right) \cdot \frac{t - x}{a - z}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-273} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a - z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-\left(t - x\right), \frac{y - a}{z}, t\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -1e-273 or 0.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 90.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6494.3
Applied rewrites94.3%
if -1e-273 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 0.0Initial program 3.7%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-out--N/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6494.5
Applied rewrites94.5%
Final simplification94.3%
(FPCore (x y z t a) :precision binary64 (if (<= (+ x (* (- y z) (/ (- t x) (- a z)))) (- INFINITY)) (* (/ x a) z) (+ x (- t x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x + ((y - z) * ((t - x) / (a - z)))) <= -((double) INFINITY)) {
tmp = (x / a) * z;
} else {
tmp = x + (t - x);
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x + ((y - z) * ((t - x) / (a - z)))) <= -Double.POSITIVE_INFINITY) {
tmp = (x / a) * z;
} else {
tmp = x + (t - x);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x + ((y - z) * ((t - x) / (a - z)))) <= -math.inf: tmp = (x / a) * z else: tmp = x + (t - x) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x + Float64(Float64(y - z) * Float64(Float64(t - x) / Float64(a - z)))) <= Float64(-Inf)) tmp = Float64(Float64(x / a) * z); else tmp = Float64(x + Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((x + ((y - z) * ((t - x) / (a - z)))) <= -Inf) tmp = (x / a) * z; else tmp = x + (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x + N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(x / a), $MachinePrecision] * z), $MachinePrecision], N[(x + N[(t - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \left(y - z\right) \cdot \frac{t - x}{a - z} \leq -\infty:\\
\;\;\;\;\frac{x}{a} \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + \left(t - x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -inf.0Initial program 96.8%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6474.2
Applied rewrites74.2%
Taylor expanded in z around inf
Applied rewrites23.5%
Taylor expanded in x around inf
Applied rewrites8.1%
Applied rewrites17.1%
if -inf.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 76.9%
Taylor expanded in z around inf
lower--.f6414.5
Applied rewrites14.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (- t x) (/ y (- a z)))))
(if (<= z -9.4e+142)
(fma (/ (- t x) z) a t)
(if (<= z -0.000145)
t_1
(if (<= z 6e-37)
(fma (- t x) (/ y a) x)
(if (<= z 2.1e+80) t_1 (* (- t) (/ (- y z) z))))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) * (y / (a - z));
double tmp;
if (z <= -9.4e+142) {
tmp = fma(((t - x) / z), a, t);
} else if (z <= -0.000145) {
tmp = t_1;
} else if (z <= 6e-37) {
tmp = fma((t - x), (y / a), x);
} else if (z <= 2.1e+80) {
tmp = t_1;
} else {
tmp = -t * ((y - z) / z);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) * Float64(y / Float64(a - z))) tmp = 0.0 if (z <= -9.4e+142) tmp = fma(Float64(Float64(t - x) / z), a, t); elseif (z <= -0.000145) tmp = t_1; elseif (z <= 6e-37) tmp = fma(Float64(t - x), Float64(y / a), x); elseif (z <= 2.1e+80) tmp = t_1; else tmp = Float64(Float64(-t) * Float64(Float64(y - z) / z)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9.4e+142], N[(N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] * a + t), $MachinePrecision], If[LessEqual[z, -0.000145], t$95$1, If[LessEqual[z, 6e-37], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 2.1e+80], t$95$1, N[((-t) * N[(N[(y - z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot \frac{y}{a - z}\\
\mathbf{if}\;z \leq -9.4 \cdot 10^{+142}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{z}, a, t\right)\\
\mathbf{elif}\;z \leq -0.000145:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-37}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{+80}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(-t\right) \cdot \frac{y - z}{z}\\
\end{array}
\end{array}
if z < -9.4e142Initial program 35.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6447.1
Applied rewrites47.1%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites70.5%
Taylor expanded in y around 0
Applied rewrites69.3%
if -9.4e142 < z < -1.45e-4 or 6e-37 < z < 2.10000000000000001e80Initial program 85.7%
Taylor expanded in y around inf
div-subN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6463.1
Applied rewrites63.1%
if -1.45e-4 < z < 6e-37Initial program 94.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6497.9
Applied rewrites97.9%
Taylor expanded in z around 0
lower-/.f6480.7
Applied rewrites80.7%
if 2.10000000000000001e80 < z Initial program 53.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6456.7
Applied rewrites56.7%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6449.0
Applied rewrites49.0%
Taylor expanded in a around 0
Applied rewrites69.9%
Final simplification73.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- t x) z)))
(if (<= z -3e+142)
(fma t_1 a t)
(if (<= z -580000000000.0)
(* (- y) t_1)
(if (<= z 5.5e+48) (fma (- t x) (/ y a) x) (* (- t) (/ (- y z) z)))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) / z;
double tmp;
if (z <= -3e+142) {
tmp = fma(t_1, a, t);
} else if (z <= -580000000000.0) {
tmp = -y * t_1;
} else if (z <= 5.5e+48) {
tmp = fma((t - x), (y / a), x);
} else {
tmp = -t * ((y - z) / z);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) / z) tmp = 0.0 if (z <= -3e+142) tmp = fma(t_1, a, t); elseif (z <= -580000000000.0) tmp = Float64(Float64(-y) * t_1); elseif (z <= 5.5e+48) tmp = fma(Float64(t - x), Float64(y / a), x); else tmp = Float64(Float64(-t) * Float64(Float64(y - z) / z)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -3e+142], N[(t$95$1 * a + t), $MachinePrecision], If[LessEqual[z, -580000000000.0], N[((-y) * t$95$1), $MachinePrecision], If[LessEqual[z, 5.5e+48], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[((-t) * N[(N[(y - z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - x}{z}\\
\mathbf{if}\;z \leq -3 \cdot 10^{+142}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, a, t\right)\\
\mathbf{elif}\;z \leq -580000000000:\\
\;\;\;\;\left(-y\right) \cdot t\_1\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-t\right) \cdot \frac{y - z}{z}\\
\end{array}
\end{array}
if z < -2.99999999999999975e142Initial program 35.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6447.1
Applied rewrites47.1%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites70.5%
Taylor expanded in y around 0
Applied rewrites69.3%
if -2.99999999999999975e142 < z < -5.8e11Initial program 84.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6484.3
Applied rewrites84.3%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites60.3%
Taylor expanded in y around inf
Applied rewrites50.2%
if -5.8e11 < z < 5.5000000000000002e48Initial program 93.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6496.9
Applied rewrites96.9%
Taylor expanded in z around 0
lower-/.f6475.5
Applied rewrites75.5%
if 5.5000000000000002e48 < z Initial program 56.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6459.3
Applied rewrites59.3%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6450.7
Applied rewrites50.7%
Taylor expanded in a around 0
Applied rewrites66.0%
Final simplification70.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- t x) z)) (t_2 (fma t_1 a t)))
(if (<= z -3e+142)
t_2
(if (<= z -580000000000.0)
(* (- y) t_1)
(if (<= z 3.2e+80) (fma (- t x) (/ y a) x) t_2)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) / z;
double t_2 = fma(t_1, a, t);
double tmp;
if (z <= -3e+142) {
tmp = t_2;
} else if (z <= -580000000000.0) {
tmp = -y * t_1;
} else if (z <= 3.2e+80) {
tmp = fma((t - x), (y / a), x);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) / z) t_2 = fma(t_1, a, t) tmp = 0.0 if (z <= -3e+142) tmp = t_2; elseif (z <= -580000000000.0) tmp = Float64(Float64(-y) * t_1); elseif (z <= 3.2e+80) tmp = fma(Float64(t - x), Float64(y / a), x); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * a + t), $MachinePrecision]}, If[LessEqual[z, -3e+142], t$95$2, If[LessEqual[z, -580000000000.0], N[((-y) * t$95$1), $MachinePrecision], If[LessEqual[z, 3.2e+80], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - x}{z}\\
t_2 := \mathsf{fma}\left(t\_1, a, t\right)\\
\mathbf{if}\;z \leq -3 \cdot 10^{+142}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \leq -580000000000:\\
\;\;\;\;\left(-y\right) \cdot t\_1\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if z < -2.99999999999999975e142 or 3.1999999999999999e80 < z Initial program 45.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6452.1
Applied rewrites52.1%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites65.9%
Taylor expanded in y around 0
Applied rewrites69.3%
if -2.99999999999999975e142 < z < -5.8e11Initial program 84.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6484.3
Applied rewrites84.3%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites60.3%
Taylor expanded in y around inf
Applied rewrites50.2%
if -5.8e11 < z < 3.1999999999999999e80Initial program 92.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6495.8
Applied rewrites95.8%
Taylor expanded in z around 0
lower-/.f6473.4
Applied rewrites73.4%
Final simplification69.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- t x) z) a t)))
(if (<= z -1.45e+142)
t_1
(if (<= z -600000000000.0)
(* (/ (- y a) z) x)
(if (<= z 3.2e+80) (fma (- t x) (/ y a) x) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((t - x) / z), a, t);
double tmp;
if (z <= -1.45e+142) {
tmp = t_1;
} else if (z <= -600000000000.0) {
tmp = ((y - a) / z) * x;
} else if (z <= 3.2e+80) {
tmp = fma((t - x), (y / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(t - x) / z), a, t) tmp = 0.0 if (z <= -1.45e+142) tmp = t_1; elseif (z <= -600000000000.0) tmp = Float64(Float64(Float64(y - a) / z) * x); elseif (z <= 3.2e+80) 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[(N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] * a + t), $MachinePrecision]}, If[LessEqual[z, -1.45e+142], t$95$1, If[LessEqual[z, -600000000000.0], N[(N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 3.2e+80], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t - x}{z}, a, t\right)\\
\mathbf{if}\;z \leq -1.45 \cdot 10^{+142}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -600000000000:\\
\;\;\;\;\frac{y - a}{z} \cdot x\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.45000000000000007e142 or 3.1999999999999999e80 < z Initial program 45.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6452.1
Applied rewrites52.1%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites65.9%
Taylor expanded in y around 0
Applied rewrites69.3%
if -1.45000000000000007e142 < z < -6e11Initial program 84.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6484.3
Applied rewrites84.3%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites60.3%
Taylor expanded in x around inf
Applied rewrites47.7%
if -6e11 < z < 3.1999999999999999e80Initial program 92.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6495.8
Applied rewrites95.8%
Taylor expanded in z around 0
lower-/.f6473.4
Applied rewrites73.4%
Final simplification69.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- t x) z) a t)))
(if (<= z -1.45e+142)
t_1
(if (<= z -600000000000.0)
(* (/ (- y a) z) x)
(if (<= z 3e+80) (fma (/ (- t x) a) y x) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((t - x) / z), a, t);
double tmp;
if (z <= -1.45e+142) {
tmp = t_1;
} else if (z <= -600000000000.0) {
tmp = ((y - a) / z) * x;
} else if (z <= 3e+80) {
tmp = fma(((t - x) / a), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(t - x) / z), a, t) tmp = 0.0 if (z <= -1.45e+142) tmp = t_1; elseif (z <= -600000000000.0) tmp = Float64(Float64(Float64(y - a) / z) * x); elseif (z <= 3e+80) tmp = fma(Float64(Float64(t - x) / a), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] * a + t), $MachinePrecision]}, If[LessEqual[z, -1.45e+142], t$95$1, If[LessEqual[z, -600000000000.0], N[(N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 3e+80], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t - x}{z}, a, t\right)\\
\mathbf{if}\;z \leq -1.45 \cdot 10^{+142}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -600000000000:\\
\;\;\;\;\frac{y - a}{z} \cdot x\\
\mathbf{elif}\;z \leq 3 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.45000000000000007e142 or 2.99999999999999987e80 < z Initial program 45.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6452.1
Applied rewrites52.1%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites65.9%
Taylor expanded in y around 0
Applied rewrites69.3%
if -1.45000000000000007e142 < z < -6e11Initial program 84.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6484.3
Applied rewrites84.3%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites60.3%
Taylor expanded in x around inf
Applied rewrites47.7%
if -6e11 < z < 2.99999999999999987e80Initial program 92.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6472.1
Applied rewrites72.1%
Final simplification68.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -320000000000.0) (not (<= z 1.65e-18))) (fma (- (- t x)) (/ (- y a) z) t) (+ x (* (/ (- y z) a) (- t x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -320000000000.0) || !(z <= 1.65e-18)) {
tmp = fma(-(t - x), ((y - a) / z), t);
} else {
tmp = x + (((y - z) / a) * (t - x));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -320000000000.0) || !(z <= 1.65e-18)) tmp = fma(Float64(-Float64(t - x)), Float64(Float64(y - a) / z), t); else tmp = Float64(x + Float64(Float64(Float64(y - z) / a) * Float64(t - x))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -320000000000.0], N[Not[LessEqual[z, 1.65e-18]], $MachinePrecision]], N[((-N[(t - x), $MachinePrecision]) * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], N[(x + N[(N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -320000000000 \lor \neg \left(z \leq 1.65 \cdot 10^{-18}\right):\\
\;\;\;\;\mathsf{fma}\left(-\left(t - x\right), \frac{y - a}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y - z}{a} \cdot \left(t - x\right)\\
\end{array}
\end{array}
if z < -3.2e11 or 1.6500000000000001e-18 < z Initial program 61.6%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-out--N/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6478.0
Applied rewrites78.0%
if -3.2e11 < z < 1.6500000000000001e-18Initial program 94.6%
Taylor expanded in a around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6484.0
Applied rewrites84.0%
Final simplification81.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -300000000000.0) (not (<= z 1.65e-18))) (fma (- (- t x)) (/ (- y a) z) t) (fma (- y z) (/ (- t x) a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -300000000000.0) || !(z <= 1.65e-18)) {
tmp = fma(-(t - x), ((y - a) / z), t);
} else {
tmp = fma((y - z), ((t - x) / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -300000000000.0) || !(z <= 1.65e-18)) tmp = fma(Float64(-Float64(t - x)), Float64(Float64(y - a) / z), t); else tmp = fma(Float64(y - z), Float64(Float64(t - x) / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -300000000000.0], N[Not[LessEqual[z, 1.65e-18]], $MachinePrecision]], N[((-N[(t - x), $MachinePrecision]) * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -300000000000 \lor \neg \left(z \leq 1.65 \cdot 10^{-18}\right):\\
\;\;\;\;\mathsf{fma}\left(-\left(t - x\right), \frac{y - a}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a}, x\right)\\
\end{array}
\end{array}
if z < -3e11 or 1.6500000000000001e-18 < z Initial program 61.6%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-out--N/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6478.0
Applied rewrites78.0%
if -3e11 < z < 1.6500000000000001e-18Initial program 94.6%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6481.2
Applied rewrites81.2%
Final simplification79.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (/ (- y a) z) x)))
(if (<= z -840000.0)
t_1
(if (<= z 4.8e-25)
(* (/ (- t x) a) y)
(if (<= z 8e+261) t_1 (+ x (- t x)))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((y - a) / z) * x;
double tmp;
if (z <= -840000.0) {
tmp = t_1;
} else if (z <= 4.8e-25) {
tmp = ((t - x) / a) * y;
} else if (z <= 8e+261) {
tmp = t_1;
} else {
tmp = x + (t - 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) :: t_1
real(8) :: tmp
t_1 = ((y - a) / z) * x
if (z <= (-840000.0d0)) then
tmp = t_1
else if (z <= 4.8d-25) then
tmp = ((t - x) / a) * y
else if (z <= 8d+261) then
tmp = t_1
else
tmp = x + (t - x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = ((y - a) / z) * x;
double tmp;
if (z <= -840000.0) {
tmp = t_1;
} else if (z <= 4.8e-25) {
tmp = ((t - x) / a) * y;
} else if (z <= 8e+261) {
tmp = t_1;
} else {
tmp = x + (t - x);
}
return tmp;
}
def code(x, y, z, t, a): t_1 = ((y - a) / z) * x tmp = 0 if z <= -840000.0: tmp = t_1 elif z <= 4.8e-25: tmp = ((t - x) / a) * y elif z <= 8e+261: tmp = t_1 else: tmp = x + (t - x) return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(y - a) / z) * x) tmp = 0.0 if (z <= -840000.0) tmp = t_1; elseif (z <= 4.8e-25) tmp = Float64(Float64(Float64(t - x) / a) * y); elseif (z <= 8e+261) tmp = t_1; else tmp = Float64(x + Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = ((y - a) / z) * x; tmp = 0.0; if (z <= -840000.0) tmp = t_1; elseif (z <= 4.8e-25) tmp = ((t - x) / a) * y; elseif (z <= 8e+261) tmp = t_1; else tmp = x + (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[z, -840000.0], t$95$1, If[LessEqual[z, 4.8e-25], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, 8e+261], t$95$1, N[(x + N[(t - x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y - a}{z} \cdot x\\
\mathbf{if}\;z \leq -840000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{-25}:\\
\;\;\;\;\frac{t - x}{a} \cdot y\\
\mathbf{elif}\;z \leq 8 \cdot 10^{+261}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x + \left(t - x\right)\\
\end{array}
\end{array}
if z < -8.4e5 or 4.80000000000000018e-25 < z < 7.9999999999999994e261Initial program 62.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6466.0
Applied rewrites66.0%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites66.0%
Taylor expanded in x around inf
Applied rewrites36.3%
if -8.4e5 < z < 4.80000000000000018e-25Initial program 94.5%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6481.5
Applied rewrites81.5%
Taylor expanded in y around inf
Applied rewrites51.2%
if 7.9999999999999994e261 < z Initial program 61.3%
Taylor expanded in z around inf
lower--.f6460.6
Applied rewrites60.6%
Final simplification45.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -0.00028) (not (<= a 2e-55))) (fma (- y z) (/ (- 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 <= -0.00028) || !(a <= 2e-55)) {
tmp = fma((y - z), ((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 <= -0.00028) || !(a <= 2e-55)) tmp = fma(Float64(y - z), 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, -0.00028], N[Not[LessEqual[a, 2e-55]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] * 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 -0.00028 \lor \neg \left(a \leq 2 \cdot 10^{-55}\right):\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{t - x}{z}, t\right)\\
\end{array}
\end{array}
if a < -2.7999999999999998e-4 or 1.99999999999999999e-55 < a Initial program 84.2%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6474.2
Applied rewrites74.2%
if -2.7999999999999998e-4 < a < 1.99999999999999999e-55Initial program 73.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6476.6
Applied rewrites76.6%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites80.9%
Taylor expanded in a around 0
Applied rewrites79.0%
Final simplification76.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -0.00028) (not (<= a 2e-55))) (fma (- t x) (/ y a) x) (fma (- y) (/ (- t x) z) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -0.00028) || !(a <= 2e-55)) {
tmp = fma((t - x), (y / a), x);
} else {
tmp = fma(-y, ((t - x) / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -0.00028) || !(a <= 2e-55)) tmp = fma(Float64(t - x), Float64(y / 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, -0.00028], N[Not[LessEqual[a, 2e-55]], $MachinePrecision]], N[(N[(t - x), $MachinePrecision] * N[(y / 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 -0.00028 \lor \neg \left(a \leq 2 \cdot 10^{-55}\right):\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{t - x}{z}, t\right)\\
\end{array}
\end{array}
if a < -2.7999999999999998e-4 or 1.99999999999999999e-55 < a Initial program 84.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6488.6
Applied rewrites88.6%
Taylor expanded in z around 0
lower-/.f6470.4
Applied rewrites70.4%
if -2.7999999999999998e-4 < a < 1.99999999999999999e-55Initial program 73.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6476.6
Applied rewrites76.6%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites80.9%
Taylor expanded in a around 0
Applied rewrites79.0%
Final simplification74.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -3.05e-99) (not (<= a 3.3e-165))) (fma (- y z) (/ t a) x) (* (/ (- y a) z) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -3.05e-99) || !(a <= 3.3e-165)) {
tmp = fma((y - z), (t / a), x);
} else {
tmp = ((y - a) / z) * x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -3.05e-99) || !(a <= 3.3e-165)) tmp = fma(Float64(y - z), Float64(t / a), x); else tmp = Float64(Float64(Float64(y - a) / z) * x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -3.05e-99], N[Not[LessEqual[a, 3.3e-165]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] * N[(t / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.05 \cdot 10^{-99} \lor \neg \left(a \leq 3.3 \cdot 10^{-165}\right):\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y - a}{z} \cdot x\\
\end{array}
\end{array}
if a < -3.0500000000000002e-99 or 3.2999999999999998e-165 < a Initial program 81.8%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6468.2
Applied rewrites68.2%
Taylor expanded in x around 0
Applied rewrites59.5%
if -3.0500000000000002e-99 < a < 3.2999999999999998e-165Initial program 73.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6476.7
Applied rewrites76.7%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites87.1%
Taylor expanded in x around inf
Applied rewrites46.8%
Final simplification55.6%
(FPCore (x y z t a) :precision binary64 (if (<= z -600000000000.0) (* (/ (- y a) z) x) (if (<= z 2.05e+141) (fma (/ (- t x) a) y x) (+ x (- t x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -600000000000.0) {
tmp = ((y - a) / z) * x;
} else if (z <= 2.05e+141) {
tmp = fma(((t - x) / a), y, x);
} else {
tmp = x + (t - x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -600000000000.0) tmp = Float64(Float64(Float64(y - a) / z) * x); elseif (z <= 2.05e+141) tmp = fma(Float64(Float64(t - x) / a), y, x); else tmp = Float64(x + Float64(t - x)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -600000000000.0], N[(N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 2.05e+141], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], N[(x + N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -600000000000:\\
\;\;\;\;\frac{y - a}{z} \cdot x\\
\mathbf{elif}\;z \leq 2.05 \cdot 10^{+141}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t - x\right)\\
\end{array}
\end{array}
if z < -6e11Initial program 59.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6465.4
Applied rewrites65.4%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites65.5%
Taylor expanded in x around inf
Applied rewrites42.1%
if -6e11 < z < 2.05000000000000011e141Initial program 91.0%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6469.8
Applied rewrites69.8%
if 2.05000000000000011e141 < z Initial program 49.8%
Taylor expanded in z around inf
lower--.f6430.8
Applied rewrites30.8%
Final simplification59.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -1.65e-37) (not (<= t 0.115))) (* t (/ y (- a z))) (* (/ (- y a) z) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1.65e-37) || !(t <= 0.115)) {
tmp = t * (y / (a - z));
} else {
tmp = ((y - a) / z) * 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 ((t <= (-1.65d-37)) .or. (.not. (t <= 0.115d0))) then
tmp = t * (y / (a - z))
else
tmp = ((y - a) / z) * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1.65e-37) || !(t <= 0.115)) {
tmp = t * (y / (a - z));
} else {
tmp = ((y - a) / z) * x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -1.65e-37) or not (t <= 0.115): tmp = t * (y / (a - z)) else: tmp = ((y - a) / z) * x return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -1.65e-37) || !(t <= 0.115)) tmp = Float64(t * Float64(y / Float64(a - z))); else tmp = Float64(Float64(Float64(y - a) / z) * x); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -1.65e-37) || ~((t <= 0.115))) tmp = t * (y / (a - z)); else tmp = ((y - a) / z) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1.65e-37], N[Not[LessEqual[t, 0.115]], $MachinePrecision]], N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.65 \cdot 10^{-37} \lor \neg \left(t \leq 0.115\right):\\
\;\;\;\;t \cdot \frac{y}{a - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - a}{z} \cdot x\\
\end{array}
\end{array}
if t < -1.64999999999999991e-37 or 0.115000000000000005 < t Initial program 92.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6494.5
Applied rewrites94.5%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6460.4
Applied rewrites60.4%
Taylor expanded in y around inf
Applied rewrites51.6%
if -1.64999999999999991e-37 < t < 0.115000000000000005Initial program 65.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6471.1
Applied rewrites71.1%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites53.5%
Taylor expanded in x around inf
Applied rewrites38.3%
Final simplification45.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.2e+133) (not (<= z 3e+80))) (+ x (- t x)) (* (/ (- t x) a) y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.2e+133) || !(z <= 3e+80)) {
tmp = x + (t - x);
} else {
tmp = ((t - x) / a) * y;
}
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 ((z <= (-4.2d+133)) .or. (.not. (z <= 3d+80))) then
tmp = x + (t - x)
else
tmp = ((t - x) / a) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.2e+133) || !(z <= 3e+80)) {
tmp = x + (t - x);
} else {
tmp = ((t - x) / a) * y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -4.2e+133) or not (z <= 3e+80): tmp = x + (t - x) else: tmp = ((t - x) / a) * y return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.2e+133) || !(z <= 3e+80)) tmp = Float64(x + Float64(t - x)); else tmp = Float64(Float64(Float64(t - x) / a) * y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -4.2e+133) || ~((z <= 3e+80))) tmp = x + (t - x); else tmp = ((t - x) / a) * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.2e+133], N[Not[LessEqual[z, 3e+80]], $MachinePrecision]], N[(x + N[(t - x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+133} \lor \neg \left(z \leq 3 \cdot 10^{+80}\right):\\
\;\;\;\;x + \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t - x}{a} \cdot y\\
\end{array}
\end{array}
if z < -4.2e133 or 2.99999999999999987e80 < z Initial program 47.5%
Taylor expanded in z around inf
lower--.f6429.2
Applied rewrites29.2%
if -4.2e133 < z < 2.99999999999999987e80Initial program 91.7%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6470.6
Applied rewrites70.6%
Taylor expanded in y around inf
Applied rewrites42.9%
Final simplification39.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.65e+15) (not (<= z 3e+80))) (+ x (- t x)) (* t (/ y a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.65e+15) || !(z <= 3e+80)) {
tmp = x + (t - x);
} else {
tmp = t * (y / a);
}
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 ((z <= (-1.65d+15)) .or. (.not. (z <= 3d+80))) then
tmp = x + (t - x)
else
tmp = t * (y / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.65e+15) || !(z <= 3e+80)) {
tmp = x + (t - x);
} else {
tmp = t * (y / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.65e+15) or not (z <= 3e+80): tmp = x + (t - x) else: tmp = t * (y / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.65e+15) || !(z <= 3e+80)) tmp = Float64(x + Float64(t - x)); else tmp = Float64(t * Float64(y / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1.65e+15) || ~((z <= 3e+80))) tmp = x + (t - x); else tmp = t * (y / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.65e+15], N[Not[LessEqual[z, 3e+80]], $MachinePrecision]], N[(x + N[(t - x), $MachinePrecision]), $MachinePrecision], N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65 \cdot 10^{+15} \lor \neg \left(z \leq 3 \cdot 10^{+80}\right):\\
\;\;\;\;x + \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{y}{a}\\
\end{array}
\end{array}
if z < -1.65e15 or 2.99999999999999987e80 < z Initial program 56.6%
Taylor expanded in z around inf
lower--.f6425.2
Applied rewrites25.2%
if -1.65e15 < z < 2.99999999999999987e80Initial program 92.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6495.9
Applied rewrites95.9%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6447.9
Applied rewrites47.9%
Taylor expanded in z around 0
Applied rewrites37.2%
Final simplification32.7%
(FPCore (x y z t a) :precision binary64 (+ x (- t x)))
double code(double x, double y, double z, double t, double a) {
return x + (t - x);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
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 + (t - x)
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (t - x);
}
def code(x, y, z, t, a): return x + (t - x)
function code(x, y, z, t, a) return Float64(x + Float64(t - x)) end
function tmp = code(x, y, z, t, a) tmp = x + (t - x); end
code[x_, y_, z_, t_, a_] := N[(x + N[(t - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(t - x\right)
\end{array}
Initial program 79.3%
Taylor expanded in z around inf
lower--.f6413.0
Applied rewrites13.0%
(FPCore (x y z t a) :precision binary64 (+ x (- x)))
double code(double x, double y, double z, double t, double a) {
return x + -x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
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 + -x
end function
public static double code(double x, double y, double z, double t, double a) {
return x + -x;
}
def code(x, y, z, t, a): return x + -x
function code(x, y, z, t, a) return Float64(x + Float64(-x)) end
function tmp = code(x, y, z, t, a) tmp = x + -x; end
code[x_, y_, z_, t_, a_] := N[(x + (-x)), $MachinePrecision]
\begin{array}{l}
\\
x + \left(-x\right)
\end{array}
Initial program 79.3%
Taylor expanded in z around inf
lower--.f6413.0
Applied rewrites13.0%
Taylor expanded in x around inf
Applied rewrites2.8%
herbie shell --seed 2024352
(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)))))