
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
return x + ((y - z) * (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)
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 - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
def code(x, y, z, t): return x + ((y - z) * (t - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - z) * Float64(t - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y - z) * (t - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
return x + ((y - z) * (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)
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 - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
def code(x, y, z, t): return x + ((y - z) * (t - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - z) * Float64(t - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y - z) * (t - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
(FPCore (x y z t) :precision binary64 (fma (- z y) (- x t) x))
double code(double x, double y, double z, double t) {
return fma((z - y), (x - t), x);
}
function code(x, y, z, t) return fma(Float64(z - y), Float64(x - t), x) end
code[x_, y_, z_, t_] := N[(N[(z - y), $MachinePrecision] * N[(x - t), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z - y, x - t, x\right)
\end{array}
Initial program 100.0%
Applied rewrites100.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (- y z) t x))) (if (<= t -3e-56) t_1 (if (<= t 9500000.0) (+ x (* x (- z y))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((y - z), t, x);
double tmp;
if (t <= -3e-56) {
tmp = t_1;
} else if (t <= 9500000.0) {
tmp = x + (x * (z - y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(y - z), t, x) tmp = 0.0 if (t <= -3e-56) tmp = t_1; elseif (t <= 9500000.0) tmp = Float64(x + Float64(x * Float64(z - y))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] * t + x), $MachinePrecision]}, If[LessEqual[t, -3e-56], t$95$1, If[LessEqual[t, 9500000.0], N[(x + N[(x * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y - z, t, x\right)\\
\mathbf{if}\;t \leq -3 \cdot 10^{-56}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 9500000:\\
\;\;\;\;x + x \cdot \left(z - y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.99999999999999989e-56 or 9.5e6 < t Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites64.7%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f6464.7
Applied rewrites64.7%
if -2.99999999999999989e-56 < t < 9.5e6Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6456.0
Applied rewrites56.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (- t x)))) (if (<= y -3.6e+53) t_1 (if (<= y 600000.0) (fma z (- x t) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -3.6e+53) {
tmp = t_1;
} else if (y <= 600000.0) {
tmp = fma(z, (x - t), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) tmp = 0.0 if (y <= -3.6e+53) tmp = t_1; elseif (y <= 600000.0) tmp = fma(z, Float64(x - t), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.6e+53], t$95$1, If[LessEqual[y, 600000.0], N[(z * N[(x - t), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -3.6 \cdot 10^{+53}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 600000:\\
\;\;\;\;\mathsf{fma}\left(z, x - t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -3.6e53 or 6e5 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6445.1
Applied rewrites45.1%
if -3.6e53 < y < 6e5Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites60.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* z (- x t)))) (if (<= z -6.5e-11) t_1 (if (<= z 1.62e+15) (fma (- t x) y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -6.5e-11) {
tmp = t_1;
} else if (z <= 1.62e+15) {
tmp = fma((t - x), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) tmp = 0.0 if (z <= -6.5e-11) tmp = t_1; elseif (z <= 1.62e+15) tmp = fma(Float64(t - x), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.5e-11], t$95$1, If[LessEqual[z, 1.62e+15], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
\mathbf{if}\;z \leq -6.5 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.62 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -6.49999999999999953e-11 or 1.62e15 < z Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6444.2
Applied rewrites44.2%
if -6.49999999999999953e-11 < z < 1.62e15Initial program 100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6460.8
Applied rewrites60.8%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6460.8
Applied rewrites60.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (- x t))))
(if (<= z -6.5e-11)
t_1
(if (<= z 2.2e-207) (fma t y x) (if (<= z 1.62e+15) (* y (- t x)) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -6.5e-11) {
tmp = t_1;
} else if (z <= 2.2e-207) {
tmp = fma(t, y, x);
} else if (z <= 1.62e+15) {
tmp = y * (t - x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) tmp = 0.0 if (z <= -6.5e-11) tmp = t_1; elseif (z <= 2.2e-207) tmp = fma(t, y, x); elseif (z <= 1.62e+15) tmp = Float64(y * Float64(t - x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.5e-11], t$95$1, If[LessEqual[z, 2.2e-207], N[(t * y + x), $MachinePrecision], If[LessEqual[z, 1.62e+15], N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
\mathbf{if}\;z \leq -6.5 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{-207}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{elif}\;z \leq 1.62 \cdot 10^{+15}:\\
\;\;\;\;y \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -6.49999999999999953e-11 or 1.62e15 < z Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6444.2
Applied rewrites44.2%
if -6.49999999999999953e-11 < z < 2.1999999999999999e-207Initial program 100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6460.8
Applied rewrites60.8%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6460.8
Applied rewrites60.8%
Taylor expanded in x around 0
Applied rewrites42.2%
if 2.1999999999999999e-207 < z < 1.62e15Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6445.1
Applied rewrites45.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (- t x)))) (if (<= y -4.3e+51) t_1 (if (<= y 265000.0) (* t (- y z)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -4.3e+51) {
tmp = t_1;
} else if (y <= 265000.0) {
tmp = t * (y - z);
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
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 = y * (t - x)
if (y <= (-4.3d+51)) then
tmp = t_1
else if (y <= 265000.0d0) then
tmp = t * (y - z)
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 = y * (t - x);
double tmp;
if (y <= -4.3e+51) {
tmp = t_1;
} else if (y <= 265000.0) {
tmp = t * (y - z);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * (t - x) tmp = 0 if y <= -4.3e+51: tmp = t_1 elif y <= 265000.0: tmp = t * (y - z) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) tmp = 0.0 if (y <= -4.3e+51) tmp = t_1; elseif (y <= 265000.0) tmp = Float64(t * Float64(y - z)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * (t - x); tmp = 0.0; if (y <= -4.3e+51) tmp = t_1; elseif (y <= 265000.0) tmp = t * (y - z); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.3e+51], t$95$1, If[LessEqual[y, 265000.0], N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -4.3 \cdot 10^{+51}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 265000:\\
\;\;\;\;t \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -4.2999999999999997e51 or 265000 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6445.1
Applied rewrites45.1%
if -4.2999999999999997e51 < y < 265000Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6449.2
Applied rewrites49.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* t (- y z)))) (if (<= t -6e-62) t_1 (if (<= t 3.4e-25) (* x z) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = t * (y - z);
double tmp;
if (t <= -6e-62) {
tmp = t_1;
} else if (t <= 3.4e-25) {
tmp = x * z;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
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 = t * (y - z)
if (t <= (-6d-62)) then
tmp = t_1
else if (t <= 3.4d-25) then
tmp = x * z
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 = t * (y - z);
double tmp;
if (t <= -6e-62) {
tmp = t_1;
} else if (t <= 3.4e-25) {
tmp = x * z;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = t * (y - z) tmp = 0 if t <= -6e-62: tmp = t_1 elif t <= 3.4e-25: tmp = x * z else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(t * Float64(y - z)) tmp = 0.0 if (t <= -6e-62) tmp = t_1; elseif (t <= 3.4e-25) tmp = Float64(x * z); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = t * (y - z); tmp = 0.0; if (t <= -6e-62) tmp = t_1; elseif (t <= 3.4e-25) tmp = x * z; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -6e-62], t$95$1, If[LessEqual[t, 3.4e-25], N[(x * z), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \left(y - z\right)\\
\mathbf{if}\;t \leq -6 \cdot 10^{-62}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3.4 \cdot 10^{-25}:\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -6.0000000000000002e-62 or 3.40000000000000002e-25 < t Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6449.2
Applied rewrites49.2%
if -6.0000000000000002e-62 < t < 3.40000000000000002e-25Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6444.2
Applied rewrites44.2%
Taylor expanded in x around inf
lower-*.f6422.3
Applied rewrites22.3%
(FPCore (x y z t) :precision binary64 (if (<= z -31.5) (* x z) (if (<= z 1.45e+34) (fma t y x) (* x z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -31.5) {
tmp = x * z;
} else if (z <= 1.45e+34) {
tmp = fma(t, y, x);
} else {
tmp = x * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -31.5) tmp = Float64(x * z); elseif (z <= 1.45e+34) tmp = fma(t, y, x); else tmp = Float64(x * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -31.5], N[(x * z), $MachinePrecision], If[LessEqual[z, 1.45e+34], N[(t * y + x), $MachinePrecision], N[(x * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -31.5:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if z < -31.5 or 1.4500000000000001e34 < z Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6444.2
Applied rewrites44.2%
Taylor expanded in x around inf
lower-*.f6422.3
Applied rewrites22.3%
if -31.5 < z < 1.4500000000000001e34Initial program 100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6460.8
Applied rewrites60.8%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6460.8
Applied rewrites60.8%
Taylor expanded in x around 0
Applied rewrites42.2%
(FPCore (x y z t) :precision binary64 (if (<= t -2.6e-61) (* t y) (if (<= t 6.2e+36) (* x z) (* t y))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -2.6e-61) {
tmp = t * y;
} else if (t <= 6.2e+36) {
tmp = x * z;
} else {
tmp = t * 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 (t <= (-2.6d-61)) then
tmp = t * y
else if (t <= 6.2d+36) then
tmp = x * z
else
tmp = t * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -2.6e-61) {
tmp = t * y;
} else if (t <= 6.2e+36) {
tmp = x * z;
} else {
tmp = t * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -2.6e-61: tmp = t * y elif t <= 6.2e+36: tmp = x * z else: tmp = t * y return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -2.6e-61) tmp = Float64(t * y); elseif (t <= 6.2e+36) tmp = Float64(x * z); else tmp = Float64(t * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -2.6e-61) tmp = t * y; elseif (t <= 6.2e+36) tmp = x * z; else tmp = t * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -2.6e-61], N[(t * y), $MachinePrecision], If[LessEqual[t, 6.2e+36], N[(x * z), $MachinePrecision], N[(t * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.6 \cdot 10^{-61}:\\
\;\;\;\;t \cdot y\\
\mathbf{elif}\;t \leq 6.2 \cdot 10^{+36}:\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;t \cdot y\\
\end{array}
\end{array}
if t < -2.6000000000000001e-61 or 6.1999999999999999e36 < t Initial program 100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6460.8
Applied rewrites60.8%
Taylor expanded in x around 0
lower-*.f6426.7
Applied rewrites26.7%
if -2.6000000000000001e-61 < t < 6.1999999999999999e36Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6444.2
Applied rewrites44.2%
Taylor expanded in x around inf
lower-*.f6422.3
Applied rewrites22.3%
(FPCore (x y z t) :precision binary64 (* t y))
double code(double x, double y, double z, double t) {
return t * y;
}
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 * y
end function
public static double code(double x, double y, double z, double t) {
return t * y;
}
def code(x, y, z, t): return t * y
function code(x, y, z, t) return Float64(t * y) end
function tmp = code(x, y, z, t) tmp = t * y; end
code[x_, y_, z_, t_] := N[(t * y), $MachinePrecision]
\begin{array}{l}
\\
t \cdot y
\end{array}
Initial program 100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6460.8
Applied rewrites60.8%
Taylor expanded in x around 0
lower-*.f6426.7
Applied rewrites26.7%
herbie shell --seed 2025149
(FPCore (x y z t)
:name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
:precision binary64
(+ x (* (- y z) (- t x))))