
(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 16 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 -1e-304)
(fma (- t x) (- (/ y (- a z)) (/ z (- a z))) x)
(if (<= t_1 0.0)
(fma (- (- t x)) (/ (- y a) z) t)
(fma (- t x) (/ (- y z) (- a z)) x)))))
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-304) {
tmp = fma((t - x), ((y / (a - z)) - (z / (a - z))), x);
} else if (t_1 <= 0.0) {
tmp = fma(-(t - x), ((y - a) / z), t);
} else {
tmp = fma((t - x), ((y - z) / (a - z)), x);
}
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-304) tmp = fma(Float64(t - x), Float64(Float64(y / Float64(a - z)) - Float64(z / Float64(a - z))), x); elseif (t_1 <= 0.0) tmp = fma(Float64(-Float64(t - x)), Float64(Float64(y - a) / z), t); else tmp = fma(Float64(t - x), Float64(Float64(y - z) / Float64(a - z)), x); 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[LessEqual[t$95$1, -1e-304], N[(N[(t - x), $MachinePrecision] * N[(N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision] - N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[((-N[(t - x), $MachinePrecision]) * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] + x), $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^{-304}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a - z} - \frac{z}{a - z}, x\right)\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(-\left(t - x\right), \frac{y - a}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a - z}, x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -9.99999999999999971e-305Initial program 89.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-/.f6492.1
Applied rewrites92.1%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6492.1
Applied rewrites92.1%
if -9.99999999999999971e-305 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 0.0Initial program 3.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--.f6499.8
Applied rewrites99.8%
if 0.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 87.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-/.f6493.1
Applied rewrites93.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (* (- y z) (/ (- t x) (- a z))))))
(if (or (<= t_1 -1e-304) (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-304) || !(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-304) || !(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-304], 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^{-304} \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)))) < -9.99999999999999971e-305 or 0.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 88.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-/.f6492.6
Applied rewrites92.6%
if -9.99999999999999971e-305 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 0.0Initial program 3.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--.f6499.8
Applied rewrites99.8%
Final simplification93.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.82e+81) (not (<= a 1.8e+16))) (fma (- y z) (/ (- t x) a) x) (fma (- (- t x)) (/ (- y a) z) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.82e+81) || !(a <= 1.8e+16)) {
tmp = fma((y - z), ((t - x) / a), x);
} else {
tmp = fma(-(t - x), ((y - a) / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.82e+81) || !(a <= 1.8e+16)) tmp = fma(Float64(y - z), Float64(Float64(t - x) / a), x); else tmp = fma(Float64(-Float64(t - x)), Float64(Float64(y - a) / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.82e+81], N[Not[LessEqual[a, 1.8e+16]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[((-N[(t - x), $MachinePrecision]) * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.82 \cdot 10^{+81} \lor \neg \left(a \leq 1.8 \cdot 10^{+16}\right):\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-\left(t - x\right), \frac{y - a}{z}, t\right)\\
\end{array}
\end{array}
if a < -1.82000000000000003e81 or 1.8e16 < a Initial program 89.3%
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--.f6482.0
Applied rewrites82.0%
if -1.82000000000000003e81 < a < 1.8e16Initial program 66.2%
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--.f6482.3
Applied rewrites82.3%
Final simplification82.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.06e-19) (not (<= a 67000000000000.0))) (fma (- y z) (/ (- t x) a) x) (- t (/ (* (- y a) (- t x)) z))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.06e-19) || !(a <= 67000000000000.0)) {
tmp = fma((y - z), ((t - x) / a), x);
} else {
tmp = t - (((y - a) * (t - x)) / z);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.06e-19) || !(a <= 67000000000000.0)) tmp = fma(Float64(y - z), Float64(Float64(t - x) / a), x); else tmp = Float64(t - Float64(Float64(Float64(y - a) * Float64(t - x)) / z)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.06e-19], N[Not[LessEqual[a, 67000000000000.0]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(t - N[(N[(N[(y - a), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.06 \cdot 10^{-19} \lor \neg \left(a \leq 67000000000000\right):\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t - \frac{\left(y - a\right) \cdot \left(t - x\right)}{z}\\
\end{array}
\end{array}
if a < -1.06e-19 or 6.7e13 < a Initial program 88.1%
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--.f6478.6
Applied rewrites78.6%
if -1.06e-19 < a < 6.7e13Initial program 65.1%
Taylor expanded in z around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites63.4%
Taylor expanded in z around inf
Applied rewrites78.1%
Final simplification78.3%
(FPCore (x y z t a)
:precision binary64
(if (<= a -1.82e+81)
(+ x (* (/ (- y z) a) (- t x)))
(if (<= a 1.8e+16)
(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 (a <= -1.82e+81) {
tmp = x + (((y - z) / a) * (t - x));
} else if (a <= 1.8e+16) {
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 (a <= -1.82e+81) tmp = Float64(x + Float64(Float64(Float64(y - z) / a) * Float64(t - x))); elseif (a <= 1.8e+16) 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[LessEqual[a, -1.82e+81], N[(x + N[(N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.8e+16], 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}\;a \leq -1.82 \cdot 10^{+81}:\\
\;\;\;\;x + \frac{y - z}{a} \cdot \left(t - x\right)\\
\mathbf{elif}\;a \leq 1.8 \cdot 10^{+16}:\\
\;\;\;\;\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 a < -1.82000000000000003e81Initial program 90.3%
Taylor expanded in a around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6486.2
Applied rewrites86.2%
if -1.82000000000000003e81 < a < 1.8e16Initial program 66.2%
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--.f6482.3
Applied rewrites82.3%
if 1.8e16 < a Initial program 88.4%
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--.f6480.2
Applied rewrites80.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -5.5e-26) (not (<= a 54000000000000.0))) (fma (- y z) (/ (- t x) a) x) (- t (/ (* (- t x) y) z))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -5.5e-26) || !(a <= 54000000000000.0)) {
tmp = fma((y - z), ((t - x) / a), x);
} else {
tmp = t - (((t - x) * y) / z);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -5.5e-26) || !(a <= 54000000000000.0)) tmp = fma(Float64(y - z), Float64(Float64(t - x) / a), x); else tmp = Float64(t - Float64(Float64(Float64(t - x) * y) / z)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -5.5e-26], N[Not[LessEqual[a, 54000000000000.0]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(t - N[(N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.5 \cdot 10^{-26} \lor \neg \left(a \leq 54000000000000\right):\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t - \frac{\left(t - x\right) \cdot y}{z}\\
\end{array}
\end{array}
if a < -5.5000000000000005e-26 or 5.4e13 < a Initial program 86.9%
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--.f6477.5
Applied rewrites77.5%
if -5.5000000000000005e-26 < a < 5.4e13Initial program 65.7%
Taylor expanded in z around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites63.3%
Taylor expanded in a around 0
Applied rewrites69.5%
Final simplification73.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.85e-11) (not (<= z 255000.0))) (* (- y z) (/ t (- a z))) (fma (- t x) (/ y a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.85e-11) || !(z <= 255000.0)) {
tmp = (y - z) * (t / (a - z));
} else {
tmp = fma((t - x), (y / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.85e-11) || !(z <= 255000.0)) tmp = Float64(Float64(y - z) * Float64(t / Float64(a - z))); else tmp = fma(Float64(t - x), Float64(y / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.85e-11], N[Not[LessEqual[z, 255000.0]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] * N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.85 \cdot 10^{-11} \lor \neg \left(z \leq 255000\right):\\
\;\;\;\;\left(y - z\right) \cdot \frac{t}{a - z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\end{array}
\end{array}
if z < -1.8500000000000001e-11 or 255000 < z Initial program 65.9%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6459.2
Applied rewrites59.2%
if -1.8500000000000001e-11 < z < 255000Initial program 85.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-/.f6489.1
Applied rewrites89.1%
Taylor expanded in z around 0
lower-/.f6471.6
Applied rewrites71.6%
Final simplification65.5%
(FPCore (x y z t a) :precision binary64 (if (<= a -5.5e-26) (fma (- t x) (/ y a) x) (if (<= a 6.6e+14) (- t (/ (* (- t x) y) z)) (fma (- y z) (/ t a) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -5.5e-26) {
tmp = fma((t - x), (y / a), x);
} else if (a <= 6.6e+14) {
tmp = t - (((t - x) * y) / z);
} else {
tmp = fma((y - z), (t / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -5.5e-26) tmp = fma(Float64(t - x), Float64(y / a), x); elseif (a <= 6.6e+14) tmp = Float64(t - Float64(Float64(Float64(t - x) * y) / z)); else tmp = fma(Float64(y - z), Float64(t / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -5.5e-26], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[a, 6.6e+14], N[(t - N[(N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(t / a), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.5 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\mathbf{elif}\;a \leq 6.6 \cdot 10^{+14}:\\
\;\;\;\;t - \frac{\left(t - x\right) \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t}{a}, x\right)\\
\end{array}
\end{array}
if a < -5.5000000000000005e-26Initial program 85.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-/.f6491.4
Applied rewrites91.4%
Taylor expanded in z around 0
lower-/.f6470.6
Applied rewrites70.6%
if -5.5000000000000005e-26 < a < 6.6e14Initial program 65.7%
Taylor expanded in z around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites63.3%
Taylor expanded in a around 0
Applied rewrites69.5%
if 6.6e14 < a Initial program 88.4%
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--.f6480.2
Applied rewrites80.2%
Taylor expanded in x around 0
Applied rewrites75.1%
(FPCore (x y z t a) :precision binary64 (if (<= a -1.5e-25) (fma (- t x) (/ y a) x) (if (<= a 5.2e+82) (* (- t x) (/ y (- a z))) (fma (- y z) (/ t a) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.5e-25) {
tmp = fma((t - x), (y / a), x);
} else if (a <= 5.2e+82) {
tmp = (t - x) * (y / (a - z));
} else {
tmp = fma((y - z), (t / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -1.5e-25) tmp = fma(Float64(t - x), Float64(y / a), x); elseif (a <= 5.2e+82) tmp = Float64(Float64(t - x) * Float64(y / Float64(a - z))); else tmp = fma(Float64(y - z), Float64(t / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -1.5e-25], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[a, 5.2e+82], N[(N[(t - x), $MachinePrecision] * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(t / a), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.5 \cdot 10^{-25}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\mathbf{elif}\;a \leq 5.2 \cdot 10^{+82}:\\
\;\;\;\;\left(t - x\right) \cdot \frac{y}{a - z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t}{a}, x\right)\\
\end{array}
\end{array}
if a < -1.4999999999999999e-25Initial program 85.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-/.f6491.4
Applied rewrites91.4%
Taylor expanded in z around 0
lower-/.f6470.6
Applied rewrites70.6%
if -1.4999999999999999e-25 < a < 5.1999999999999997e82Initial program 66.3%
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--.f6451.0
Applied rewrites51.0%
if 5.1999999999999997e82 < a Initial program 92.1%
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--.f6484.0
Applied rewrites84.0%
Taylor expanded in x around 0
Applied rewrites79.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2e+165) (not (<= z 1.42e+43))) (+ x (- t x)) (fma (- t x) (/ y a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2e+165) || !(z <= 1.42e+43)) {
tmp = x + (t - x);
} else {
tmp = fma((t - x), (y / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2e+165) || !(z <= 1.42e+43)) tmp = Float64(x + Float64(t - x)); else tmp = fma(Float64(t - x), Float64(y / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2e+165], N[Not[LessEqual[z, 1.42e+43]], $MachinePrecision]], N[(x + N[(t - x), $MachinePrecision]), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+165} \lor \neg \left(z \leq 1.42 \cdot 10^{+43}\right):\\
\;\;\;\;x + \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\end{array}
\end{array}
if z < -1.9999999999999998e165 or 1.4199999999999999e43 < z Initial program 62.3%
Taylor expanded in z around inf
lower--.f6442.2
Applied rewrites42.2%
if -1.9999999999999998e165 < z < 1.4199999999999999e43Initial program 82.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-/.f6486.0
Applied rewrites86.0%
Taylor expanded in z around 0
lower-/.f6464.1
Applied rewrites64.1%
Final simplification56.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.2e+164) (not (<= z 1.42e+43))) (+ x (- t x)) (fma (/ (- t x) a) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.2e+164) || !(z <= 1.42e+43)) {
tmp = x + (t - x);
} else {
tmp = fma(((t - x) / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.2e+164) || !(z <= 1.42e+43)) tmp = Float64(x + Float64(t - x)); else tmp = fma(Float64(Float64(t - x) / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.2e+164], N[Not[LessEqual[z, 1.42e+43]], $MachinePrecision]], N[(x + N[(t - x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+164} \lor \neg \left(z \leq 1.42 \cdot 10^{+43}\right):\\
\;\;\;\;x + \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a}, y, x\right)\\
\end{array}
\end{array}
if z < -4.1999999999999998e164 or 1.4199999999999999e43 < z Initial program 62.3%
Taylor expanded in z around inf
lower--.f6442.2
Applied rewrites42.2%
if -4.1999999999999998e164 < z < 1.4199999999999999e43Initial program 82.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6461.7
Applied rewrites61.7%
Final simplification55.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3.1e+251) (not (<= z 1.42e+43))) (+ x (- t x)) (fma (- y z) (/ t a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.1e+251) || !(z <= 1.42e+43)) {
tmp = x + (t - x);
} else {
tmp = fma((y - z), (t / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3.1e+251) || !(z <= 1.42e+43)) tmp = Float64(x + Float64(t - x)); else tmp = fma(Float64(y - z), Float64(t / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3.1e+251], N[Not[LessEqual[z, 1.42e+43]], $MachinePrecision]], N[(x + N[(t - x), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(t / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{+251} \lor \neg \left(z \leq 1.42 \cdot 10^{+43}\right):\\
\;\;\;\;x + \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t}{a}, x\right)\\
\end{array}
\end{array}
if z < -3.0999999999999998e251 or 1.4199999999999999e43 < z Initial program 59.8%
Taylor expanded in z around inf
lower--.f6445.6
Applied rewrites45.6%
if -3.0999999999999998e251 < z < 1.4199999999999999e43Initial 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--.f6462.8
Applied rewrites62.8%
Taylor expanded in x around 0
Applied rewrites52.6%
Final simplification50.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.8e+182) (not (<= z 1.42e+43))) (+ x (- t x)) (fma (/ t a) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.8e+182) || !(z <= 1.42e+43)) {
tmp = x + (t - x);
} else {
tmp = fma((t / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.8e+182) || !(z <= 1.42e+43)) tmp = Float64(x + Float64(t - x)); else tmp = fma(Float64(t / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.8e+182], N[Not[LessEqual[z, 1.42e+43]], $MachinePrecision]], N[(x + N[(t - x), $MachinePrecision]), $MachinePrecision], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{+182} \lor \neg \left(z \leq 1.42 \cdot 10^{+43}\right):\\
\;\;\;\;x + \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\end{array}
\end{array}
if z < -1.8e182 or 1.4199999999999999e43 < z Initial program 62.9%
Taylor expanded in z around inf
lower--.f6444.2
Applied rewrites44.2%
if -1.8e182 < z < 1.4199999999999999e43Initial program 82.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-/.f6485.2
Applied rewrites85.2%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
div-subN/A
*-commutativeN/A
lower-fma.f64N/A
div-subN/A
lower-/.f64N/A
lower--.f6460.3
Applied rewrites60.3%
Taylor expanded in x around 0
Applied rewrites49.2%
Final simplification47.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -6.1e+50) (not (<= z 3.7e+42))) (+ x (- t x)) (/ (* t y) a)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -6.1e+50) || !(z <= 3.7e+42)) {
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 <= (-6.1d+50)) .or. (.not. (z <= 3.7d+42))) 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 <= -6.1e+50) || !(z <= 3.7e+42)) {
tmp = x + (t - x);
} else {
tmp = (t * y) / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -6.1e+50) or not (z <= 3.7e+42): tmp = x + (t - x) else: tmp = (t * y) / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -6.1e+50) || !(z <= 3.7e+42)) tmp = Float64(x + Float64(t - x)); else tmp = Float64(Float64(t * y) / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -6.1e+50) || ~((z <= 3.7e+42))) tmp = x + (t - x); else tmp = (t * y) / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -6.1e+50], N[Not[LessEqual[z, 3.7e+42]], $MachinePrecision]], N[(x + N[(t - x), $MachinePrecision]), $MachinePrecision], N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.1 \cdot 10^{+50} \lor \neg \left(z \leq 3.7 \cdot 10^{+42}\right):\\
\;\;\;\;x + \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t \cdot y}{a}\\
\end{array}
\end{array}
if z < -6.10000000000000026e50 or 3.69999999999999996e42 < z Initial program 62.9%
Taylor expanded in z around inf
lower--.f6438.0
Applied rewrites38.0%
if -6.10000000000000026e50 < z < 3.69999999999999996e42Initial program 85.4%
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.4
Applied rewrites88.4%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
div-subN/A
*-commutativeN/A
lower-fma.f64N/A
div-subN/A
lower-/.f64N/A
lower--.f6467.1
Applied rewrites67.1%
Taylor expanded in x around 0
Applied rewrites22.6%
Final simplification29.0%
(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 76.0%
Taylor expanded in z around inf
lower--.f6418.8
Applied rewrites18.8%
(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 76.0%
Taylor expanded in z around inf
lower--.f6418.8
Applied rewrites18.8%
Taylor expanded in x around inf
Applied rewrites2.9%
herbie shell --seed 2024363
(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)))))