
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
double code(double x, double y, double z, double t) {
return ((x / y) * (z - t)) + 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x / y) * (z - t)) + t
end function
public static double code(double x, double y, double z, double t) {
return ((x / y) * (z - t)) + t;
}
def code(x, y, z, t): return ((x / y) * (z - t)) + t
function code(x, y, z, t) return Float64(Float64(Float64(x / y) * Float64(z - t)) + t) end
function tmp = code(x, y, z, t) tmp = ((x / y) * (z - t)) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} \cdot \left(z - t\right) + t
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
double code(double x, double y, double z, double t) {
return ((x / y) * (z - t)) + 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x / y) * (z - t)) + t
end function
public static double code(double x, double y, double z, double t) {
return ((x / y) * (z - t)) + t;
}
def code(x, y, z, t): return ((x / y) * (z - t)) + t
function code(x, y, z, t) return Float64(Float64(Float64(x / y) * Float64(z - t)) + t) end
function tmp = code(x, y, z, t) tmp = ((x / y) * (z - t)) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} \cdot \left(z - t\right) + t
\end{array}
(FPCore (x y z t) :precision binary64 (fma (/ x y) (- z t) t))
double code(double x, double y, double z, double t) {
return fma((x / y), (z - t), t);
}
function code(x, y, z, t) return fma(Float64(x / y), Float64(z - t), t) end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)
\end{array}
Initial program 97.7%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f6497.7
Applied rewrites97.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* (- z t) x) y)))
(if (<= (/ x y) -20.0)
t_1
(if (<= (/ x y) 5000000.0) (+ (* (/ z y) x) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = ((z - t) * x) / y;
double tmp;
if ((x / y) <= -20.0) {
tmp = t_1;
} else if ((x / y) <= 5000000.0) {
tmp = ((z / y) * x) + 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)
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) :: t_1
real(8) :: tmp
t_1 = ((z - t) * x) / y
if ((x / y) <= (-20.0d0)) then
tmp = t_1
else if ((x / y) <= 5000000.0d0) then
tmp = ((z / y) * x) + t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = ((z - t) * x) / y;
double tmp;
if ((x / y) <= -20.0) {
tmp = t_1;
} else if ((x / y) <= 5000000.0) {
tmp = ((z / y) * x) + t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = ((z - t) * x) / y tmp = 0 if (x / y) <= -20.0: tmp = t_1 elif (x / y) <= 5000000.0: tmp = ((z / y) * x) + t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(z - t) * x) / y) tmp = 0.0 if (Float64(x / y) <= -20.0) tmp = t_1; elseif (Float64(x / y) <= 5000000.0) tmp = Float64(Float64(Float64(z / y) * x) + t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = ((z - t) * x) / y; tmp = 0.0; if ((x / y) <= -20.0) tmp = t_1; elseif ((x / y) <= 5000000.0) tmp = ((z / y) * x) + t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(z - t), $MachinePrecision] * x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -20.0], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 5000000.0], N[(N[(N[(z / y), $MachinePrecision] * x), $MachinePrecision] + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(z - t\right) \cdot x}{y}\\
\mathbf{if}\;\frac{x}{y} \leq -20:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{x}{y} \leq 5000000:\\
\;\;\;\;\frac{z}{y} \cdot x + t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 x y) < -20 or 5e6 < (/.f64 x y) Initial program 96.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6492.9
Applied rewrites92.9%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
distribute-lft-out--N/A
*-commutativeN/A
fp-cancel-sub-signN/A
lower-/.f64N/A
fp-cancel-sub-signN/A
*-commutativeN/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6493.2
Applied rewrites93.2%
if -20 < (/.f64 x y) < 5e6Initial program 98.5%
Taylor expanded in z around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6493.5
Applied rewrites93.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* (- z t) x) y)))
(if (<= (/ x y) -20.0)
t_1
(if (<= (/ x y) 5000000.0) (fma (/ x y) z t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = ((z - t) * x) / y;
double tmp;
if ((x / y) <= -20.0) {
tmp = t_1;
} else if ((x / y) <= 5000000.0) {
tmp = fma((x / y), z, t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(Float64(z - t) * x) / y) tmp = 0.0 if (Float64(x / y) <= -20.0) tmp = t_1; elseif (Float64(x / y) <= 5000000.0) tmp = fma(Float64(x / y), z, t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(z - t), $MachinePrecision] * x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -20.0], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 5000000.0], N[(N[(x / y), $MachinePrecision] * z + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(z - t\right) \cdot x}{y}\\
\mathbf{if}\;\frac{x}{y} \leq -20:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{x}{y} \leq 5000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, z, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 x y) < -20 or 5e6 < (/.f64 x y) Initial program 96.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6492.9
Applied rewrites92.9%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
distribute-lft-out--N/A
*-commutativeN/A
fp-cancel-sub-signN/A
lower-/.f64N/A
fp-cancel-sub-signN/A
*-commutativeN/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6493.2
Applied rewrites93.2%
if -20 < (/.f64 x y) < 5e6Initial program 98.5%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f6498.5
Applied rewrites98.5%
Taylor expanded in z around inf
Applied rewrites96.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (/ (- z t) y) x))) (if (<= (/ x y) -1e+21) t_1 (if (<= (/ x y) 5e-13) (fma (/ x y) z t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = ((z - t) / y) * x;
double tmp;
if ((x / y) <= -1e+21) {
tmp = t_1;
} else if ((x / y) <= 5e-13) {
tmp = fma((x / y), z, t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(Float64(z - t) / y) * x) tmp = 0.0 if (Float64(x / y) <= -1e+21) tmp = t_1; elseif (Float64(x / y) <= 5e-13) tmp = fma(Float64(x / y), z, t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(z - t), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -1e+21], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 5e-13], N[(N[(x / y), $MachinePrecision] * z + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{y} \cdot x\\
\mathbf{if}\;\frac{x}{y} \leq -1 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{x}{y} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, z, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 x y) < -1e21 or 4.9999999999999999e-13 < (/.f64 x y) Initial program 96.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6492.2
Applied rewrites92.2%
if -1e21 < (/.f64 x y) < 4.9999999999999999e-13Initial program 98.5%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f6498.5
Applied rewrites98.5%
Taylor expanded in z around inf
Applied rewrites96.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- 1.0 (/ x y)) t))) (if (<= t -1.45e+48) t_1 (if (<= t 2.25e+46) (fma (/ x y) z t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (1.0 - (x / y)) * t;
double tmp;
if (t <= -1.45e+48) {
tmp = t_1;
} else if (t <= 2.25e+46) {
tmp = fma((x / y), z, t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(1.0 - Float64(x / y)) * t) tmp = 0.0 if (t <= -1.45e+48) tmp = t_1; elseif (t <= 2.25e+46) tmp = fma(Float64(x / y), z, t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t, -1.45e+48], t$95$1, If[LessEqual[t, 2.25e+46], N[(N[(x / y), $MachinePrecision] * z + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(1 - \frac{x}{y}\right) \cdot t\\
\mathbf{if}\;t \leq -1.45 \cdot 10^{+48}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.25 \cdot 10^{+46}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, z, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.4499999999999999e48 or 2.25000000000000005e46 < t Initial program 99.9%
Taylor expanded in z around 0
*-lft-identityN/A
*-commutativeN/A
associate-*l/N/A
associate-*l*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift-/.f6489.3
Applied rewrites89.3%
if -1.4499999999999999e48 < t < 2.25000000000000005e46Initial program 96.1%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f6496.1
Applied rewrites96.1%
Taylor expanded in z around inf
Applied rewrites84.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (/ x y) z t))) (if (<= y -7.6e-207) t_1 (if (<= y -2.4e-284) (/ (* (- t) x) y) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((x / y), z, t);
double tmp;
if (y <= -7.6e-207) {
tmp = t_1;
} else if (y <= -2.4e-284) {
tmp = (-t * x) / y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(x / y), z, t) tmp = 0.0 if (y <= -7.6e-207) tmp = t_1; elseif (y <= -2.4e-284) tmp = Float64(Float64(Float64(-t) * x) / y); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] * z + t), $MachinePrecision]}, If[LessEqual[y, -7.6e-207], t$95$1, If[LessEqual[y, -2.4e-284], N[(N[((-t) * x), $MachinePrecision] / y), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{x}{y}, z, t\right)\\
\mathbf{if}\;y \leq -7.6 \cdot 10^{-207}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -2.4 \cdot 10^{-284}:\\
\;\;\;\;\frac{\left(-t\right) \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -7.6000000000000001e-207 or -2.40000000000000003e-284 < y Initial program 97.8%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f6497.8
Applied rewrites97.8%
Taylor expanded in z around inf
Applied rewrites78.1%
if -7.6000000000000001e-207 < y < -2.40000000000000003e-284Initial program 96.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6480.2
Applied rewrites80.2%
Taylor expanded in z around 0
associate-*l/N/A
*-commutativeN/A
distribute-lft-out--N/A
*-commutativeN/A
fp-cancel-sub-signN/A
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lift-neg.f6452.3
Applied rewrites52.3%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -20.0) (* (/ x y) (- t)) (if (<= (/ x y) 1e-114) t (* z (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -20.0) {
tmp = (x / y) * -t;
} else if ((x / y) <= 1e-114) {
tmp = t;
} else {
tmp = z * (x / 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)
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) :: tmp
if ((x / y) <= (-20.0d0)) then
tmp = (x / y) * -t
else if ((x / y) <= 1d-114) then
tmp = t
else
tmp = z * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -20.0) {
tmp = (x / y) * -t;
} else if ((x / y) <= 1e-114) {
tmp = t;
} else {
tmp = z * (x / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -20.0: tmp = (x / y) * -t elif (x / y) <= 1e-114: tmp = t else: tmp = z * (x / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -20.0) tmp = Float64(Float64(x / y) * Float64(-t)); elseif (Float64(x / y) <= 1e-114) tmp = t; else tmp = Float64(z * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -20.0) tmp = (x / y) * -t; elseif ((x / y) <= 1e-114) tmp = t; else tmp = z * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -20.0], N[(N[(x / y), $MachinePrecision] * (-t)), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 1e-114], t, N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -20:\\
\;\;\;\;\frac{x}{y} \cdot \left(-t\right)\\
\mathbf{elif}\;\frac{x}{y} \leq 10^{-114}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -20Initial program 97.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6492.2
Applied rewrites92.2%
Taylor expanded in z around inf
Applied rewrites52.3%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6451.0
Applied rewrites51.0%
associate-*l/51.0
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6454.6
Applied rewrites54.6%
if -20 < (/.f64 x y) < 1.0000000000000001e-114Initial program 98.2%
Taylor expanded in x around 0
Applied rewrites77.1%
if 1.0000000000000001e-114 < (/.f64 x y) Initial program 97.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6478.7
Applied rewrites78.7%
Taylor expanded in z around inf
Applied rewrites48.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f6448.7
Applied rewrites48.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6453.5
Applied rewrites53.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* z (/ x y)))) (if (<= (/ x y) -5e-39) t_1 (if (<= (/ x y) 1e-114) t t_1))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x / y);
double tmp;
if ((x / y) <= -5e-39) {
tmp = t_1;
} else if ((x / y) <= 1e-114) {
tmp = 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)
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) :: t_1
real(8) :: tmp
t_1 = z * (x / y)
if ((x / y) <= (-5d-39)) then
tmp = t_1
else if ((x / y) <= 1d-114) then
tmp = t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = z * (x / y);
double tmp;
if ((x / y) <= -5e-39) {
tmp = t_1;
} else if ((x / y) <= 1e-114) {
tmp = t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (x / y) tmp = 0 if (x / y) <= -5e-39: tmp = t_1 elif (x / y) <= 1e-114: tmp = t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(x / y)) tmp = 0.0 if (Float64(x / y) <= -5e-39) tmp = t_1; elseif (Float64(x / y) <= 1e-114) tmp = t; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (x / y); tmp = 0.0; if ((x / y) <= -5e-39) tmp = t_1; elseif ((x / y) <= 1e-114) tmp = t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -5e-39], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 1e-114], t, t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \frac{x}{y}\\
\mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{-39}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{x}{y} \leq 10^{-114}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 x y) < -4.9999999999999998e-39 or 1.0000000000000001e-114 < (/.f64 x y) Initial program 97.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6482.3
Applied rewrites82.3%
Taylor expanded in z around inf
Applied rewrites49.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f6449.9
Applied rewrites49.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6454.6
Applied rewrites54.6%
if -4.9999999999999998e-39 < (/.f64 x y) < 1.0000000000000001e-114Initial program 98.1%
Taylor expanded in x around 0
Applied rewrites80.1%
(FPCore (x y z t) :precision binary64 t)
double code(double x, double y, double z, double t) {
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = t
end function
public static double code(double x, double y, double z, double t) {
return t;
}
def code(x, y, z, t): return t
function code(x, y, z, t) return t end
function tmp = code(x, y, z, t) tmp = t; end
code[x_, y_, z_, t_] := t
\begin{array}{l}
\\
t
\end{array}
Initial program 97.7%
Taylor expanded in x around 0
Applied rewrites38.2%
herbie shell --seed 2025120
(FPCore (x y z t)
:name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
:precision binary64
(+ (* (/ x y) (- z t)) t))