
(FPCore (x y z t) :precision binary64 (+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
double code(double x, double y, double z, double t) {
return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z));
}
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) + ((2.0d0 + ((z * 2.0d0) * (1.0d0 - t))) / (t * z))
end function
public static double code(double x, double y, double z, double t) {
return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z));
}
def code(x, y, z, t): return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z))
function code(x, y, z, t) return Float64(Float64(x / y) + Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z))) end
function tmp = code(x, y, z, t) tmp = (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z)); end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
double code(double x, double y, double z, double t) {
return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z));
}
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) + ((2.0d0 + ((z * 2.0d0) * (1.0d0 - t))) / (t * z))
end function
public static double code(double x, double y, double z, double t) {
return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z));
}
def code(x, y, z, t): return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z))
function code(x, y, z, t) return Float64(Float64(x / y) + Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z))) end
function tmp = code(x, y, z, t) tmp = (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z)); end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= (+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))) INFINITY) (+ (/ x y) (/ (fma z (fma -2.0 t 2.0) 2.0) (* t z))) (/ (fma -2.0 y x) y)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z))) <= ((double) INFINITY)) {
tmp = (x / y) + (fma(z, fma(-2.0, t, 2.0), 2.0) / (t * z));
} else {
tmp = fma(-2.0, y, x) / y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x / y) + Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z))) <= Inf) tmp = Float64(Float64(x / y) + Float64(fma(z, fma(-2.0, t, 2.0), 2.0) / Float64(t * z))); else tmp = Float64(fma(-2.0, y, x) / y); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x / y), $MachinePrecision] + N[(N[(z * N[(-2.0 * t + 2.0), $MachinePrecision] + 2.0), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * y + x), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \leq \infty:\\
\;\;\;\;\frac{x}{y} + \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(-2, t, 2\right), 2\right)}{t \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, y, x\right)}{y}\\
\end{array}
\end{array}
if (+.f64 (/.f64 x y) (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z))) < +inf.0Initial program 99.9%
Taylor expanded in t around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-fma.f6499.9
Applied rewrites99.9%
if +inf.0 < (+.f64 (/.f64 x y) (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z))) Initial program 0.0%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f6497.1
Applied rewrites97.1%
Taylor expanded in t around inf
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (- (/ 2.0 z) -2.0) t))
(t_2 (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
(if (<= t_2 -5e+20)
t_1
(if (<= t_2 5e+134)
(+ (/ x y) -2.0)
(if (<= t_2 INFINITY) t_1 (/ (fma -2.0 y x) y))))))
double code(double x, double y, double z, double t) {
double t_1 = ((2.0 / z) - -2.0) / t;
double t_2 = (2.0 + ((z * 2.0) * (1.0 - t))) / (t * z);
double tmp;
if (t_2 <= -5e+20) {
tmp = t_1;
} else if (t_2 <= 5e+134) {
tmp = (x / y) + -2.0;
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(-2.0, y, x) / y;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(Float64(2.0 / z) - -2.0) / t) t_2 = Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z)) tmp = 0.0 if (t_2 <= -5e+20) tmp = t_1; elseif (t_2 <= 5e+134) tmp = Float64(Float64(x / y) + -2.0); elseif (t_2 <= Inf) tmp = t_1; else tmp = Float64(fma(-2.0, y, x) / y); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(2.0 / z), $MachinePrecision] - -2.0), $MachinePrecision] / t), $MachinePrecision]}, Block[{t$95$2 = N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+20], t$95$1, If[LessEqual[t$95$2, 5e+134], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision], If[LessEqual[t$95$2, Infinity], t$95$1, N[(N[(-2.0 * y + x), $MachinePrecision] / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{2}{z} - -2}{t}\\
t_2 := \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+134}:\\
\;\;\;\;\frac{x}{y} + -2\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, y, x\right)}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < -5e20 or 4.99999999999999981e134 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < +inf.0Initial program 99.1%
Taylor expanded in t around 0
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6473.0
Applied rewrites73.0%
if -5e20 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < 4.99999999999999981e134Initial program 99.9%
Taylor expanded in t around inf
Applied rewrites84.1%
if +inf.0 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) Initial program 0.0%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f64100.0
Applied rewrites100.0%
Taylor expanded in t around inf
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (fma z 2.0 2.0) (* t z)))
(t_2 (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
(if (<= t_2 -5e+20)
t_1
(if (<= t_2 5e+134)
(+ (/ x y) -2.0)
(if (<= t_2 INFINITY) t_1 (/ (fma -2.0 y x) y))))))
double code(double x, double y, double z, double t) {
double t_1 = fma(z, 2.0, 2.0) / (t * z);
double t_2 = (2.0 + ((z * 2.0) * (1.0 - t))) / (t * z);
double tmp;
if (t_2 <= -5e+20) {
tmp = t_1;
} else if (t_2 <= 5e+134) {
tmp = (x / y) + -2.0;
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(-2.0, y, x) / y;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(z, 2.0, 2.0) / Float64(t * z)) t_2 = Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z)) tmp = 0.0 if (t_2 <= -5e+20) tmp = t_1; elseif (t_2 <= 5e+134) tmp = Float64(Float64(x / y) + -2.0); elseif (t_2 <= Inf) tmp = t_1; else tmp = Float64(fma(-2.0, y, x) / y); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * 2.0 + 2.0), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+20], t$95$1, If[LessEqual[t$95$2, 5e+134], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision], If[LessEqual[t$95$2, Infinity], t$95$1, N[(N[(-2.0 * y + x), $MachinePrecision] / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\mathsf{fma}\left(z, 2, 2\right)}{t \cdot z}\\
t_2 := \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+134}:\\
\;\;\;\;\frac{x}{y} + -2\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, y, x\right)}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < -5e20 or 4.99999999999999981e134 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < +inf.0Initial program 99.1%
Taylor expanded in t around 0
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6473.0
Applied rewrites73.0%
Taylor expanded in z around inf
Applied rewrites26.4%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6473.0
Applied rewrites73.0%
if -5e20 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < 4.99999999999999981e134Initial program 99.9%
Taylor expanded in t around inf
Applied rewrites84.1%
if +inf.0 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) Initial program 0.0%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f64100.0
Applied rewrites100.0%
Taylor expanded in t around inf
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ 2.0 (* t z)))
(t_2 (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
(if (<= t_2 -2e+254)
t_1
(if (<= t_2 5e+168)
(+ (/ x y) -2.0)
(if (<= t_2 INFINITY) t_1 (/ (fma -2.0 y x) y))))))
double code(double x, double y, double z, double t) {
double t_1 = 2.0 / (t * z);
double t_2 = (2.0 + ((z * 2.0) * (1.0 - t))) / (t * z);
double tmp;
if (t_2 <= -2e+254) {
tmp = t_1;
} else if (t_2 <= 5e+168) {
tmp = (x / y) + -2.0;
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(-2.0, y, x) / y;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(2.0 / Float64(t * z)) t_2 = Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z)) tmp = 0.0 if (t_2 <= -2e+254) tmp = t_1; elseif (t_2 <= 5e+168) tmp = Float64(Float64(x / y) + -2.0); elseif (t_2 <= Inf) tmp = t_1; else tmp = Float64(fma(-2.0, y, x) / y); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+254], t$95$1, If[LessEqual[t$95$2, 5e+168], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision], If[LessEqual[t$95$2, Infinity], t$95$1, N[(N[(-2.0 * y + x), $MachinePrecision] / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{2}{t \cdot z}\\
t_2 := \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+254}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+168}:\\
\;\;\;\;\frac{x}{y} + -2\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, y, x\right)}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < -1.9999999999999999e254 or 4.99999999999999967e168 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < +inf.0Initial program 98.5%
Taylor expanded in z around 0
lower-/.f64N/A
lift-*.f6466.8
Applied rewrites66.8%
if -1.9999999999999999e254 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < 4.99999999999999967e168Initial program 99.8%
Taylor expanded in t around inf
Applied rewrites67.2%
if +inf.0 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) Initial program 0.0%
Taylor expanded in y around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f64100.0
Applied rewrites100.0%
Taylor expanded in t around inf
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
(if (or (<= t_1 -2e+254) (not (or (<= t_1 5e+168) (not (<= t_1 INFINITY)))))
(/ 2.0 (* t z))
(+ (/ x y) -2.0))))
double code(double x, double y, double z, double t) {
double t_1 = (2.0 + ((z * 2.0) * (1.0 - t))) / (t * z);
double tmp;
if ((t_1 <= -2e+254) || !((t_1 <= 5e+168) || !(t_1 <= ((double) INFINITY)))) {
tmp = 2.0 / (t * z);
} else {
tmp = (x / y) + -2.0;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (2.0 + ((z * 2.0) * (1.0 - t))) / (t * z);
double tmp;
if ((t_1 <= -2e+254) || !((t_1 <= 5e+168) || !(t_1 <= Double.POSITIVE_INFINITY))) {
tmp = 2.0 / (t * z);
} else {
tmp = (x / y) + -2.0;
}
return tmp;
}
def code(x, y, z, t): t_1 = (2.0 + ((z * 2.0) * (1.0 - t))) / (t * z) tmp = 0 if (t_1 <= -2e+254) or not ((t_1 <= 5e+168) or not (t_1 <= math.inf)): tmp = 2.0 / (t * z) else: tmp = (x / y) + -2.0 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z)) tmp = 0.0 if ((t_1 <= -2e+254) || !((t_1 <= 5e+168) || !(t_1 <= Inf))) tmp = Float64(2.0 / Float64(t * z)); else tmp = Float64(Float64(x / y) + -2.0); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (2.0 + ((z * 2.0) * (1.0 - t))) / (t * z); tmp = 0.0; if ((t_1 <= -2e+254) || ~(((t_1 <= 5e+168) || ~((t_1 <= Inf))))) tmp = 2.0 / (t * z); else tmp = (x / y) + -2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+254], N[Not[Or[LessEqual[t$95$1, 5e+168], N[Not[LessEqual[t$95$1, Infinity]], $MachinePrecision]]], $MachinePrecision]], N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+254} \lor \neg \left(t\_1 \leq 5 \cdot 10^{+168} \lor \neg \left(t\_1 \leq \infty\right)\right):\\
\;\;\;\;\frac{2}{t \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + -2\\
\end{array}
\end{array}
if (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < -1.9999999999999999e254 or 4.99999999999999967e168 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < +inf.0Initial program 98.5%
Taylor expanded in z around 0
lower-/.f64N/A
lift-*.f6466.8
Applied rewrites66.8%
if -1.9999999999999999e254 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < 4.99999999999999967e168 or +inf.0 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) Initial program 81.6%
Taylor expanded in t around inf
Applied rewrites73.2%
Final simplification71.5%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -5e+14) (not (<= (/ x y) 2.0))) (+ (/ x y) (/ (fma z 2.0 2.0) (* t z))) (fma (/ (- 1.0 t) t) 2.0 (/ 2.0 (* t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -5e+14) || !((x / y) <= 2.0)) {
tmp = (x / y) + (fma(z, 2.0, 2.0) / (t * z));
} else {
tmp = fma(((1.0 - t) / t), 2.0, (2.0 / (t * z)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -5e+14) || !(Float64(x / y) <= 2.0)) tmp = Float64(Float64(x / y) + Float64(fma(z, 2.0, 2.0) / Float64(t * z))); else tmp = fma(Float64(Float64(1.0 - t) / t), 2.0, Float64(2.0 / Float64(t * z))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -5e+14], N[Not[LessEqual[N[(x / y), $MachinePrecision], 2.0]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(N[(z * 2.0 + 2.0), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - t), $MachinePrecision] / t), $MachinePrecision] * 2.0 + N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{+14} \lor \neg \left(\frac{x}{y} \leq 2\right):\\
\;\;\;\;\frac{x}{y} + \frac{\mathsf{fma}\left(z, 2, 2\right)}{t \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1 - t}{t}, 2, \frac{2}{t \cdot z}\right)\\
\end{array}
\end{array}
if (/.f64 x y) < -5e14 or 2 < (/.f64 x y) Initial program 85.3%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6499.1
Applied rewrites99.1%
if -5e14 < (/.f64 x y) < 2Initial program 87.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f6499.2
Applied rewrites99.2%
Final simplification99.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ 2.0 (* t z))))
(if (or (<= (/ x y) -5e+14) (not (<= (/ x y) 2.0)))
(+ (/ x y) t_1)
(fma (/ (- 1.0 t) t) 2.0 t_1))))
double code(double x, double y, double z, double t) {
double t_1 = 2.0 / (t * z);
double tmp;
if (((x / y) <= -5e+14) || !((x / y) <= 2.0)) {
tmp = (x / y) + t_1;
} else {
tmp = fma(((1.0 - t) / t), 2.0, t_1);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(2.0 / Float64(t * z)) tmp = 0.0 if ((Float64(x / y) <= -5e+14) || !(Float64(x / y) <= 2.0)) tmp = Float64(Float64(x / y) + t_1); else tmp = fma(Float64(Float64(1.0 - t) / t), 2.0, t_1); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[N[(x / y), $MachinePrecision], -5e+14], N[Not[LessEqual[N[(x / y), $MachinePrecision], 2.0]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(N[(1.0 - t), $MachinePrecision] / t), $MachinePrecision] * 2.0 + t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{2}{t \cdot z}\\
\mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{+14} \lor \neg \left(\frac{x}{y} \leq 2\right):\\
\;\;\;\;\frac{x}{y} + t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1 - t}{t}, 2, t\_1\right)\\
\end{array}
\end{array}
if (/.f64 x y) < -5e14 or 2 < (/.f64 x y) Initial program 85.3%
Taylor expanded in z around 0
Applied rewrites90.9%
if -5e14 < (/.f64 x y) < 2Initial program 87.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f6499.2
Applied rewrites99.2%
Final simplification95.0%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -5e+14) (not (<= (/ x y) 4e-28))) (+ (/ x y) (/ 2.0 (* t z))) (/ (fma (* (- 1.0 t) z) 2.0 2.0) (* t z))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -5e+14) || !((x / y) <= 4e-28)) {
tmp = (x / y) + (2.0 / (t * z));
} else {
tmp = fma(((1.0 - t) * z), 2.0, 2.0) / (t * z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -5e+14) || !(Float64(x / y) <= 4e-28)) tmp = Float64(Float64(x / y) + Float64(2.0 / Float64(t * z))); else tmp = Float64(fma(Float64(Float64(1.0 - t) * z), 2.0, 2.0) / Float64(t * z)); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -5e+14], N[Not[LessEqual[N[(x / y), $MachinePrecision], 4e-28]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 - t), $MachinePrecision] * z), $MachinePrecision] * 2.0 + 2.0), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{+14} \lor \neg \left(\frac{x}{y} \leq 4 \cdot 10^{-28}\right):\\
\;\;\;\;\frac{x}{y} + \frac{2}{t \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(1 - t\right) \cdot z, 2, 2\right)}{t \cdot z}\\
\end{array}
\end{array}
if (/.f64 x y) < -5e14 or 3.99999999999999988e-28 < (/.f64 x y) Initial program 84.8%
Taylor expanded in z around 0
Applied rewrites90.3%
if -5e14 < (/.f64 x y) < 3.99999999999999988e-28Initial program 87.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-add-revN/A
associate-*r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites87.7%
Final simplification89.1%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -1e-23) (not (<= (/ x y) 2e+28))) (+ (/ x y) -2.0) (/ (fma (* (- 1.0 t) z) 2.0 2.0) (* t z))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -1e-23) || !((x / y) <= 2e+28)) {
tmp = (x / y) + -2.0;
} else {
tmp = fma(((1.0 - t) * z), 2.0, 2.0) / (t * z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -1e-23) || !(Float64(x / y) <= 2e+28)) tmp = Float64(Float64(x / y) + -2.0); else tmp = Float64(fma(Float64(Float64(1.0 - t) * z), 2.0, 2.0) / Float64(t * z)); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -1e-23], N[Not[LessEqual[N[(x / y), $MachinePrecision], 2e+28]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision], N[(N[(N[(N[(1.0 - t), $MachinePrecision] * z), $MachinePrecision] * 2.0 + 2.0), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -1 \cdot 10^{-23} \lor \neg \left(\frac{x}{y} \leq 2 \cdot 10^{+28}\right):\\
\;\;\;\;\frac{x}{y} + -2\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(1 - t\right) \cdot z, 2, 2\right)}{t \cdot z}\\
\end{array}
\end{array}
if (/.f64 x y) < -9.9999999999999996e-24 or 1.99999999999999992e28 < (/.f64 x y) Initial program 84.2%
Taylor expanded in t around inf
Applied rewrites77.9%
if -9.9999999999999996e-24 < (/.f64 x y) < 1.99999999999999992e28Initial program 88.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f6498.5
Applied rewrites98.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-add-revN/A
associate-*r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites87.4%
Final simplification82.7%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -8500000000000.0) (not (<= (/ x y) 5.8e+14))) (/ x y) -2.0))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -8500000000000.0) || !((x / y) <= 5.8e+14)) {
tmp = x / y;
} else {
tmp = -2.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((x / y) <= (-8500000000000.0d0)) .or. (.not. ((x / y) <= 5.8d+14))) then
tmp = x / y
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -8500000000000.0) || !((x / y) <= 5.8e+14)) {
tmp = x / y;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -8500000000000.0) or not ((x / y) <= 5.8e+14): tmp = x / y else: tmp = -2.0 return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -8500000000000.0) || !(Float64(x / y) <= 5.8e+14)) tmp = Float64(x / y); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -8500000000000.0) || ~(((x / y) <= 5.8e+14))) tmp = x / y; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -8500000000000.0], N[Not[LessEqual[N[(x / y), $MachinePrecision], 5.8e+14]], $MachinePrecision]], N[(x / y), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -8500000000000 \lor \neg \left(\frac{x}{y} \leq 5.8 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if (/.f64 x y) < -8.5e12 or 5.8e14 < (/.f64 x y) Initial program 85.1%
Taylor expanded in x around inf
lift-/.f6476.5
Applied rewrites76.5%
if -8.5e12 < (/.f64 x y) < 5.8e14Initial program 87.3%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f6499.2
Applied rewrites99.2%
Taylor expanded in t around inf
Applied rewrites38.1%
Final simplification57.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -0.44) (not (<= z 4.8e-24))) (fma (/ (- 1.0 t) t) 2.0 (/ x y)) (+ (/ x y) (/ 2.0 (* t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -0.44) || !(z <= 4.8e-24)) {
tmp = fma(((1.0 - t) / t), 2.0, (x / y));
} else {
tmp = (x / y) + (2.0 / (t * z));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -0.44) || !(z <= 4.8e-24)) tmp = fma(Float64(Float64(1.0 - t) / t), 2.0, Float64(x / y)); else tmp = Float64(Float64(x / y) + Float64(2.0 / Float64(t * z))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -0.44], N[Not[LessEqual[z, 4.8e-24]], $MachinePrecision]], N[(N[(N[(1.0 - t), $MachinePrecision] / t), $MachinePrecision] * 2.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.44 \lor \neg \left(z \leq 4.8 \cdot 10^{-24}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{1 - t}{t}, 2, \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + \frac{2}{t \cdot z}\\
\end{array}
\end{array}
if z < -0.440000000000000002 or 4.7999999999999996e-24 < z Initial program 74.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift-/.f6499.4
Applied rewrites99.4%
if -0.440000000000000002 < z < 4.7999999999999996e-24Initial program 99.0%
Taylor expanded in z around 0
Applied rewrites87.2%
Final simplification93.6%
(FPCore (x y z t) :precision binary64 (if (or (<= z -0.65) (not (<= z 360000.0))) (/ (fma (- (/ x y) 2.0) t 2.0) t) (+ (/ x y) (/ 2.0 (* t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -0.65) || !(z <= 360000.0)) {
tmp = fma(((x / y) - 2.0), t, 2.0) / t;
} else {
tmp = (x / y) + (2.0 / (t * z));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -0.65) || !(z <= 360000.0)) tmp = Float64(fma(Float64(Float64(x / y) - 2.0), t, 2.0) / t); else tmp = Float64(Float64(x / y) + Float64(2.0 / Float64(t * z))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -0.65], N[Not[LessEqual[z, 360000.0]], $MachinePrecision]], N[(N[(N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision] * t + 2.0), $MachinePrecision] / t), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.65 \lor \neg \left(z \leq 360000\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y} - 2, t, 2\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + \frac{2}{t \cdot z}\\
\end{array}
\end{array}
if z < -0.650000000000000022 or 3.6e5 < z Initial program 74.1%
Taylor expanded in t around 0
lower-/.f64N/A
Applied rewrites92.2%
Taylor expanded in z around inf
Applied rewrites92.0%
if -0.650000000000000022 < z < 3.6e5Initial program 99.1%
Taylor expanded in z around 0
Applied rewrites86.1%
Final simplification89.1%
(FPCore (x y z t) :precision binary64 (if (or (<= t -3.3e-192) (not (<= t 2.35e-150))) (+ (/ x y) -2.0) (/ 2.0 t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.3e-192) || !(t <= 2.35e-150)) {
tmp = (x / y) + -2.0;
} else {
tmp = 2.0 / t;
}
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 <= (-3.3d-192)) .or. (.not. (t <= 2.35d-150))) then
tmp = (x / y) + (-2.0d0)
else
tmp = 2.0d0 / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.3e-192) || !(t <= 2.35e-150)) {
tmp = (x / y) + -2.0;
} else {
tmp = 2.0 / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -3.3e-192) or not (t <= 2.35e-150): tmp = (x / y) + -2.0 else: tmp = 2.0 / t return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -3.3e-192) || !(t <= 2.35e-150)) tmp = Float64(Float64(x / y) + -2.0); else tmp = Float64(2.0 / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -3.3e-192) || ~((t <= 2.35e-150))) tmp = (x / y) + -2.0; else tmp = 2.0 / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -3.3e-192], N[Not[LessEqual[t, 2.35e-150]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision], N[(2.0 / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.3 \cdot 10^{-192} \lor \neg \left(t \leq 2.35 \cdot 10^{-150}\right):\\
\;\;\;\;\frac{x}{y} + -2\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{t}\\
\end{array}
\end{array}
if t < -3.29999999999999989e-192 or 2.3499999999999999e-150 < t Initial program 82.9%
Taylor expanded in t around inf
Applied rewrites67.8%
if -3.29999999999999989e-192 < t < 2.3499999999999999e-150Initial program 98.1%
Taylor expanded in t around 0
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6482.5
Applied rewrites82.5%
Taylor expanded in z around inf
Applied rewrites44.9%
Final simplification62.8%
(FPCore (x y z t) :precision binary64 -2.0)
double code(double x, double y, double z, double t) {
return -2.0;
}
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 = -2.0d0
end function
public static double code(double x, double y, double z, double t) {
return -2.0;
}
def code(x, y, z, t): return -2.0
function code(x, y, z, t) return -2.0 end
function tmp = code(x, y, z, t) tmp = -2.0; end
code[x_, y_, z_, t_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 86.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f6462.2
Applied rewrites62.2%
Taylor expanded in t around inf
Applied rewrites20.4%
Final simplification20.4%
herbie shell --seed 2025085
(FPCore (x y z t)
:name "Data.HashTable.ST.Basic:computeOverhead from hashtables-1.2.0.2"
:precision binary64
:alt
(! :herbie-platform default (- (/ (+ (/ 2 z) 2) t) (- 2 (/ x y))))
(+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))