
(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}
Sampling outcomes in binary64 precision:
Herbie found 14 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 (+ 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}
Initial program 100.0%
(FPCore (x y z t) :precision binary64 (if (<= y -6.5e+15) (fma (- t x) y x) (if (<= y 1.3e-5) (- x (* (- t x) z)) (* (- t x) y))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.5e+15) {
tmp = fma((t - x), y, x);
} else if (y <= 1.3e-5) {
tmp = x - ((t - x) * z);
} else {
tmp = (t - x) * y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -6.5e+15) tmp = fma(Float64(t - x), y, x); elseif (y <= 1.3e-5) tmp = Float64(x - Float64(Float64(t - x) * z)); else tmp = Float64(Float64(t - x) * y); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -6.5e+15], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[y, 1.3e-5], N[(x - N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-5}:\\
\;\;\;\;x - \left(t - x\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left(t - x\right) \cdot y\\
\end{array}
\end{array}
if y < -6.5e15Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6483.1
Applied rewrites83.1%
if -6.5e15 < y < 1.29999999999999992e-5Initial program 100.0%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6491.5
Applied rewrites91.5%
if 1.29999999999999992e-5 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6485.6
Applied rewrites85.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- 1.0 (- y z)) x))) (if (<= x -6.5e-59) t_1 (if (<= x 1.4e-34) (* (- y z) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (1.0 - (y - z)) * x;
double tmp;
if (x <= -6.5e-59) {
tmp = t_1;
} else if (x <= 1.4e-34) {
tmp = (y - z) * t;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
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 = (1.0d0 - (y - z)) * x
if (x <= (-6.5d-59)) then
tmp = t_1
else if (x <= 1.4d-34) then
tmp = (y - z) * t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (1.0 - (y - z)) * x;
double tmp;
if (x <= -6.5e-59) {
tmp = t_1;
} else if (x <= 1.4e-34) {
tmp = (y - z) * t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (1.0 - (y - z)) * x tmp = 0 if x <= -6.5e-59: tmp = t_1 elif x <= 1.4e-34: tmp = (y - z) * t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(1.0 - Float64(y - z)) * x) tmp = 0.0 if (x <= -6.5e-59) tmp = t_1; elseif (x <= 1.4e-34) tmp = Float64(Float64(y - z) * t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (1.0 - (y - z)) * x; tmp = 0.0; if (x <= -6.5e-59) tmp = t_1; elseif (x <= 1.4e-34) tmp = (y - z) * t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(1.0 - N[(y - z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -6.5e-59], t$95$1, If[LessEqual[x, 1.4e-34], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(1 - \left(y - z\right)\right) \cdot x\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{-59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-34}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -6.50000000000000017e-59 or 1.39999999999999998e-34 < x Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift--.f6486.8
Applied rewrites86.8%
if -6.50000000000000017e-59 < x < 1.39999999999999998e-34Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6485.3
Applied rewrites85.3%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- x t) z))) (if (<= z -1700000.0) t_1 (if (<= z 2.35e+54) (fma (- t x) y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x - t) * z;
double tmp;
if (z <= -1700000.0) {
tmp = t_1;
} else if (z <= 2.35e+54) {
tmp = fma((t - x), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x - t) * z) tmp = 0.0 if (z <= -1700000.0) tmp = t_1; elseif (z <= 2.35e+54) 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[(N[(x - t), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1700000.0], t$95$1, If[LessEqual[z, 2.35e+54], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x - t\right) \cdot z\\
\mathbf{if}\;z \leq -1700000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.35 \cdot 10^{+54}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.7e6 or 2.34999999999999996e54 < z Initial program 99.9%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-outN/A
associate-*r*N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
Applied rewrites91.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6477.7
Applied rewrites77.7%
if -1.7e6 < z < 2.34999999999999996e54Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6487.8
Applied rewrites87.8%
Final simplification83.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- t x) y)) (t_2 (- x (* z t))))
(if (<= y -6.2e+15)
t_1
(if (<= y -8e-198)
t_2
(if (<= y 1.9e-148) (fma z x x) (if (<= y 1.3e-5) t_2 t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * y;
double t_2 = x - (z * t);
double tmp;
if (y <= -6.2e+15) {
tmp = t_1;
} else if (y <= -8e-198) {
tmp = t_2;
} else if (y <= 1.9e-148) {
tmp = fma(z, x, x);
} else if (y <= 1.3e-5) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(t - x) * y) t_2 = Float64(x - Float64(z * t)) tmp = 0.0 if (y <= -6.2e+15) tmp = t_1; elseif (y <= -8e-198) tmp = t_2; elseif (y <= 1.9e-148) tmp = fma(z, x, x); elseif (y <= 1.3e-5) tmp = t_2; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$2 = N[(x - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.2e+15], t$95$1, If[LessEqual[y, -8e-198], t$95$2, If[LessEqual[y, 1.9e-148], N[(z * x + x), $MachinePrecision], If[LessEqual[y, 1.3e-5], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot y\\
t_2 := x - z \cdot t\\
\mathbf{if}\;y \leq -6.2 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -8 \cdot 10^{-198}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-148}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -6.2e15 or 1.29999999999999992e-5 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6484.2
Applied rewrites84.2%
if -6.2e15 < y < -7.9999999999999993e-198 or 1.90000000000000007e-148 < y < 1.29999999999999992e-5Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-outN/A
associate-*r*N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
Applied rewrites99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f6486.4
Applied rewrites86.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f6470.0
Applied rewrites70.0%
if -7.9999999999999993e-198 < y < 1.90000000000000007e-148Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-outN/A
associate-*r*N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f6497.0
Applied rewrites97.0%
Taylor expanded in t around 0
associate-*r*N/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6473.0
Applied rewrites73.0%
Final simplification77.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- t x) y))) (if (<= y -0.06) t_1 (if (<= y 1.3e-5) (fma z x x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * y;
double tmp;
if (y <= -0.06) {
tmp = t_1;
} else if (y <= 1.3e-5) {
tmp = fma(z, x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(t - x) * y) tmp = 0.0 if (y <= -0.06) tmp = t_1; elseif (y <= 1.3e-5) tmp = fma(z, x, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -0.06], t$95$1, If[LessEqual[y, 1.3e-5], N[(z * x + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot y\\
\mathbf{if}\;y \leq -0.06:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -0.059999999999999998 or 1.29999999999999992e-5 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6482.0
Applied rewrites82.0%
if -0.059999999999999998 < y < 1.29999999999999992e-5Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-outN/A
associate-*r*N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f6493.2
Applied rewrites93.2%
Taylor expanded in t around 0
associate-*r*N/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6465.7
Applied rewrites65.7%
Final simplification73.8%
(FPCore (x y z t) :precision binary64 (if (<= y -12000000.0) (* (- 1.0 y) x) (if (<= y 9000000000000.0) (fma z x x) (* (- x) y))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -12000000.0) {
tmp = (1.0 - y) * x;
} else if (y <= 9000000000000.0) {
tmp = fma(z, x, x);
} else {
tmp = -x * y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -12000000.0) tmp = Float64(Float64(1.0 - y) * x); elseif (y <= 9000000000000.0) tmp = fma(z, x, x); else tmp = Float64(Float64(-x) * y); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -12000000.0], N[(N[(1.0 - y), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 9000000000000.0], N[(z * x + x), $MachinePrecision], N[((-x) * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -12000000:\\
\;\;\;\;\left(1 - y\right) \cdot x\\
\mathbf{elif}\;y \leq 9000000000000:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot y\\
\end{array}
\end{array}
if y < -1.2e7Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift--.f6452.0
Applied rewrites52.0%
Taylor expanded in z around 0
lower--.f6447.9
Applied rewrites47.9%
if -1.2e7 < y < 9e12Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-outN/A
associate-*r*N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f6491.4
Applied rewrites91.4%
Taylor expanded in t around 0
associate-*r*N/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6464.9
Applied rewrites64.9%
if 9e12 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6486.8
Applied rewrites86.8%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6456.0
Applied rewrites56.0%
Final simplification58.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- x) y))) (if (<= y -950000000.0) t_1 (if (<= y 9000000000000.0) (fma z x x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = -x * y;
double tmp;
if (y <= -950000000.0) {
tmp = t_1;
} else if (y <= 9000000000000.0) {
tmp = fma(z, x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(-x) * y) tmp = 0.0 if (y <= -950000000.0) tmp = t_1; elseif (y <= 9000000000000.0) tmp = fma(z, x, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-x) * y), $MachinePrecision]}, If[LessEqual[y, -950000000.0], t$95$1, If[LessEqual[y, 9000000000000.0], N[(z * x + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-x\right) \cdot y\\
\mathbf{if}\;y \leq -950000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 9000000000000:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -9.5e8 or 9e12 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6483.4
Applied rewrites83.4%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6451.2
Applied rewrites51.2%
if -9.5e8 < y < 9e12Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-outN/A
associate-*r*N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f6491.4
Applied rewrites91.4%
Taylor expanded in t around 0
associate-*r*N/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6464.9
Applied rewrites64.9%
Final simplification58.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- z) t)))
(if (<= z -2.4e+102)
t_1
(if (<= z -1000000.0) (* z x) (if (<= z 6.1e+56) (fma t y x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = -z * t;
double tmp;
if (z <= -2.4e+102) {
tmp = t_1;
} else if (z <= -1000000.0) {
tmp = z * x;
} else if (z <= 6.1e+56) {
tmp = fma(t, y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(-z) * t) tmp = 0.0 if (z <= -2.4e+102) tmp = t_1; elseif (z <= -1000000.0) tmp = Float64(z * x); elseif (z <= 6.1e+56) tmp = fma(t, y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-z) * t), $MachinePrecision]}, If[LessEqual[z, -2.4e+102], t$95$1, If[LessEqual[z, -1000000.0], N[(z * x), $MachinePrecision], If[LessEqual[z, 6.1e+56], N[(t * y + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-z\right) \cdot t\\
\mathbf{if}\;z \leq -2.4 \cdot 10^{+102}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1000000:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq 6.1 \cdot 10^{+56}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.39999999999999994e102 or 6.1000000000000001e56 < z Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6480.5
Applied rewrites80.5%
Taylor expanded in x around 0
Applied rewrites50.2%
if -2.39999999999999994e102 < z < -1e6Initial program 99.9%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6466.7
Applied rewrites66.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6452.2
Applied rewrites52.2%
if -1e6 < z < 6.1000000000000001e56Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6487.2
Applied rewrites87.2%
Taylor expanded in x around 0
Applied rewrites58.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- x) y)) (t_2 (* (- z) t)))
(if (<= y -6.5e+15)
t_1
(if (<= y -8e-198)
t_2
(if (<= y 1.9e-148) (* z x) (if (<= y 1.3e-5) t_2 t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = -x * y;
double t_2 = -z * t;
double tmp;
if (y <= -6.5e+15) {
tmp = t_1;
} else if (y <= -8e-198) {
tmp = t_2;
} else if (y <= 1.9e-148) {
tmp = z * x;
} else if (y <= 1.3e-5) {
tmp = t_2;
} 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) :: t_2
real(8) :: tmp
t_1 = -x * y
t_2 = -z * t
if (y <= (-6.5d+15)) then
tmp = t_1
else if (y <= (-8d-198)) then
tmp = t_2
else if (y <= 1.9d-148) then
tmp = z * x
else if (y <= 1.3d-5) then
tmp = t_2
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;
double t_2 = -z * t;
double tmp;
if (y <= -6.5e+15) {
tmp = t_1;
} else if (y <= -8e-198) {
tmp = t_2;
} else if (y <= 1.9e-148) {
tmp = z * x;
} else if (y <= 1.3e-5) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = -x * y t_2 = -z * t tmp = 0 if y <= -6.5e+15: tmp = t_1 elif y <= -8e-198: tmp = t_2 elif y <= 1.9e-148: tmp = z * x elif y <= 1.3e-5: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(-x) * y) t_2 = Float64(Float64(-z) * t) tmp = 0.0 if (y <= -6.5e+15) tmp = t_1; elseif (y <= -8e-198) tmp = t_2; elseif (y <= 1.9e-148) tmp = Float64(z * x); elseif (y <= 1.3e-5) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -x * y; t_2 = -z * t; tmp = 0.0; if (y <= -6.5e+15) tmp = t_1; elseif (y <= -8e-198) tmp = t_2; elseif (y <= 1.9e-148) tmp = z * x; elseif (y <= 1.3e-5) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-x) * y), $MachinePrecision]}, Block[{t$95$2 = N[((-z) * t), $MachinePrecision]}, If[LessEqual[y, -6.5e+15], t$95$1, If[LessEqual[y, -8e-198], t$95$2, If[LessEqual[y, 1.9e-148], N[(z * x), $MachinePrecision], If[LessEqual[y, 1.3e-5], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-x\right) \cdot y\\
t_2 := \left(-z\right) \cdot t\\
\mathbf{if}\;y \leq -6.5 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -8 \cdot 10^{-198}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-148}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -6.5e15 or 1.29999999999999992e-5 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6484.2
Applied rewrites84.2%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6451.0
Applied rewrites51.0%
if -6.5e15 < y < -7.9999999999999993e-198 or 1.90000000000000007e-148 < y < 1.29999999999999992e-5Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6457.0
Applied rewrites57.0%
Taylor expanded in x around 0
Applied rewrites41.1%
if -7.9999999999999993e-198 < y < 1.90000000000000007e-148Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6468.3
Applied rewrites68.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6445.1
Applied rewrites45.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- x) y))) (if (<= y -42000000.0) t_1 (if (<= y 9000000000000.0) (* z x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = -x * y;
double tmp;
if (y <= -42000000.0) {
tmp = t_1;
} else if (y <= 9000000000000.0) {
tmp = z * x;
} 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
if (y <= (-42000000.0d0)) then
tmp = t_1
else if (y <= 9000000000000.0d0) then
tmp = z * x
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;
double tmp;
if (y <= -42000000.0) {
tmp = t_1;
} else if (y <= 9000000000000.0) {
tmp = z * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = -x * y tmp = 0 if y <= -42000000.0: tmp = t_1 elif y <= 9000000000000.0: tmp = z * x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(-x) * y) tmp = 0.0 if (y <= -42000000.0) tmp = t_1; elseif (y <= 9000000000000.0) tmp = Float64(z * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -x * y; tmp = 0.0; if (y <= -42000000.0) tmp = t_1; elseif (y <= 9000000000000.0) tmp = z * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-x) * y), $MachinePrecision]}, If[LessEqual[y, -42000000.0], t$95$1, If[LessEqual[y, 9000000000000.0], N[(z * x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-x\right) \cdot y\\
\mathbf{if}\;y \leq -42000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 9000000000000:\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -4.2e7 or 9e12 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6483.4
Applied rewrites83.4%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6451.2
Applied rewrites51.2%
if -4.2e7 < y < 9e12Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6462.1
Applied rewrites62.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6436.0
Applied rewrites36.0%
(FPCore (x y z t) :precision binary64 (if (<= z -1000000.0) (* z x) (if (<= z -3.7e-159) (* y t) (if (<= z 6e-15) x (* z x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1000000.0) {
tmp = z * x;
} else if (z <= -3.7e-159) {
tmp = y * t;
} else if (z <= 6e-15) {
tmp = x;
} else {
tmp = z * 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 (z <= (-1000000.0d0)) then
tmp = z * x
else if (z <= (-3.7d-159)) then
tmp = y * t
else if (z <= 6d-15) then
tmp = x
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1000000.0) {
tmp = z * x;
} else if (z <= -3.7e-159) {
tmp = y * t;
} else if (z <= 6e-15) {
tmp = x;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1000000.0: tmp = z * x elif z <= -3.7e-159: tmp = y * t elif z <= 6e-15: tmp = x else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1000000.0) tmp = Float64(z * x); elseif (z <= -3.7e-159) tmp = Float64(y * t); elseif (z <= 6e-15) tmp = x; else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1000000.0) tmp = z * x; elseif (z <= -3.7e-159) tmp = y * t; elseif (z <= 6e-15) tmp = x; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1000000.0], N[(z * x), $MachinePrecision], If[LessEqual[z, -3.7e-159], N[(y * t), $MachinePrecision], If[LessEqual[z, 6e-15], x, N[(z * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1000000:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq -3.7 \cdot 10^{-159}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-15}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -1e6 or 6e-15 < z Initial program 99.9%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6473.4
Applied rewrites73.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6441.2
Applied rewrites41.2%
if -1e6 < z < -3.6999999999999999e-159Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6451.5
Applied rewrites51.5%
Taylor expanded in y around inf
Applied rewrites42.5%
if -3.6999999999999999e-159 < z < 6e-15Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6491.7
Applied rewrites91.7%
Taylor expanded in y around 0
Applied rewrites41.5%
(FPCore (x y z t) :precision binary64 (if (<= z -1.0) (* z x) (if (<= z 6e-15) x (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.0) {
tmp = z * x;
} else if (z <= 6e-15) {
tmp = x;
} else {
tmp = z * 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 (z <= (-1.0d0)) then
tmp = z * x
else if (z <= 6d-15) then
tmp = x
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.0) {
tmp = z * x;
} else if (z <= 6e-15) {
tmp = x;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.0: tmp = z * x elif z <= 6e-15: tmp = x else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.0) tmp = Float64(z * x); elseif (z <= 6e-15) tmp = x; else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.0) tmp = z * x; elseif (z <= 6e-15) tmp = x; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.0], N[(z * x), $MachinePrecision], If[LessEqual[z, 6e-15], x, N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-15}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -1 or 6e-15 < z Initial program 99.9%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6473.4
Applied rewrites73.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6441.2
Applied rewrites41.2%
if -1 < z < 6e-15Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6491.5
Applied rewrites91.5%
Taylor expanded in y around 0
Applied rewrites35.2%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return 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
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6460.5
Applied rewrites60.5%
Taylor expanded in y around 0
Applied rewrites17.6%
herbie shell --seed 2025064
(FPCore (x y z t)
:name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
:precision binary64
:alt
(! :herbie-platform default (+ x (+ (* t (- y z)) (* (- x) (- y z)))))
(+ x (* (- y z) (- t x))))