
(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.5%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f6497.6
Applied rewrites97.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (/ x y) (- z t)))) (if (<= (/ x y) -1000.0) t_1 (if (<= (/ x y) 0.04) (fma (/ x y) z t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x / y) * (z - t);
double tmp;
if ((x / y) <= -1000.0) {
tmp = t_1;
} else if ((x / y) <= 0.04) {
tmp = fma((x / y), z, t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x / y) * Float64(z - t)) tmp = 0.0 if (Float64(x / y) <= -1000.0) tmp = t_1; elseif (Float64(x / y) <= 0.04) 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[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -1000.0], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 0.04], N[(N[(x / y), $MachinePrecision] * z + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{y} \cdot \left(z - t\right)\\
\mathbf{if}\;\frac{x}{y} \leq -1000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{x}{y} \leq 0.04:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, z, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 x y) < -1e3 or 0.0400000000000000008 < (/.f64 x y) Initial program 96.7%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6493.3
Applied rewrites93.3%
Taylor expanded in x around inf
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6491.8
Applied rewrites91.8%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6495.5
Applied rewrites95.5%
if -1e3 < (/.f64 x y) < 0.0400000000000000008Initial program 98.3%
Taylor expanded in z around inf
Applied rewrites97.4%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lower-fma.f64N/A
lift-/.f6497.4
Applied rewrites97.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (/ (- z t) y) x))) (if (<= (/ x y) -1e+38) t_1 (if (<= (/ x y) 0.04) (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+38) {
tmp = t_1;
} else if ((x / y) <= 0.04) {
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+38) tmp = t_1; elseif (Float64(x / y) <= 0.04) 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+38], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 0.04], 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^{+38}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{x}{y} \leq 0.04:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, z, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 x y) < -9.99999999999999977e37 or 0.0400000000000000008 < (/.f64 x y) Initial program 96.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6492.9
Applied rewrites92.9%
if -9.99999999999999977e37 < (/.f64 x y) < 0.0400000000000000008Initial program 98.4%
Taylor expanded in z around inf
Applied rewrites95.3%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lower-fma.f64N/A
lift-/.f6495.3
Applied rewrites95.3%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (/ x y) z t))) (if (<= z -2.5e+44) t_1 (if (<= z 2.8e-33) (* (- 1.0 (/ x y)) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((x / y), z, t);
double tmp;
if (z <= -2.5e+44) {
tmp = t_1;
} else if (z <= 2.8e-33) {
tmp = (1.0 - (x / y)) * t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(x / y), z, t) tmp = 0.0 if (z <= -2.5e+44) tmp = t_1; elseif (z <= 2.8e-33) tmp = Float64(Float64(1.0 - Float64(x / y)) * t); 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[z, -2.5e+44], t$95$1, If[LessEqual[z, 2.8e-33], N[(N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{x}{y}, z, t\right)\\
\mathbf{if}\;z \leq -2.5 \cdot 10^{+44}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-33}:\\
\;\;\;\;\left(1 - \frac{x}{y}\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.4999999999999998e44 or 2.8e-33 < z Initial program 98.1%
Taylor expanded in z around inf
Applied rewrites88.9%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lower-fma.f64N/A
lift-/.f6488.9
Applied rewrites88.9%
if -2.4999999999999998e44 < z < 2.8e-33Initial program 97.0%
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-/.f6482.9
Applied rewrites82.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (/ (- x) y) t)))
(if (<= (/ x y) -1e+88)
t_1
(if (<= (/ x y) 10000000.0) (fma (/ x y) z t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (-x / y) * t;
double tmp;
if ((x / y) <= -1e+88) {
tmp = t_1;
} else if ((x / y) <= 10000000.0) {
tmp = fma((x / y), z, t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(Float64(-x) / y) * t) tmp = 0.0 if (Float64(x / y) <= -1e+88) tmp = t_1; elseif (Float64(x / y) <= 10000000.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[((-x) / y), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -1e+88], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 10000000.0], N[(N[(x / y), $MachinePrecision] * z + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{-x}{y} \cdot t\\
\mathbf{if}\;\frac{x}{y} \leq -1 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{x}{y} \leq 10000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, z, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 x y) < -9.99999999999999959e87 or 1e7 < (/.f64 x y) Initial program 96.3%
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-/.f6455.9
Applied rewrites55.9%
Taylor expanded in x around inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6455.8
Applied rewrites55.8%
if -9.99999999999999959e87 < (/.f64 x y) < 1e7Initial program 98.5%
Taylor expanded in z around inf
Applied rewrites92.5%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lower-fma.f64N/A
lift-/.f6492.5
Applied rewrites92.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (/ (- x) y) t))) (if (<= (/ x y) -1e+21) t_1 (if (<= (/ x y) 500.0) t t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (-x / y) * t;
double tmp;
if ((x / y) <= -1e+21) {
tmp = t_1;
} else if ((x / y) <= 500.0) {
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 = (-x / y) * t
if ((x / y) <= (-1d+21)) then
tmp = t_1
else if ((x / y) <= 500.0d0) 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 = (-x / y) * t;
double tmp;
if ((x / y) <= -1e+21) {
tmp = t_1;
} else if ((x / y) <= 500.0) {
tmp = t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (-x / y) * t tmp = 0 if (x / y) <= -1e+21: tmp = t_1 elif (x / y) <= 500.0: tmp = t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(-x) / y) * t) tmp = 0.0 if (Float64(x / y) <= -1e+21) tmp = t_1; elseif (Float64(x / y) <= 500.0) tmp = t; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (-x / y) * t; tmp = 0.0; if ((x / y) <= -1e+21) tmp = t_1; elseif ((x / y) <= 500.0) tmp = t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[((-x) / y), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -1e+21], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 500.0], t, t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{-x}{y} \cdot t\\
\mathbf{if}\;\frac{x}{y} \leq -1 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{x}{y} \leq 500:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 x y) < -1e21 or 500 < (/.f64 x y) Initial program 96.6%
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-/.f6454.9
Applied rewrites54.9%
Taylor expanded in x around inf
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6454.5
Applied rewrites54.5%
if -1e21 < (/.f64 x y) < 500Initial program 98.4%
Taylor expanded in x around 0
Applied rewrites73.0%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -2e-6) (/ (* x z) y) (if (<= (/ x y) 1e-16) t (* (/ z y) x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -2e-6) {
tmp = (x * z) / y;
} else if ((x / y) <= 1e-16) {
tmp = t;
} else {
tmp = (z / y) * x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
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) <= (-2d-6)) then
tmp = (x * z) / y
else if ((x / y) <= 1d-16) then
tmp = t
else
tmp = (z / y) * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -2e-6) {
tmp = (x * z) / y;
} else if ((x / y) <= 1e-16) {
tmp = t;
} else {
tmp = (z / y) * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -2e-6: tmp = (x * z) / y elif (x / y) <= 1e-16: tmp = t else: tmp = (z / y) * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -2e-6) tmp = Float64(Float64(x * z) / y); elseif (Float64(x / y) <= 1e-16) tmp = t; else tmp = Float64(Float64(z / y) * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -2e-6) tmp = (x * z) / y; elseif ((x / y) <= 1e-16) tmp = t; else tmp = (z / y) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -2e-6], N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 1e-16], t, N[(N[(z / y), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -2 \cdot 10^{-6}:\\
\;\;\;\;\frac{x \cdot z}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 10^{-16}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{y} \cdot x\\
\end{array}
\end{array}
if (/.f64 x y) < -1.99999999999999991e-6Initial program 96.5%
Taylor expanded in z around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.9
Applied rewrites51.9%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-/.f64N/A
lower-*.f6451.8
Applied rewrites51.8%
if -1.99999999999999991e-6 < (/.f64 x y) < 9.9999999999999998e-17Initial program 98.3%
Taylor expanded in x around 0
Applied rewrites77.2%
if 9.9999999999999998e-17 < (/.f64 x y) Initial program 97.2%
Taylor expanded in z around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6452.0
Applied rewrites52.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (/ z y) x))) (if (<= (/ x y) -2e-6) t_1 (if (<= (/ x y) 1e-16) t t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (z / y) * x;
double tmp;
if ((x / y) <= -2e-6) {
tmp = t_1;
} else if ((x / y) <= 1e-16) {
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 / y) * x
if ((x / y) <= (-2d-6)) then
tmp = t_1
else if ((x / y) <= 1d-16) 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 / y) * x;
double tmp;
if ((x / y) <= -2e-6) {
tmp = t_1;
} else if ((x / y) <= 1e-16) {
tmp = t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z / y) * x tmp = 0 if (x / y) <= -2e-6: tmp = t_1 elif (x / y) <= 1e-16: tmp = t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z / y) * x) tmp = 0.0 if (Float64(x / y) <= -2e-6) tmp = t_1; elseif (Float64(x / y) <= 1e-16) tmp = t; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z / y) * x; tmp = 0.0; if ((x / y) <= -2e-6) tmp = t_1; elseif ((x / y) <= 1e-16) tmp = t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z / y), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -2e-6], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 1e-16], t, t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z}{y} \cdot x\\
\mathbf{if}\;\frac{x}{y} \leq -2 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{x}{y} \leq 10^{-16}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 x y) < -1.99999999999999991e-6 or 9.9999999999999998e-17 < (/.f64 x y) Initial program 96.8%
Taylor expanded in z around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.9
Applied rewrites51.9%
if -1.99999999999999991e-6 < (/.f64 x y) < 9.9999999999999998e-17Initial program 98.3%
Taylor expanded in x around 0
Applied rewrites77.2%
(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.5%
Taylor expanded in x around 0
Applied rewrites40.0%
herbie shell --seed 2025115
(FPCore (x y z t)
:name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
:precision binary64
(+ (* (/ x y) (- z t)) t))