
(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 12 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 (- y z) (- t x) x))
double code(double x, double y, double z, double t) {
return fma((y - z), (t - x), x);
}
function code(x, y, z, t) return fma(Float64(y - z), Float64(t - x), x) end
code[x_, y_, z_, t_] := N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - z, t - x, x\right)
\end{array}
Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift--.f64100.0
Applied rewrites100.0%
(FPCore (x y z t) :precision binary64 (if (<= z -4.1e+45) (* (- x t) z) (if (<= z 1.6e+26) (fma (- t x) y x) (fma (- t) z (* z x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.1e+45) {
tmp = (x - t) * z;
} else if (z <= 1.6e+26) {
tmp = fma((t - x), y, x);
} else {
tmp = fma(-t, z, (z * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -4.1e+45) tmp = Float64(Float64(x - t) * z); elseif (z <= 1.6e+26) tmp = fma(Float64(t - x), y, x); else tmp = fma(Float64(-t), z, Float64(z * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -4.1e+45], N[(N[(x - t), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 1.6e+26], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision], N[((-t) * z + N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.1 \cdot 10^{+45}:\\
\;\;\;\;\left(x - t\right) \cdot z\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-t, z, z \cdot x\right)\\
\end{array}
\end{array}
if z < -4.10000000000000012e45Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6443.6
Applied rewrites43.6%
if -4.10000000000000012e45 < z < 1.60000000000000014e26Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6461.1
Applied rewrites61.1%
if 1.60000000000000014e26 < z Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6443.6
Applied rewrites43.6%
Taylor expanded in x around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- x t) z))) (if (<= z -4.1e+45) t_1 (if (<= z 1.6e+26) (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 <= -4.1e+45) {
tmp = t_1;
} else if (z <= 1.6e+26) {
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 <= -4.1e+45) tmp = t_1; elseif (z <= 1.6e+26) 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, -4.1e+45], t$95$1, If[LessEqual[z, 1.6e+26], 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 -4.1 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.10000000000000012e45 or 1.60000000000000014e26 < z Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6443.6
Applied rewrites43.6%
if -4.10000000000000012e45 < z < 1.60000000000000014e26Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6461.1
Applied rewrites61.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- x t) z)))
(if (<= z -4.1e+45)
t_1
(if (<= z -7.3e-230) (fma t y x) (if (<= z 3.8e+23) (* (- t x) y) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = (x - t) * z;
double tmp;
if (z <= -4.1e+45) {
tmp = t_1;
} else if (z <= -7.3e-230) {
tmp = fma(t, y, x);
} else if (z <= 3.8e+23) {
tmp = (t - x) * y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x - t) * z) tmp = 0.0 if (z <= -4.1e+45) tmp = t_1; elseif (z <= -7.3e-230) tmp = fma(t, y, x); elseif (z <= 3.8e+23) tmp = Float64(Float64(t - x) * y); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x - t), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -4.1e+45], t$95$1, If[LessEqual[z, -7.3e-230], N[(t * y + x), $MachinePrecision], If[LessEqual[z, 3.8e+23], N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x - t\right) \cdot z\\
\mathbf{if}\;z \leq -4.1 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -7.3 \cdot 10^{-230}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+23}:\\
\;\;\;\;\left(t - x\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.10000000000000012e45 or 3.79999999999999975e23 < z Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6443.6
Applied rewrites43.6%
if -4.10000000000000012e45 < z < -7.3000000000000001e-230Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6461.1
Applied rewrites61.1%
Taylor expanded in x around 0
Applied rewrites42.0%
if -7.3000000000000001e-230 < z < 3.79999999999999975e23Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6445.3
Applied rewrites45.3%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- x t) z))) (if (<= z -4.1e+45) t_1 (if (<= z 700000000000.0) (fma t y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x - t) * z;
double tmp;
if (z <= -4.1e+45) {
tmp = t_1;
} else if (z <= 700000000000.0) {
tmp = fma(t, 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 <= -4.1e+45) tmp = t_1; elseif (z <= 700000000000.0) tmp = fma(t, 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, -4.1e+45], t$95$1, If[LessEqual[z, 700000000000.0], N[(t * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x - t\right) \cdot z\\
\mathbf{if}\;z \leq -4.1 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 700000000000:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.10000000000000012e45 or 7e11 < z Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6443.6
Applied rewrites43.6%
if -4.10000000000000012e45 < z < 7e11Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6461.1
Applied rewrites61.1%
Taylor expanded in x around 0
Applied rewrites42.0%
(FPCore (x y z t) :precision binary64 (if (<= z -5.2e+45) (* z x) (if (<= z 2.25e+26) (fma t y x) (- (* t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.2e+45) {
tmp = z * x;
} else if (z <= 2.25e+26) {
tmp = fma(t, y, x);
} else {
tmp = -(t * z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -5.2e+45) tmp = Float64(z * x); elseif (z <= 2.25e+26) tmp = fma(t, y, x); else tmp = Float64(-Float64(t * z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.2e+45], N[(z * x), $MachinePrecision], If[LessEqual[z, 2.25e+26], N[(t * y + x), $MachinePrecision], (-N[(t * z), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+45}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq 2.25 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;-t \cdot z\\
\end{array}
\end{array}
if z < -5.20000000000000014e45Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6443.6
Applied rewrites43.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6421.7
Applied rewrites21.7%
if -5.20000000000000014e45 < z < 2.24999999999999989e26Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6461.1
Applied rewrites61.1%
Taylor expanded in x around 0
Applied rewrites42.0%
if 2.24999999999999989e26 < z Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f6426.0
Applied rewrites26.0%
(FPCore (x y z t) :precision binary64 (if (<= t -5.8e+81) (- (* t z)) (if (<= t 7.2e+109) (fma z x x) (* t y))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -5.8e+81) {
tmp = -(t * z);
} else if (t <= 7.2e+109) {
tmp = fma(z, x, x);
} else {
tmp = t * y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (t <= -5.8e+81) tmp = Float64(-Float64(t * z)); elseif (t <= 7.2e+109) tmp = fma(z, x, x); else tmp = Float64(t * y); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[t, -5.8e+81], (-N[(t * z), $MachinePrecision]), If[LessEqual[t, 7.2e+109], N[(z * x + x), $MachinePrecision], N[(t * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.8 \cdot 10^{+81}:\\
\;\;\;\;-t \cdot z\\
\mathbf{elif}\;t \leq 7.2 \cdot 10^{+109}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot y\\
\end{array}
\end{array}
if t < -5.7999999999999999e81Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f6426.0
Applied rewrites26.0%
if -5.7999999999999999e81 < t < 7.2e109Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
lower-+.f6437.4
Applied rewrites37.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6437.4
Applied rewrites37.4%
if 7.2e109 < t Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6445.3
Applied rewrites45.3%
Taylor expanded in x around 0
Applied rewrites26.4%
(FPCore (x y z t)
:precision binary64
(if (<= y -5.5e-10)
(* t y)
(if (<= y 5.5e-5)
(- (* t z))
(if (<= y 2.6e+53) (* t y) (if (<= y 1.66e+252) (* (- x) y) (* t y))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.5e-10) {
tmp = t * y;
} else if (y <= 5.5e-5) {
tmp = -(t * z);
} else if (y <= 2.6e+53) {
tmp = t * y;
} else if (y <= 1.66e+252) {
tmp = -x * y;
} 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 (y <= (-5.5d-10)) then
tmp = t * y
else if (y <= 5.5d-5) then
tmp = -(t * z)
else if (y <= 2.6d+53) then
tmp = t * y
else if (y <= 1.66d+252) then
tmp = -x * y
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 (y <= -5.5e-10) {
tmp = t * y;
} else if (y <= 5.5e-5) {
tmp = -(t * z);
} else if (y <= 2.6e+53) {
tmp = t * y;
} else if (y <= 1.66e+252) {
tmp = -x * y;
} else {
tmp = t * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -5.5e-10: tmp = t * y elif y <= 5.5e-5: tmp = -(t * z) elif y <= 2.6e+53: tmp = t * y elif y <= 1.66e+252: tmp = -x * y else: tmp = t * y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -5.5e-10) tmp = Float64(t * y); elseif (y <= 5.5e-5) tmp = Float64(-Float64(t * z)); elseif (y <= 2.6e+53) tmp = Float64(t * y); elseif (y <= 1.66e+252) tmp = Float64(Float64(-x) * y); else tmp = Float64(t * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -5.5e-10) tmp = t * y; elseif (y <= 5.5e-5) tmp = -(t * z); elseif (y <= 2.6e+53) tmp = t * y; elseif (y <= 1.66e+252) tmp = -x * y; else tmp = t * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -5.5e-10], N[(t * y), $MachinePrecision], If[LessEqual[y, 5.5e-5], (-N[(t * z), $MachinePrecision]), If[LessEqual[y, 2.6e+53], N[(t * y), $MachinePrecision], If[LessEqual[y, 1.66e+252], N[((-x) * y), $MachinePrecision], N[(t * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{-10}:\\
\;\;\;\;t \cdot y\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-5}:\\
\;\;\;\;-t \cdot z\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+53}:\\
\;\;\;\;t \cdot y\\
\mathbf{elif}\;y \leq 1.66 \cdot 10^{+252}:\\
\;\;\;\;\left(-x\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t \cdot y\\
\end{array}
\end{array}
if y < -5.4999999999999996e-10 or 5.5000000000000002e-5 < y < 2.59999999999999998e53 or 1.66e252 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6445.3
Applied rewrites45.3%
Taylor expanded in x around 0
Applied rewrites26.4%
if -5.4999999999999996e-10 < y < 5.5000000000000002e-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--.f6459.5
Applied rewrites59.5%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f6426.0
Applied rewrites26.0%
if 2.59999999999999998e53 < y < 1.66e252Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6445.3
Applied rewrites45.3%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6423.3
Applied rewrites23.3%
(FPCore (x y z t) :precision binary64 (if (<= y -5.5e-10) (* t y) (if (<= y 5.5e-5) (- (* t z)) (* t y))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.5e-10) {
tmp = t * y;
} else if (y <= 5.5e-5) {
tmp = -(t * 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 (y <= (-5.5d-10)) then
tmp = t * y
else if (y <= 5.5d-5) then
tmp = -(t * 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 (y <= -5.5e-10) {
tmp = t * y;
} else if (y <= 5.5e-5) {
tmp = -(t * z);
} else {
tmp = t * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -5.5e-10: tmp = t * y elif y <= 5.5e-5: tmp = -(t * z) else: tmp = t * y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -5.5e-10) tmp = Float64(t * y); elseif (y <= 5.5e-5) tmp = Float64(-Float64(t * z)); else tmp = Float64(t * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -5.5e-10) tmp = t * y; elseif (y <= 5.5e-5) tmp = -(t * z); else tmp = t * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -5.5e-10], N[(t * y), $MachinePrecision], If[LessEqual[y, 5.5e-5], (-N[(t * z), $MachinePrecision]), N[(t * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{-10}:\\
\;\;\;\;t \cdot y\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-5}:\\
\;\;\;\;-t \cdot z\\
\mathbf{else}:\\
\;\;\;\;t \cdot y\\
\end{array}
\end{array}
if y < -5.4999999999999996e-10 or 5.5000000000000002e-5 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6445.3
Applied rewrites45.3%
Taylor expanded in x around 0
Applied rewrites26.4%
if -5.4999999999999996e-10 < y < 5.5000000000000002e-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--.f6459.5
Applied rewrites59.5%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f6426.0
Applied rewrites26.0%
(FPCore (x y z t) :precision binary64 (if (<= z -5.2e+45) (* z x) (if (<= z 1.6e+69) (* t y) (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.2e+45) {
tmp = z * x;
} else if (z <= 1.6e+69) {
tmp = t * y;
} 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 <= (-5.2d+45)) then
tmp = z * x
else if (z <= 1.6d+69) then
tmp = t * y
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 <= -5.2e+45) {
tmp = z * x;
} else if (z <= 1.6e+69) {
tmp = t * y;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5.2e+45: tmp = z * x elif z <= 1.6e+69: tmp = t * y else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5.2e+45) tmp = Float64(z * x); elseif (z <= 1.6e+69) tmp = Float64(t * y); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -5.2e+45) tmp = z * x; elseif (z <= 1.6e+69) tmp = t * y; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.2e+45], N[(z * x), $MachinePrecision], If[LessEqual[z, 1.6e+69], N[(t * y), $MachinePrecision], N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+45}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+69}:\\
\;\;\;\;t \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -5.20000000000000014e45 or 1.59999999999999992e69 < z Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6443.6
Applied rewrites43.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6421.7
Applied rewrites21.7%
if -5.20000000000000014e45 < z < 1.59999999999999992e69Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6445.3
Applied rewrites45.3%
Taylor expanded in x around 0
Applied rewrites26.4%
(FPCore (x y z t) :precision binary64 (if (<= z -3.9e-32) (* z x) (if (<= z 0.00185) (* 1.0 x) (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.9e-32) {
tmp = z * x;
} else if (z <= 0.00185) {
tmp = 1.0 * 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 <= (-3.9d-32)) then
tmp = z * x
else if (z <= 0.00185d0) then
tmp = 1.0d0 * 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 <= -3.9e-32) {
tmp = z * x;
} else if (z <= 0.00185) {
tmp = 1.0 * x;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.9e-32: tmp = z * x elif z <= 0.00185: tmp = 1.0 * x else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.9e-32) tmp = Float64(z * x); elseif (z <= 0.00185) tmp = Float64(1.0 * x); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.9e-32) tmp = z * x; elseif (z <= 0.00185) tmp = 1.0 * x; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.9e-32], N[(z * x), $MachinePrecision], If[LessEqual[z, 0.00185], N[(1.0 * x), $MachinePrecision], N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{-32}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq 0.00185:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -3.9000000000000001e-32 or 0.0018500000000000001 < z Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6443.6
Applied rewrites43.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6421.7
Applied rewrites21.7%
if -3.9000000000000001e-32 < z < 0.0018500000000000001Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
lower-+.f6437.4
Applied rewrites37.4%
Taylor expanded in z around 0
Applied rewrites18.1%
(FPCore (x y z t) :precision binary64 (* z x))
double code(double x, double y, double z, double t) {
return z * 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 = z * x
end function
public static double code(double x, double y, double z, double t) {
return z * x;
}
def code(x, y, z, t): return z * x
function code(x, y, z, t) return Float64(z * x) end
function tmp = code(x, y, z, t) tmp = z * x; end
code[x_, y_, z_, t_] := N[(z * x), $MachinePrecision]
\begin{array}{l}
\\
z \cdot x
\end{array}
Initial 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--.f6459.5
Applied rewrites59.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6443.6
Applied rewrites43.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6421.7
Applied rewrites21.7%
herbie shell --seed 2025131
(FPCore (x y z t)
:name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
:precision binary64
(+ x (* (- y z) (- t x))))