
(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}
Herbie found 12 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))))))
(if (<= t_1 -5e-218)
t_1
(if (<= t_1 1e-142) (+ (- (/ (* (- t x) (- y a)) z)) t) t_1))))
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 <= -5e-218) {
tmp = t_1;
} else if (t_1 <= 1e-142) {
tmp = -(((t - x) * (y - a)) / z) + t;
} 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 = x + ((y - z) * ((t - x) / (a - z)))
if (t_1 <= (-5d-218)) then
tmp = t_1
else if (t_1 <= 1d-142) then
tmp = -(((t - x) * (y - a)) / z) + t
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 = x + ((y - z) * ((t - x) / (a - z)));
double tmp;
if (t_1 <= -5e-218) {
tmp = t_1;
} else if (t_1 <= 1e-142) {
tmp = -(((t - x) * (y - a)) / z) + t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = x + ((y - z) * ((t - x) / (a - z))) tmp = 0 if t_1 <= -5e-218: tmp = t_1 elif t_1 <= 1e-142: tmp = -(((t - x) * (y - a)) / z) + t else: tmp = t_1 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 <= -5e-218) tmp = t_1; elseif (t_1 <= 1e-142) tmp = Float64(Float64(-Float64(Float64(Float64(t - x) * Float64(y - a)) / z)) + t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = x + ((y - z) * ((t - x) / (a - z))); tmp = 0.0; if (t_1 <= -5e-218) tmp = t_1; elseif (t_1 <= 1e-142) tmp = -(((t - x) * (y - a)) / z) + t; else tmp = t_1; end tmp_2 = 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[LessEqual[t$95$1, -5e-218], t$95$1, If[LessEqual[t$95$1, 1e-142], N[((-N[(N[(N[(t - x), $MachinePrecision] * N[(y - a), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]) + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(y - z\right) \cdot \frac{t - x}{a - z}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-218}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq 10^{-142}:\\
\;\;\;\;\left(-\frac{\left(t - x\right) \cdot \left(y - a\right)}{z}\right) + t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -5.00000000000000041e-218 or 1e-142 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 92.0%
if -5.00000000000000041e-218 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 1e-142Initial program 23.3%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites67.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- t x) (- a z)))
(t_2 (fma t_1 (- y z) x))
(t_3 (+ x (* (- y z) t_1))))
(if (<= t_3 -5e-218)
t_2
(if (<= t_3 1e-142) (+ (- (/ (* (- t x) (- y a)) z)) t) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) / (a - z);
double t_2 = fma(t_1, (y - z), x);
double t_3 = x + ((y - z) * t_1);
double tmp;
if (t_3 <= -5e-218) {
tmp = t_2;
} else if (t_3 <= 1e-142) {
tmp = -(((t - x) * (y - a)) / z) + t;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) / Float64(a - z)) t_2 = fma(t_1, Float64(y - z), x) t_3 = Float64(x + Float64(Float64(y - z) * t_1)) tmp = 0.0 if (t_3 <= -5e-218) tmp = t_2; elseif (t_3 <= 1e-142) tmp = Float64(Float64(-Float64(Float64(Float64(t - x) * Float64(y - a)) / z)) + t); else tmp = t_2; 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[(t$95$1 * N[(y - z), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$3 = N[(x + N[(N[(y - z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -5e-218], t$95$2, If[LessEqual[t$95$3, 1e-142], N[((-N[(N[(N[(t - x), $MachinePrecision] * N[(y - a), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]) + t), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - x}{a - z}\\
t_2 := \mathsf{fma}\left(t\_1, y - z, x\right)\\
t_3 := x + \left(y - z\right) \cdot t\_1\\
\mathbf{if}\;t\_3 \leq -5 \cdot 10^{-218}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 10^{-142}:\\
\;\;\;\;\left(-\frac{\left(t - x\right) \cdot \left(y - a\right)}{z}\right) + t\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -5.00000000000000041e-218 or 1e-142 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 92.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift--.f6492.0
Applied rewrites92.0%
if -5.00000000000000041e-218 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 1e-142Initial program 23.3%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites67.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (- t x) (/ (- y z) a) x)))
(if (<= a -31000000000.0)
t_1
(if (<= a 5e+73) (+ (- (/ (* (- t x) (- y a)) z)) t) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((t - x), ((y - z) / a), x);
double tmp;
if (a <= -31000000000.0) {
tmp = t_1;
} else if (a <= 5e+73) {
tmp = -(((t - x) * (y - a)) / z) + t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(t - x), Float64(Float64(y - z) / a), x) tmp = 0.0 if (a <= -31000000000.0) tmp = t_1; elseif (a <= 5e+73) tmp = Float64(Float64(-Float64(Float64(Float64(t - x) * Float64(y - a)) / z)) + t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -31000000000.0], t$95$1, If[LessEqual[a, 5e+73], N[((-N[(N[(N[(t - x), $MachinePrecision] * N[(y - a), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]) + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\mathbf{if}\;a \leq -31000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 5 \cdot 10^{+73}:\\
\;\;\;\;\left(-\frac{\left(t - x\right) \cdot \left(y - a\right)}{z}\right) + t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -3.1e10 or 4.99999999999999976e73 < 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--.f6478.3
Applied rewrites78.3%
if -3.1e10 < a < 4.99999999999999976e73Initial program 73.6%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites68.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ t (- a z)) (- y z) x)) (t_2 (* t (/ (- y z) (- a z)))))
(if (<= z -2.6e+24)
t_2
(if (<= z -1.65e-158)
t_1
(if (<= z 3.6e-50)
(fma (- t x) (/ (- y z) a) x)
(if (<= z 2.5e+142) t_1 t_2))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((t / (a - z)), (y - z), x);
double t_2 = t * ((y - z) / (a - z));
double tmp;
if (z <= -2.6e+24) {
tmp = t_2;
} else if (z <= -1.65e-158) {
tmp = t_1;
} else if (z <= 3.6e-50) {
tmp = fma((t - x), ((y - z) / a), x);
} else if (z <= 2.5e+142) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(t / Float64(a - z)), Float64(y - z), x) t_2 = Float64(t * Float64(Float64(y - z) / Float64(a - z))) tmp = 0.0 if (z <= -2.6e+24) tmp = t_2; elseif (z <= -1.65e-158) tmp = t_1; elseif (z <= 3.6e-50) tmp = fma(Float64(t - x), Float64(Float64(y - z) / a), x); elseif (z <= 2.5e+142) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.6e+24], t$95$2, If[LessEqual[z, -1.65e-158], t$95$1, If[LessEqual[z, 3.6e-50], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 2.5e+142], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t}{a - z}, y - z, x\right)\\
t_2 := t \cdot \frac{y - z}{a - z}\\
\mathbf{if}\;z \leq -2.6 \cdot 10^{+24}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \leq -1.65 \cdot 10^{-158}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{-50}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{+142}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if z < -2.5999999999999998e24 or 2.5000000000000001e142 < z Initial program 63.2%
Taylor expanded in t around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/r*N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lift--.f6459.4
Applied rewrites59.4%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6463.5
Applied rewrites63.5%
if -2.5999999999999998e24 < z < -1.6500000000000001e-158 or 3.59999999999999979e-50 < z < 2.5000000000000001e142Initial program 87.3%
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--.f6487.4
Applied rewrites87.4%
Taylor expanded in x around 0
Applied rewrites69.0%
if -1.6500000000000001e-158 < z < 3.59999999999999979e-50Initial program 91.5%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6484.3
Applied rewrites84.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* t (/ (- y z) (- a z)))))
(if (<= z -8200.0)
t_1
(if (<= z 1.5e+93) (+ x (* y (/ (- t x) (- a z)))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t * ((y - z) / (a - z));
double tmp;
if (z <= -8200.0) {
tmp = t_1;
} else if (z <= 1.5e+93) {
tmp = x + (y * ((t - x) / (a - z)));
} 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 - z) / (a - z))
if (z <= (-8200.0d0)) then
tmp = t_1
else if (z <= 1.5d+93) then
tmp = x + (y * ((t - x) / (a - z)))
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 - z) / (a - z));
double tmp;
if (z <= -8200.0) {
tmp = t_1;
} else if (z <= 1.5e+93) {
tmp = x + (y * ((t - x) / (a - z)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = t * ((y - z) / (a - z)) tmp = 0 if z <= -8200.0: tmp = t_1 elif z <= 1.5e+93: tmp = x + (y * ((t - x) / (a - z))) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(t * Float64(Float64(y - z) / Float64(a - z))) tmp = 0.0 if (z <= -8200.0) tmp = t_1; elseif (z <= 1.5e+93) tmp = Float64(x + Float64(y * Float64(Float64(t - x) / Float64(a - z)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = t * ((y - z) / (a - z)); tmp = 0.0; if (z <= -8200.0) tmp = t_1; elseif (z <= 1.5e+93) tmp = x + (y * ((t - x) / (a - z))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8200.0], t$95$1, If[LessEqual[z, 1.5e+93], N[(x + N[(y * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \frac{y - z}{a - z}\\
\mathbf{if}\;z \leq -8200:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{+93}:\\
\;\;\;\;x + y \cdot \frac{t - x}{a - z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -8200 or 1.49999999999999989e93 < z Initial program 65.3%
Taylor expanded in t around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/r*N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lift--.f6461.1
Applied rewrites61.1%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6462.5
Applied rewrites62.5%
if -8200 < z < 1.49999999999999989e93Initial program 90.7%
Taylor expanded in y around inf
Applied rewrites80.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* t (/ (- y z) (- a z)))))
(if (<= z -185000000000.0)
t_1
(if (<= z 1.95e+89) (fma (- t x) (/ (- y z) a) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t * ((y - z) / (a - z));
double tmp;
if (z <= -185000000000.0) {
tmp = t_1;
} else if (z <= 1.95e+89) {
tmp = fma((t - x), ((y - z) / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(t * Float64(Float64(y - z) / Float64(a - z))) tmp = 0.0 if (z <= -185000000000.0) tmp = t_1; elseif (z <= 1.95e+89) tmp = fma(Float64(t - x), Float64(Float64(y - z) / a), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -185000000000.0], t$95$1, If[LessEqual[z, 1.95e+89], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \frac{y - z}{a - z}\\
\mathbf{if}\;z \leq -185000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{+89}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.85e11 or 1.95000000000000005e89 < z Initial program 65.1%
Taylor expanded in t around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/r*N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lift--.f6461.0
Applied rewrites61.0%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6462.8
Applied rewrites62.8%
if -1.85e11 < z < 1.95000000000000005e89Initial program 90.6%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6474.5
Applied rewrites74.5%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* t (/ (- y z) (- a z))))) (if (<= z -2e-32) t_1 (if (<= z 0.0035) (fma (- t x) (/ y a) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t * ((y - z) / (a - z));
double tmp;
if (z <= -2e-32) {
tmp = t_1;
} else if (z <= 0.0035) {
tmp = fma((t - x), (y / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(t * Float64(Float64(y - z) / Float64(a - z))) tmp = 0.0 if (z <= -2e-32) tmp = t_1; elseif (z <= 0.0035) 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[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2e-32], t$95$1, If[LessEqual[z, 0.0035], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \frac{y - z}{a - z}\\
\mathbf{if}\;z \leq -2 \cdot 10^{-32}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 0.0035:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.00000000000000011e-32 or 0.00350000000000000007 < z Initial program 69.6%
Taylor expanded in t around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-/r*N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lift--.f6464.6
Applied rewrites64.6%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6460.1
Applied rewrites60.1%
if -2.00000000000000011e-32 < z < 0.00350000000000000007Initial program 91.6%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6479.8
Applied rewrites79.8%
Taylor expanded in y around inf
Applied rewrites76.2%
(FPCore (x y z t a) :precision binary64 (if (<= z -1e+39) t (if (<= z 2.6e+99) (fma (- t x) (/ y a) x) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1e+39) {
tmp = t;
} else if (z <= 2.6e+99) {
tmp = fma((t - x), (y / a), x);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1e+39) tmp = t; elseif (z <= 2.6e+99) tmp = fma(Float64(t - x), Float64(y / a), x); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1e+39], t, If[LessEqual[z, 2.6e+99], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+39}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+99}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -9.9999999999999994e38 or 2.6e99 < z Initial program 64.0%
Taylor expanded in z around inf
Applied rewrites48.8%
if -9.9999999999999994e38 < z < 2.6e99Initial program 90.1%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6473.2
Applied rewrites73.2%
Taylor expanded in y around inf
Applied rewrites68.4%
(FPCore (x y z t a) :precision binary64 (if (<= z -1e+39) t (if (<= z 2.6e+99) (fma y (/ (- t x) a) x) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1e+39) {
tmp = t;
} else if (z <= 2.6e+99) {
tmp = fma(y, ((t - x) / a), x);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1e+39) tmp = t; elseif (z <= 2.6e+99) 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, -1e+39], t, If[LessEqual[z, 2.6e+99], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+39}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+99}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -9.9999999999999994e38 or 2.6e99 < z Initial program 64.0%
Taylor expanded in z around inf
Applied rewrites48.8%
if -9.9999999999999994e38 < z < 2.6e99Initial program 90.1%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6466.8
Applied rewrites66.8%
(FPCore (x y z t a) :precision binary64 (if (<= z -3.7e+39) t (if (<= z 2.3e+99) (fma y (/ t a) x) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.7e+39) {
tmp = t;
} else if (z <= 2.3e+99) {
tmp = fma(y, (t / a), x);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3.7e+39) tmp = t; elseif (z <= 2.3e+99) tmp = fma(y, Float64(t / a), x); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.7e+39], t, If[LessEqual[z, 2.3e+99], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{+39}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{+99}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -3.70000000000000012e39 or 2.30000000000000019e99 < z Initial program 63.9%
Taylor expanded in z around inf
Applied rewrites48.9%
if -3.70000000000000012e39 < z < 2.30000000000000019e99Initial program 90.1%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6466.8
Applied rewrites66.8%
Taylor expanded in x around 0
Applied rewrites53.7%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.1e+15) t (if (<= z 9.2e+78) x t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.1e+15) {
tmp = t;
} else if (z <= 9.2e+78) {
tmp = x;
} else {
tmp = t;
}
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.1d+15)) then
tmp = t
else if (z <= 9.2d+78) then
tmp = x
else
tmp = t
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.1e+15) {
tmp = t;
} else if (z <= 9.2e+78) {
tmp = x;
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -1.1e+15: tmp = t elif z <= 9.2e+78: tmp = x else: tmp = t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.1e+15) tmp = t; elseif (z <= 9.2e+78) tmp = x; else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -1.1e+15) tmp = t; elseif (z <= 9.2e+78) tmp = x; else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.1e+15], t, If[LessEqual[z, 9.2e+78], x, t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+15}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{+78}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -1.1e15 or 9.2000000000000008e78 < z Initial program 65.3%
Taylor expanded in z around inf
Applied rewrites47.1%
if -1.1e15 < z < 9.2000000000000008e78Initial program 90.7%
Taylor expanded in a around inf
Applied rewrites32.8%
(FPCore (x y z t a) :precision binary64 t)
double code(double x, double y, double z, double t, double a) {
return t;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = t
end function
public static double code(double x, double y, double z, double t, double a) {
return t;
}
def code(x, y, z, t, a): return t
function code(x, y, z, t, a) return t end
function tmp = code(x, y, z, t, a) tmp = t; end
code[x_, y_, z_, t_, a_] := t
\begin{array}{l}
\\
t
\end{array}
Initial program 79.9%
Taylor expanded in z around inf
Applied rewrites25.4%
herbie shell --seed 2025119
(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)))))