
(FPCore (x y z t) :precision binary64 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))
double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.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 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
def code(x, y, z, t): return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)
function code(x, y, z, t) return Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) end
function tmp = code(x, y, z, t) tmp = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0); end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))
double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.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 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
def code(x, y, z, t): return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)
function code(x, y, z, t) return Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) end
function tmp = code(x, y, z, t) tmp = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0); end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* t z) x))
(t_2 (* (/ (/ z (+ 1.0 x)) t_1) y))
(t_3 (/ (+ x (/ (- (* y z) x) t_1)) (+ x 1.0))))
(if (<= t_3 -500000000.0)
t_2
(if (<= t_3 5e-20)
(/ (- x (/ (- (/ x z) y) t)) (+ x 1.0))
(if (<= t_3 2.0)
(/ (- x (/ x t_1)) (+ x 1.0))
(if (<= t_3 INFINITY) t_2 (/ (+ (/ y t) x) (+ x 1.0))))))))
double code(double x, double y, double z, double t) {
double t_1 = (t * z) - x;
double t_2 = ((z / (1.0 + x)) / t_1) * y;
double t_3 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
double tmp;
if (t_3 <= -500000000.0) {
tmp = t_2;
} else if (t_3 <= 5e-20) {
tmp = (x - (((x / z) - y) / t)) / (x + 1.0);
} else if (t_3 <= 2.0) {
tmp = (x - (x / t_1)) / (x + 1.0);
} else if (t_3 <= ((double) INFINITY)) {
tmp = t_2;
} else {
tmp = ((y / t) + x) / (x + 1.0);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (t * z) - x;
double t_2 = ((z / (1.0 + x)) / t_1) * y;
double t_3 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
double tmp;
if (t_3 <= -500000000.0) {
tmp = t_2;
} else if (t_3 <= 5e-20) {
tmp = (x - (((x / z) - y) / t)) / (x + 1.0);
} else if (t_3 <= 2.0) {
tmp = (x - (x / t_1)) / (x + 1.0);
} else if (t_3 <= Double.POSITIVE_INFINITY) {
tmp = t_2;
} else {
tmp = ((y / t) + x) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): t_1 = (t * z) - x t_2 = ((z / (1.0 + x)) / t_1) * y t_3 = (x + (((y * z) - x) / t_1)) / (x + 1.0) tmp = 0 if t_3 <= -500000000.0: tmp = t_2 elif t_3 <= 5e-20: tmp = (x - (((x / z) - y) / t)) / (x + 1.0) elif t_3 <= 2.0: tmp = (x - (x / t_1)) / (x + 1.0) elif t_3 <= math.inf: tmp = t_2 else: tmp = ((y / t) + x) / (x + 1.0) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(t * z) - x) t_2 = Float64(Float64(Float64(z / Float64(1.0 + x)) / t_1) * y) t_3 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / t_1)) / Float64(x + 1.0)) tmp = 0.0 if (t_3 <= -500000000.0) tmp = t_2; elseif (t_3 <= 5e-20) tmp = Float64(Float64(x - Float64(Float64(Float64(x / z) - y) / t)) / Float64(x + 1.0)); elseif (t_3 <= 2.0) tmp = Float64(Float64(x - Float64(x / t_1)) / Float64(x + 1.0)); elseif (t_3 <= Inf) tmp = t_2; else tmp = Float64(Float64(Float64(y / t) + x) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (t * z) - x; t_2 = ((z / (1.0 + x)) / t_1) * y; t_3 = (x + (((y * z) - x) / t_1)) / (x + 1.0); tmp = 0.0; if (t_3 <= -500000000.0) tmp = t_2; elseif (t_3 <= 5e-20) tmp = (x - (((x / z) - y) / t)) / (x + 1.0); elseif (t_3 <= 2.0) tmp = (x - (x / t_1)) / (x + 1.0); elseif (t_3 <= Inf) tmp = t_2; else tmp = ((y / t) + x) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(z / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -500000000.0], t$95$2, If[LessEqual[t$95$3, 5e-20], N[(N[(x - N[(N[(N[(x / z), $MachinePrecision] - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2.0], N[(N[(x - N[(x / t$95$1), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, Infinity], t$95$2, N[(N[(N[(y / t), $MachinePrecision] + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot z - x\\
t_2 := \frac{\frac{z}{1 + x}}{t\_1} \cdot y\\
t_3 := \frac{x + \frac{y \cdot z - x}{t\_1}}{x + 1}\\
\mathbf{if}\;t\_3 \leq -500000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{-20}:\\
\;\;\;\;\frac{x - \frac{\frac{x}{z} - y}{t}}{x + 1}\\
\mathbf{elif}\;t\_3 \leq 2:\\
\;\;\;\;\frac{x - \frac{x}{t\_1}}{x + 1}\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{t} + x}{x + 1}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < -5e8 or 2 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < +inf.0Initial program 83.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites92.8%
Taylor expanded in y around inf
Applied rewrites93.6%
if -5e8 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 4.9999999999999999e-20Initial program 98.4%
Taylor expanded in t around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-/.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if 4.9999999999999999e-20 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 100.0%
Taylor expanded in y around 0
lower--.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
if +inf.0 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 0.0%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (+ (/ y t) x) (+ x 1.0)))
(t_2 (- (* t z) x))
(t_3 (* (/ (/ z (+ 1.0 x)) t_2) y))
(t_4 (/ (+ x (/ (- (* y z) x) t_2)) (+ x 1.0))))
(if (<= t_4 -500000000.0)
t_3
(if (<= t_4 1e-46)
t_1
(if (<= t_4 2.0)
(/ (- x (/ x t_2)) (+ x 1.0))
(if (<= t_4 INFINITY) t_3 t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = ((y / t) + x) / (x + 1.0);
double t_2 = (t * z) - x;
double t_3 = ((z / (1.0 + x)) / t_2) * y;
double t_4 = (x + (((y * z) - x) / t_2)) / (x + 1.0);
double tmp;
if (t_4 <= -500000000.0) {
tmp = t_3;
} else if (t_4 <= 1e-46) {
tmp = t_1;
} else if (t_4 <= 2.0) {
tmp = (x - (x / t_2)) / (x + 1.0);
} else if (t_4 <= ((double) INFINITY)) {
tmp = t_3;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = ((y / t) + x) / (x + 1.0);
double t_2 = (t * z) - x;
double t_3 = ((z / (1.0 + x)) / t_2) * y;
double t_4 = (x + (((y * z) - x) / t_2)) / (x + 1.0);
double tmp;
if (t_4 <= -500000000.0) {
tmp = t_3;
} else if (t_4 <= 1e-46) {
tmp = t_1;
} else if (t_4 <= 2.0) {
tmp = (x - (x / t_2)) / (x + 1.0);
} else if (t_4 <= Double.POSITIVE_INFINITY) {
tmp = t_3;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = ((y / t) + x) / (x + 1.0) t_2 = (t * z) - x t_3 = ((z / (1.0 + x)) / t_2) * y t_4 = (x + (((y * z) - x) / t_2)) / (x + 1.0) tmp = 0 if t_4 <= -500000000.0: tmp = t_3 elif t_4 <= 1e-46: tmp = t_1 elif t_4 <= 2.0: tmp = (x - (x / t_2)) / (x + 1.0) elif t_4 <= math.inf: tmp = t_3 else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(y / t) + x) / Float64(x + 1.0)) t_2 = Float64(Float64(t * z) - x) t_3 = Float64(Float64(Float64(z / Float64(1.0 + x)) / t_2) * y) t_4 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / t_2)) / Float64(x + 1.0)) tmp = 0.0 if (t_4 <= -500000000.0) tmp = t_3; elseif (t_4 <= 1e-46) tmp = t_1; elseif (t_4 <= 2.0) tmp = Float64(Float64(x - Float64(x / t_2)) / Float64(x + 1.0)); elseif (t_4 <= Inf) tmp = t_3; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = ((y / t) + x) / (x + 1.0); t_2 = (t * z) - x; t_3 = ((z / (1.0 + x)) / t_2) * y; t_4 = (x + (((y * z) - x) / t_2)) / (x + 1.0); tmp = 0.0; if (t_4 <= -500000000.0) tmp = t_3; elseif (t_4 <= 1e-46) tmp = t_1; elseif (t_4 <= 2.0) tmp = (x - (x / t_2)) / (x + 1.0); elseif (t_4 <= Inf) tmp = t_3; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(y / t), $MachinePrecision] + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(z / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$4 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -500000000.0], t$95$3, If[LessEqual[t$95$4, 1e-46], t$95$1, If[LessEqual[t$95$4, 2.0], N[(N[(x - N[(x / t$95$2), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, Infinity], t$95$3, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{y}{t} + x}{x + 1}\\
t_2 := t \cdot z - x\\
t_3 := \frac{\frac{z}{1 + x}}{t\_2} \cdot y\\
t_4 := \frac{x + \frac{y \cdot z - x}{t\_2}}{x + 1}\\
\mathbf{if}\;t\_4 \leq -500000000:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_4 \leq 10^{-46}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_4 \leq 2:\\
\;\;\;\;\frac{x - \frac{x}{t\_2}}{x + 1}\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < -5e8 or 2 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < +inf.0Initial program 83.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites92.8%
Taylor expanded in y around inf
Applied rewrites93.6%
if -5e8 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 1.00000000000000002e-46 or +inf.0 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 85.1%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f6489.4
Applied rewrites89.4%
if 1.00000000000000002e-46 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 100.0%
Taylor expanded in y around 0
lower--.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6498.8
Applied rewrites98.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0))))
(if (<= t_1 -2e-91)
(/ y t)
(if (<= t_1 0.9999999996843258)
(/ x (+ 1.0 x))
(if (<= t_1 4e+64) (fma z (/ (- y) (fma x x x)) 1.0) (/ y t))))))
double code(double x, double y, double z, double t) {
double t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
double tmp;
if (t_1 <= -2e-91) {
tmp = y / t;
} else if (t_1 <= 0.9999999996843258) {
tmp = x / (1.0 + x);
} else if (t_1 <= 4e+64) {
tmp = fma(z, (-y / fma(x, x, x)), 1.0);
} else {
tmp = y / t;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) tmp = 0.0 if (t_1 <= -2e-91) tmp = Float64(y / t); elseif (t_1 <= 0.9999999996843258) tmp = Float64(x / Float64(1.0 + x)); elseif (t_1 <= 4e+64) tmp = fma(z, Float64(Float64(-y) / fma(x, x, x)), 1.0); else tmp = Float64(y / t); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-91], N[(y / t), $MachinePrecision], If[LessEqual[t$95$1, 0.9999999996843258], N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+64], N[(z * N[((-y) / N[(x * x + x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(y / t), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-91}:\\
\;\;\;\;\frac{y}{t}\\
\mathbf{elif}\;t\_1 \leq 0.9999999996843258:\\
\;\;\;\;\frac{x}{1 + x}\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+64}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{-y}{\mathsf{fma}\left(x, x, x\right)}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < -2.00000000000000004e-91 or 4.00000000000000009e64 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 76.6%
Taylor expanded in x around 0
lower-/.f6456.9
Applied rewrites56.9%
if -2.00000000000000004e-91 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 0.99999999968432585Initial program 98.1%
Taylor expanded in t around inf
lower-/.f64N/A
lower-+.f6462.1
Applied rewrites62.1%
if 0.99999999968432585 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 4.00000000000000009e64Initial program 100.0%
Taylor expanded in t around 0
associate-+r+N/A
div-addN/A
*-inversesN/A
mul-1-negN/A
distribute-neg-fracN/A
associate-/r*N/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6497.4
Applied rewrites97.4%
Applied rewrites97.4%
Applied rewrites97.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0))))
(if (<= t_1 -2e-91)
(/ y t)
(if (<= t_1 0.9999999996843258)
(/ x (+ 1.0 x))
(if (<= t_1 4e+64) 1.0 (/ y t))))))
double code(double x, double y, double z, double t) {
double t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
double tmp;
if (t_1 <= -2e-91) {
tmp = y / t;
} else if (t_1 <= 0.9999999996843258) {
tmp = x / (1.0 + x);
} else if (t_1 <= 4e+64) {
tmp = 1.0;
} else {
tmp = y / 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) :: t_1
real(8) :: tmp
t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0d0)
if (t_1 <= (-2d-91)) then
tmp = y / t
else if (t_1 <= 0.9999999996843258d0) then
tmp = x / (1.0d0 + x)
else if (t_1 <= 4d+64) then
tmp = 1.0d0
else
tmp = y / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
double tmp;
if (t_1 <= -2e-91) {
tmp = y / t;
} else if (t_1 <= 0.9999999996843258) {
tmp = x / (1.0 + x);
} else if (t_1 <= 4e+64) {
tmp = 1.0;
} else {
tmp = y / t;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0) tmp = 0 if t_1 <= -2e-91: tmp = y / t elif t_1 <= 0.9999999996843258: tmp = x / (1.0 + x) elif t_1 <= 4e+64: tmp = 1.0 else: tmp = y / t return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) tmp = 0.0 if (t_1 <= -2e-91) tmp = Float64(y / t); elseif (t_1 <= 0.9999999996843258) tmp = Float64(x / Float64(1.0 + x)); elseif (t_1 <= 4e+64) tmp = 1.0; else tmp = Float64(y / t); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0); tmp = 0.0; if (t_1 <= -2e-91) tmp = y / t; elseif (t_1 <= 0.9999999996843258) tmp = x / (1.0 + x); elseif (t_1 <= 4e+64) tmp = 1.0; else tmp = y / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-91], N[(y / t), $MachinePrecision], If[LessEqual[t$95$1, 0.9999999996843258], N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+64], 1.0, N[(y / t), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-91}:\\
\;\;\;\;\frac{y}{t}\\
\mathbf{elif}\;t\_1 \leq 0.9999999996843258:\\
\;\;\;\;\frac{x}{1 + x}\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+64}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < -2.00000000000000004e-91 or 4.00000000000000009e64 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 76.6%
Taylor expanded in x around 0
lower-/.f6456.9
Applied rewrites56.9%
if -2.00000000000000004e-91 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 0.99999999968432585Initial program 98.1%
Taylor expanded in t around inf
lower-/.f64N/A
lower-+.f6462.1
Applied rewrites62.1%
if 0.99999999968432585 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 4.00000000000000009e64Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites96.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0))))
(if (<= t_1 -2e-91)
(/ y t)
(if (<= t_1 2e-42)
(* (fma -1.0 x 1.0) x)
(if (<= t_1 4e+64) 1.0 (/ y t))))))
double code(double x, double y, double z, double t) {
double t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
double tmp;
if (t_1 <= -2e-91) {
tmp = y / t;
} else if (t_1 <= 2e-42) {
tmp = fma(-1.0, x, 1.0) * x;
} else if (t_1 <= 4e+64) {
tmp = 1.0;
} else {
tmp = y / t;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) tmp = 0.0 if (t_1 <= -2e-91) tmp = Float64(y / t); elseif (t_1 <= 2e-42) tmp = Float64(fma(-1.0, x, 1.0) * x); elseif (t_1 <= 4e+64) tmp = 1.0; else tmp = Float64(y / t); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-91], N[(y / t), $MachinePrecision], If[LessEqual[t$95$1, 2e-42], N[(N[(-1.0 * x + 1.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$1, 4e+64], 1.0, N[(y / t), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-91}:\\
\;\;\;\;\frac{y}{t}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-42}:\\
\;\;\;\;\mathsf{fma}\left(-1, x, 1\right) \cdot x\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+64}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < -2.00000000000000004e-91 or 4.00000000000000009e64 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 76.6%
Taylor expanded in x around 0
lower-/.f6456.9
Applied rewrites56.9%
if -2.00000000000000004e-91 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 2.00000000000000008e-42Initial program 97.9%
Taylor expanded in t around inf
lower-/.f64N/A
lower-+.f6465.3
Applied rewrites65.3%
Taylor expanded in x around 0
Applied rewrites65.3%
if 2.00000000000000008e-42 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 4.00000000000000009e64Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites94.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0))))
(if (or (<= t_1 5e-20) (not (<= t_1 4e+64)))
(/ (+ (/ y t) x) 1.0)
(fma z (/ (- y) (fma x x x)) 1.0))))
double code(double x, double y, double z, double t) {
double t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
double tmp;
if ((t_1 <= 5e-20) || !(t_1 <= 4e+64)) {
tmp = ((y / t) + x) / 1.0;
} else {
tmp = fma(z, (-y / fma(x, x, x)), 1.0);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) tmp = 0.0 if ((t_1 <= 5e-20) || !(t_1 <= 4e+64)) tmp = Float64(Float64(Float64(y / t) + x) / 1.0); else tmp = fma(z, Float64(Float64(-y) / fma(x, x, x)), 1.0); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, 5e-20], N[Not[LessEqual[t$95$1, 4e+64]], $MachinePrecision]], N[(N[(N[(y / t), $MachinePrecision] + x), $MachinePrecision] / 1.0), $MachinePrecision], N[(z * N[((-y) / N[(x * x + x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{-20} \lor \neg \left(t\_1 \leq 4 \cdot 10^{+64}\right):\\
\;\;\;\;\frac{\frac{y}{t} + x}{1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{-y}{\mathsf{fma}\left(x, x, x\right)}, 1\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 4.9999999999999999e-20 or 4.00000000000000009e64 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 84.6%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f6478.0
Applied rewrites78.0%
Taylor expanded in x around 0
Applied rewrites73.8%
if 4.9999999999999999e-20 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 4.00000000000000009e64Initial program 100.0%
Taylor expanded in t around 0
associate-+r+N/A
div-addN/A
*-inversesN/A
mul-1-negN/A
distribute-neg-fracN/A
associate-/r*N/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6496.5
Applied rewrites96.5%
Applied rewrites96.5%
Applied rewrites96.5%
Final simplification85.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))) (if (<= t_1 5e+266) t_1 (/ (+ (/ y t) x) (+ x 1.0)))))
double code(double x, double y, double z, double t) {
double t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
double tmp;
if (t_1 <= 5e+266) {
tmp = t_1;
} else {
tmp = ((y / t) + x) / (x + 1.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) :: t_1
real(8) :: tmp
t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0d0)
if (t_1 <= 5d+266) then
tmp = t_1
else
tmp = ((y / t) + x) / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
double tmp;
if (t_1 <= 5e+266) {
tmp = t_1;
} else {
tmp = ((y / t) + x) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0) tmp = 0 if t_1 <= 5e+266: tmp = t_1 else: tmp = ((y / t) + x) / (x + 1.0) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) tmp = 0.0 if (t_1 <= 5e+266) tmp = t_1; else tmp = Float64(Float64(Float64(y / t) + x) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0); tmp = 0.0; if (t_1 <= 5e+266) tmp = t_1; else tmp = ((y / t) + x) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+266], t$95$1, N[(N[(N[(y / t), $MachinePrecision] + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+266}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{t} + x}{x + 1}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 4.9999999999999999e266Initial program 98.3%
if 4.9999999999999999e266 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 26.5%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f6485.5
Applied rewrites85.5%
(FPCore (x y z t) :precision binary64 (if (<= (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)) 2e-42) (* (fma -1.0 x 1.0) x) 1.0))
double code(double x, double y, double z, double t) {
double tmp;
if (((x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)) <= 2e-42) {
tmp = fma(-1.0, x, 1.0) * x;
} else {
tmp = 1.0;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) <= 2e-42) tmp = Float64(fma(-1.0, x, 1.0) * x); else tmp = 1.0; end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], 2e-42], N[(N[(-1.0 * x + 1.0), $MachinePrecision] * x), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \leq 2 \cdot 10^{-42}:\\
\;\;\;\;\mathsf{fma}\left(-1, x, 1\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 2.00000000000000008e-42Initial program 95.5%
Taylor expanded in t around inf
lower-/.f64N/A
lower-+.f6438.3
Applied rewrites38.3%
Taylor expanded in x around 0
Applied rewrites37.4%
if 2.00000000000000008e-42 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 91.2%
Taylor expanded in x around inf
Applied rewrites78.9%
(FPCore (x y z t) :precision binary64 (if (or (<= t -3.2e-17) (not (<= t 2.45e-51))) (/ (+ (/ y t) x) (+ x 1.0)) (fma (/ (/ z (+ 1.0 x)) x) (- y) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.2e-17) || !(t <= 2.45e-51)) {
tmp = ((y / t) + x) / (x + 1.0);
} else {
tmp = fma(((z / (1.0 + x)) / x), -y, 1.0);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((t <= -3.2e-17) || !(t <= 2.45e-51)) tmp = Float64(Float64(Float64(y / t) + x) / Float64(x + 1.0)); else tmp = fma(Float64(Float64(z / Float64(1.0 + x)) / x), Float64(-y), 1.0); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -3.2e-17], N[Not[LessEqual[t, 2.45e-51]], $MachinePrecision]], N[(N[(N[(y / t), $MachinePrecision] + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * (-y) + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.2 \cdot 10^{-17} \lor \neg \left(t \leq 2.45 \cdot 10^{-51}\right):\\
\;\;\;\;\frac{\frac{y}{t} + x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{z}{1 + x}}{x}, -y, 1\right)\\
\end{array}
\end{array}
if t < -3.2000000000000002e-17 or 2.44999999999999987e-51 < t Initial program 90.6%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f6491.5
Applied rewrites91.5%
if -3.2000000000000002e-17 < t < 2.44999999999999987e-51Initial program 95.5%
Taylor expanded in t around 0
associate-+r+N/A
div-addN/A
*-inversesN/A
mul-1-negN/A
distribute-neg-fracN/A
associate-/r*N/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6485.5
Applied rewrites85.5%
Applied rewrites85.5%
Applied rewrites87.0%
Final simplification89.5%
(FPCore (x y z t) :precision binary64 (if (or (<= t -3.2e-17) (not (<= t 2.2e-51))) (/ (+ (/ y t) x) (+ x 1.0)) (fma (/ z (fma x x x)) (- y) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.2e-17) || !(t <= 2.2e-51)) {
tmp = ((y / t) + x) / (x + 1.0);
} else {
tmp = fma((z / fma(x, x, x)), -y, 1.0);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((t <= -3.2e-17) || !(t <= 2.2e-51)) tmp = Float64(Float64(Float64(y / t) + x) / Float64(x + 1.0)); else tmp = fma(Float64(z / fma(x, x, x)), Float64(-y), 1.0); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -3.2e-17], N[Not[LessEqual[t, 2.2e-51]], $MachinePrecision]], N[(N[(N[(y / t), $MachinePrecision] + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(z / N[(x * x + x), $MachinePrecision]), $MachinePrecision] * (-y) + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.2 \cdot 10^{-17} \lor \neg \left(t \leq 2.2 \cdot 10^{-51}\right):\\
\;\;\;\;\frac{\frac{y}{t} + x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{\mathsf{fma}\left(x, x, x\right)}, -y, 1\right)\\
\end{array}
\end{array}
if t < -3.2000000000000002e-17 or 2.2e-51 < t Initial program 90.6%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f6491.5
Applied rewrites91.5%
if -3.2000000000000002e-17 < t < 2.2e-51Initial program 95.5%
Taylor expanded in t around 0
associate-+r+N/A
div-addN/A
*-inversesN/A
mul-1-negN/A
distribute-neg-fracN/A
associate-/r*N/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6485.5
Applied rewrites85.5%
Applied rewrites85.5%
Final simplification88.9%
(FPCore (x y z t) :precision binary64 1.0)
double code(double x, double y, double z, double t) {
return 1.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 = 1.0d0
end function
public static double code(double x, double y, double z, double t) {
return 1.0;
}
def code(x, y, z, t): return 1.0
function code(x, y, z, t) return 1.0 end
function tmp = code(x, y, z, t) tmp = 1.0; end
code[x_, y_, z_, t_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 92.7%
Taylor expanded in x around inf
Applied rewrites53.1%
(FPCore (x y z t) :precision binary64 (/ (+ x (- (/ y (- t (/ x z))) (/ x (- (* t z) x)))) (+ x 1.0)))
double code(double x, double y, double z, double t) {
return (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.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 = (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0);
}
def code(x, y, z, t): return (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0)
function code(x, y, z, t) return Float64(Float64(x + Float64(Float64(y / Float64(t - Float64(x / z))) - Float64(x / Float64(Float64(t * z) - x)))) / Float64(x + 1.0)) end
function tmp = code(x, y, z, t) tmp = (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0); end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(y / N[(t - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1}
\end{array}
herbie shell --seed 2024360
(FPCore (x y z t)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, A"
:precision binary64
:alt
(! :herbie-platform default (/ (+ x (- (/ y (- t (/ x z))) (/ x (- (* t z) x)))) (+ x 1)))
(/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))