
(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 18 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 (/ (- 1.0 t) t) 2.0 (/ 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(((1.0 - t) / t), 2.0, (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 = fma(Float64(Float64(1.0 - t) / t), 2.0, Float64(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[(N[(1.0 - t), $MachinePrecision] / t), $MachinePrecision] * 2.0 + N[(x / y), $MachinePrecision]), $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}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1 - t}{t}, 2, \frac{x}{y}\right)\\
\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.8%
Taylor expanded in t around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-fma.f6499.8
Applied rewrites99.8%
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 z around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift-/.f6496.8
Applied rewrites96.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
(if (or (<= t_1 -5e+176) (not (or (<= t_1 -1.0) (not (<= t_1 INFINITY)))))
(/ (- (/ 2.0 z) -2.0) t)
(+ (/ 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 <= -5e+176) || !((t_1 <= -1.0) || !(t_1 <= ((double) INFINITY)))) {
tmp = ((2.0 / z) - -2.0) / t;
} 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 <= -5e+176) || !((t_1 <= -1.0) || !(t_1 <= Double.POSITIVE_INFINITY))) {
tmp = ((2.0 / z) - -2.0) / t;
} 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 <= -5e+176) or not ((t_1 <= -1.0) or not (t_1 <= math.inf)): tmp = ((2.0 / z) - -2.0) / t 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 <= -5e+176) || !((t_1 <= -1.0) || !(t_1 <= Inf))) tmp = Float64(Float64(Float64(2.0 / z) - -2.0) / t); 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 <= -5e+176) || ~(((t_1 <= -1.0) || ~((t_1 <= Inf))))) tmp = ((2.0 / z) - -2.0) / t; 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, -5e+176], N[Not[Or[LessEqual[t$95$1, -1.0], N[Not[LessEqual[t$95$1, Infinity]], $MachinePrecision]]], $MachinePrecision]], N[(N[(N[(2.0 / z), $MachinePrecision] - -2.0), $MachinePrecision] / t), $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 -5 \cdot 10^{+176} \lor \neg \left(t\_1 \leq -1 \lor \neg \left(t\_1 \leq \infty\right)\right):\\
\;\;\;\;\frac{\frac{2}{z} - -2}{t}\\
\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)) < -5e176 or -1 < (/.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.0%
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-/.f6478.6
Applied rewrites78.6%
if -5e176 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < -1 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 78.9%
Taylor expanded in t around inf
Applied rewrites86.6%
Final simplification82.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
(if (or (<= t_1 -5e+176) (not (or (<= t_1 -1.0) (not (<= t_1 INFINITY)))))
(/ (fma z 2.0 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 <= -5e+176) || !((t_1 <= -1.0) || !(t_1 <= ((double) INFINITY)))) {
tmp = fma(z, 2.0, 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 <= -5e+176) || !((t_1 <= -1.0) || !(t_1 <= Inf))) tmp = Float64(fma(z, 2.0, 2.0) / Float64(t * z)); else tmp = Float64(Float64(x / y) + -2.0); end return 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, -5e+176], N[Not[Or[LessEqual[t$95$1, -1.0], N[Not[LessEqual[t$95$1, Infinity]], $MachinePrecision]]], $MachinePrecision]], N[(N[(z * 2.0 + 2.0), $MachinePrecision] / 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 -5 \cdot 10^{+176} \lor \neg \left(t\_1 \leq -1 \lor \neg \left(t\_1 \leq \infty\right)\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(z, 2, 2\right)}{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)) < -5e176 or -1 < (/.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.0%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/r*N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites65.0%
Taylor expanded in t around 0
associate-*r/N/A
lower-/.f64N/A
distribute-lft-inN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6478.5
Applied rewrites78.5%
if -5e176 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < -1 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 78.9%
Taylor expanded in t around inf
Applied rewrites86.6%
Final simplification82.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
(if (<= t_1 -5e+286)
(/ 2.0 (* t z))
(if (or (<= t_1 2e+57) (not (<= t_1 INFINITY)))
(+ (/ x y) -2.0)
(/ (/ 2.0 z) t)))))
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 <= -5e+286) {
tmp = 2.0 / (t * z);
} else if ((t_1 <= 2e+57) || !(t_1 <= ((double) INFINITY))) {
tmp = (x / y) + -2.0;
} else {
tmp = (2.0 / z) / t;
}
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 <= -5e+286) {
tmp = 2.0 / (t * z);
} else if ((t_1 <= 2e+57) || !(t_1 <= Double.POSITIVE_INFINITY)) {
tmp = (x / y) + -2.0;
} else {
tmp = (2.0 / z) / t;
}
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 <= -5e+286: tmp = 2.0 / (t * z) elif (t_1 <= 2e+57) or not (t_1 <= math.inf): tmp = (x / y) + -2.0 else: tmp = (2.0 / z) / t 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 <= -5e+286) tmp = Float64(2.0 / Float64(t * z)); elseif ((t_1 <= 2e+57) || !(t_1 <= Inf)) tmp = Float64(Float64(x / y) + -2.0); else tmp = Float64(Float64(2.0 / z) / t); 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 <= -5e+286) tmp = 2.0 / (t * z); elseif ((t_1 <= 2e+57) || ~((t_1 <= Inf))) tmp = (x / y) + -2.0; else tmp = (2.0 / z) / t; 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[LessEqual[t$95$1, -5e+286], N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$1, 2e+57], N[Not[LessEqual[t$95$1, Infinity]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] / t), $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 -5 \cdot 10^{+286}:\\
\;\;\;\;\frac{2}{t \cdot z}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+57} \lor \neg \left(t\_1 \leq \infty\right):\\
\;\;\;\;\frac{x}{y} + -2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{z}}{t}\\
\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)) < -5.0000000000000004e286Initial program 99.9%
Taylor expanded in z around 0
lower-/.f64N/A
lift-*.f6481.8
Applied rewrites81.8%
if -5.0000000000000004e286 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < 2.0000000000000001e57 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 82.6%
Taylor expanded in t around inf
Applied rewrites77.5%
if 2.0000000000000001e57 < (/.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 96.9%
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-/.f6480.8
Applied rewrites80.8%
Taylor expanded in z around 0
lift-/.f6455.9
Applied rewrites55.9%
Final simplification71.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
(if (or (<= t_1 -5e+286) (not (or (<= t_1 2e+57) (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 <= -5e+286) || !((t_1 <= 2e+57) || !(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 <= -5e+286) || !((t_1 <= 2e+57) || !(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 <= -5e+286) or not ((t_1 <= 2e+57) 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 <= -5e+286) || !((t_1 <= 2e+57) || !(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 <= -5e+286) || ~(((t_1 <= 2e+57) || ~((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, -5e+286], N[Not[Or[LessEqual[t$95$1, 2e+57], 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 -5 \cdot 10^{+286} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+57} \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)) < -5.0000000000000004e286 or 2.0000000000000001e57 < (/.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 97.4%
Taylor expanded in z around 0
lower-/.f64N/A
lift-*.f6460.6
Applied rewrites60.6%
if -5.0000000000000004e286 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < 2.0000000000000001e57 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 82.6%
Taylor expanded in t around inf
Applied rewrites77.5%
Final simplification71.7%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -10000000.0) (not (<= (/ x y) 5e-7))) (+ (/ x y) (/ 2.0 (* t z))) (/ (+ (fma -2.0 t (/ 2.0 z)) 2.0) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -10000000.0) || !((x / y) <= 5e-7)) {
tmp = (x / y) + (2.0 / (t * z));
} else {
tmp = (fma(-2.0, t, (2.0 / z)) + 2.0) / t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -10000000.0) || !(Float64(x / y) <= 5e-7)) tmp = Float64(Float64(x / y) + Float64(2.0 / Float64(t * z))); else tmp = Float64(Float64(fma(-2.0, t, Float64(2.0 / z)) + 2.0) / t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -10000000.0], N[Not[LessEqual[N[(x / y), $MachinePrecision], 5e-7]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-2.0 * t + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -10000000 \lor \neg \left(\frac{x}{y} \leq 5 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{x}{y} + \frac{2}{t \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, t, \frac{2}{z}\right) + 2}{t}\\
\end{array}
\end{array}
if (/.f64 x y) < -1e7 or 4.99999999999999977e-7 < (/.f64 x y) Initial program 85.8%
Taylor expanded in z around 0
Applied rewrites87.6%
if -1e7 < (/.f64 x y) < 4.99999999999999977e-7Initial program 89.6%
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 t around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-fma.f64N/A
lift-/.f6498.6
Applied rewrites98.6%
Final simplification93.1%
(FPCore (x y z t)
:precision binary64
(if (<= (/ x y) -10000000.0)
(+ (/ x y) (/ (/ (fma z 2.0 2.0) t) z))
(if (<= (/ x y) 0.5)
(/ (+ (fma -2.0 t (/ 2.0 z)) 2.0) t)
(fma (/ (- 1.0 t) t) 2.0 (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -10000000.0) {
tmp = (x / y) + ((fma(z, 2.0, 2.0) / t) / z);
} else if ((x / y) <= 0.5) {
tmp = (fma(-2.0, t, (2.0 / z)) + 2.0) / t;
} else {
tmp = fma(((1.0 - t) / t), 2.0, (x / y));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -10000000.0) tmp = Float64(Float64(x / y) + Float64(Float64(fma(z, 2.0, 2.0) / t) / z)); elseif (Float64(x / y) <= 0.5) tmp = Float64(Float64(fma(-2.0, t, Float64(2.0 / z)) + 2.0) / t); else tmp = fma(Float64(Float64(1.0 - t) / t), 2.0, Float64(x / y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -10000000.0], N[(N[(x / y), $MachinePrecision] + N[(N[(N[(z * 2.0 + 2.0), $MachinePrecision] / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 0.5], N[(N[(N[(-2.0 * t + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] / t), $MachinePrecision], N[(N[(N[(1.0 - t), $MachinePrecision] / t), $MachinePrecision] * 2.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -10000000:\\
\;\;\;\;\frac{x}{y} + \frac{\frac{\mathsf{fma}\left(z, 2, 2\right)}{t}}{z}\\
\mathbf{elif}\;\frac{x}{y} \leq 0.5:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, t, \frac{2}{z}\right) + 2}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1 - t}{t}, 2, \frac{x}{y}\right)\\
\end{array}
\end{array}
if (/.f64 x y) < -1e7Initial program 79.9%
Taylor expanded in t around 0
associate-/r*N/A
div-addN/A
metadata-evalN/A
associate-*r/N/A
associate-*r/N/A
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6489.9
Applied rewrites89.9%
if -1e7 < (/.f64 x y) < 0.5Initial program 89.6%
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 t around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-fma.f64N/A
lift-/.f6498.6
Applied rewrites98.6%
if 0.5 < (/.f64 x y) Initial program 92.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift-/.f6490.1
Applied rewrites90.1%
Final simplification94.3%
(FPCore (x y z t)
:precision binary64
(if (<= (/ x y) -10000000.0)
(+ (/ (/ 2.0 t) z) (/ x y))
(if (<= (/ x y) 0.5)
(/ (+ (fma -2.0 t (/ 2.0 z)) 2.0) t)
(fma (/ (- 1.0 t) t) 2.0 (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -10000000.0) {
tmp = ((2.0 / t) / z) + (x / y);
} else if ((x / y) <= 0.5) {
tmp = (fma(-2.0, t, (2.0 / z)) + 2.0) / t;
} else {
tmp = fma(((1.0 - t) / t), 2.0, (x / y));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -10000000.0) tmp = Float64(Float64(Float64(2.0 / t) / z) + Float64(x / y)); elseif (Float64(x / y) <= 0.5) tmp = Float64(Float64(fma(-2.0, t, Float64(2.0 / z)) + 2.0) / t); else tmp = fma(Float64(Float64(1.0 - t) / t), 2.0, Float64(x / y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -10000000.0], N[(N[(N[(2.0 / t), $MachinePrecision] / z), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 0.5], N[(N[(N[(-2.0 * t + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] / t), $MachinePrecision], N[(N[(N[(1.0 - t), $MachinePrecision] / t), $MachinePrecision] * 2.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -10000000:\\
\;\;\;\;\frac{\frac{2}{t}}{z} + \frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 0.5:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, t, \frac{2}{z}\right) + 2}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1 - t}{t}, 2, \frac{x}{y}\right)\\
\end{array}
\end{array}
if (/.f64 x y) < -1e7Initial program 79.9%
Taylor expanded in z around 0
Applied rewrites88.1%
lift-+.f64N/A
lift-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f6488.2
Applied rewrites88.2%
if -1e7 < (/.f64 x y) < 0.5Initial program 89.6%
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 t around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-fma.f64N/A
lift-/.f6498.6
Applied rewrites98.6%
if 0.5 < (/.f64 x y) Initial program 92.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift-/.f6490.1
Applied rewrites90.1%
Final simplification93.9%
(FPCore (x y z t)
:precision binary64
(if (<= (/ x y) -10000000.0)
(+ (/ x y) (/ (/ 2.0 z) t))
(if (<= (/ x y) 0.5)
(/ (+ (fma -2.0 t (/ 2.0 z)) 2.0) t)
(fma (/ (- 1.0 t) t) 2.0 (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -10000000.0) {
tmp = (x / y) + ((2.0 / z) / t);
} else if ((x / y) <= 0.5) {
tmp = (fma(-2.0, t, (2.0 / z)) + 2.0) / t;
} else {
tmp = fma(((1.0 - t) / t), 2.0, (x / y));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -10000000.0) tmp = Float64(Float64(x / y) + Float64(Float64(2.0 / z) / t)); elseif (Float64(x / y) <= 0.5) tmp = Float64(Float64(fma(-2.0, t, Float64(2.0 / z)) + 2.0) / t); else tmp = fma(Float64(Float64(1.0 - t) / t), 2.0, Float64(x / y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -10000000.0], N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 0.5], N[(N[(N[(-2.0 * t + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] / t), $MachinePrecision], N[(N[(N[(1.0 - t), $MachinePrecision] / t), $MachinePrecision] * 2.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -10000000:\\
\;\;\;\;\frac{x}{y} + \frac{\frac{2}{z}}{t}\\
\mathbf{elif}\;\frac{x}{y} \leq 0.5:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, t, \frac{2}{z}\right) + 2}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1 - t}{t}, 2, \frac{x}{y}\right)\\
\end{array}
\end{array}
if (/.f64 x y) < -1e7Initial program 79.9%
Taylor expanded in t around 0
lower-/.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-fma.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-/.f6497.1
Applied rewrites97.1%
Taylor expanded in z around 0
lift-/.f6488.2
Applied rewrites88.2%
if -1e7 < (/.f64 x y) < 0.5Initial program 89.6%
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 t around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-fma.f64N/A
lift-/.f6498.6
Applied rewrites98.6%
if 0.5 < (/.f64 x y) Initial program 92.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift-/.f6490.1
Applied rewrites90.1%
Final simplification93.9%
(FPCore (x y z t)
:precision binary64
(if (<= (/ x y) -10000000.0)
(+ (/ x y) (/ 2.0 (* t z)))
(if (<= (/ x y) 0.5)
(/ (+ (fma -2.0 t (/ 2.0 z)) 2.0) t)
(fma (/ (- 1.0 t) t) 2.0 (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -10000000.0) {
tmp = (x / y) + (2.0 / (t * z));
} else if ((x / y) <= 0.5) {
tmp = (fma(-2.0, t, (2.0 / z)) + 2.0) / t;
} else {
tmp = fma(((1.0 - t) / t), 2.0, (x / y));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -10000000.0) tmp = Float64(Float64(x / y) + Float64(2.0 / Float64(t * z))); elseif (Float64(x / y) <= 0.5) tmp = Float64(Float64(fma(-2.0, t, Float64(2.0 / z)) + 2.0) / t); else tmp = fma(Float64(Float64(1.0 - t) / t), 2.0, Float64(x / y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -10000000.0], N[(N[(x / y), $MachinePrecision] + N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 0.5], N[(N[(N[(-2.0 * t + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] / t), $MachinePrecision], N[(N[(N[(1.0 - t), $MachinePrecision] / t), $MachinePrecision] * 2.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -10000000:\\
\;\;\;\;\frac{x}{y} + \frac{2}{t \cdot z}\\
\mathbf{elif}\;\frac{x}{y} \leq 0.5:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, t, \frac{2}{z}\right) + 2}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1 - t}{t}, 2, \frac{x}{y}\right)\\
\end{array}
\end{array}
if (/.f64 x y) < -1e7Initial program 79.9%
Taylor expanded in z around 0
Applied rewrites88.1%
if -1e7 < (/.f64 x y) < 0.5Initial program 89.6%
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 t around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-fma.f64N/A
lift-/.f6498.6
Applied rewrites98.6%
if 0.5 < (/.f64 x y) Initial program 92.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift-/.f6490.1
Applied rewrites90.1%
Final simplification93.8%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -10000000.0) (not (<= (/ x y) 5e-7))) (+ (/ x y) (/ 2.0 (* t z))) (/ (fma (* z 2.0) (- 1.0 t) 2.0) (* t z))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -10000000.0) || !((x / y) <= 5e-7)) {
tmp = (x / y) + (2.0 / (t * z));
} else {
tmp = fma((z * 2.0), (1.0 - t), 2.0) / (t * z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -10000000.0) || !(Float64(x / y) <= 5e-7)) tmp = Float64(Float64(x / y) + Float64(2.0 / Float64(t * z))); else tmp = Float64(fma(Float64(z * 2.0), Float64(1.0 - t), 2.0) / Float64(t * z)); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -10000000.0], N[Not[LessEqual[N[(x / y), $MachinePrecision], 5e-7]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision] + 2.0), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -10000000 \lor \neg \left(\frac{x}{y} \leq 5 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{x}{y} + \frac{2}{t \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z \cdot 2, 1 - t, 2\right)}{t \cdot z}\\
\end{array}
\end{array}
if (/.f64 x y) < -1e7 or 4.99999999999999977e-7 < (/.f64 x y) Initial program 85.8%
Taylor expanded in z around 0
Applied rewrites87.6%
if -1e7 < (/.f64 x y) < 4.99999999999999977e-7Initial program 89.6%
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 t around inf
Applied rewrites39.7%
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 rewrites88.5%
Final simplification88.1%
(FPCore (x y z t)
:precision binary64
(if (<= (/ x y) -5.6e+119)
(/ x y)
(if (<= (/ x y) 3100000000000.0)
(/ (fma (* z 2.0) (- 1.0 t) 2.0) (* t z))
(+ (/ x y) -2.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -5.6e+119) {
tmp = x / y;
} else if ((x / y) <= 3100000000000.0) {
tmp = fma((z * 2.0), (1.0 - t), 2.0) / (t * z);
} else {
tmp = (x / y) + -2.0;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -5.6e+119) tmp = Float64(x / y); elseif (Float64(x / y) <= 3100000000000.0) tmp = Float64(fma(Float64(z * 2.0), Float64(1.0 - t), 2.0) / Float64(t * z)); else tmp = Float64(Float64(x / y) + -2.0); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -5.6e+119], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 3100000000000.0], N[(N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision] + 2.0), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5.6 \cdot 10^{+119}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 3100000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(z \cdot 2, 1 - t, 2\right)}{t \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + -2\\
\end{array}
\end{array}
if (/.f64 x y) < -5.60000000000000026e119Initial program 75.4%
Taylor expanded in x around inf
lift-/.f6486.1
Applied rewrites86.1%
if -5.60000000000000026e119 < (/.f64 x y) < 3.1e12Initial program 89.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-*.f6493.6
Applied rewrites93.6%
Taylor expanded in t around inf
Applied rewrites34.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 rewrites84.9%
if 3.1e12 < (/.f64 x y) Initial program 92.9%
Taylor expanded in t around inf
Applied rewrites77.0%
Final simplification83.4%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -5.5e-8) (not (<= (/ x y) 700.0))) (+ (/ x y) -2.0) (fma -1.0 2.0 (/ 2.0 (* t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -5.5e-8) || !((x / y) <= 700.0)) {
tmp = (x / y) + -2.0;
} else {
tmp = fma(-1.0, 2.0, (2.0 / (t * z)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -5.5e-8) || !(Float64(x / y) <= 700.0)) tmp = Float64(Float64(x / y) + -2.0); else tmp = fma(-1.0, 2.0, Float64(2.0 / Float64(t * z))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -5.5e-8], N[Not[LessEqual[N[(x / y), $MachinePrecision], 700.0]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision], N[(-1.0 * 2.0 + N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5.5 \cdot 10^{-8} \lor \neg \left(\frac{x}{y} \leq 700\right):\\
\;\;\;\;\frac{x}{y} + -2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, 2, \frac{2}{t \cdot z}\right)\\
\end{array}
\end{array}
if (/.f64 x y) < -5.5000000000000003e-8 or 700 < (/.f64 x y) Initial program 85.9%
Taylor expanded in t around inf
Applied rewrites74.7%
if -5.5000000000000003e-8 < (/.f64 x y) < 700Initial program 89.5%
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 rewrites77.6%
Final simplification76.1%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -5.1e-40) (not (<= (/ x y) 1.65e-21))) (+ (/ x y) -2.0) (- (/ 2.0 t) 2.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -5.1e-40) || !((x / y) <= 1.65e-21)) {
tmp = (x / y) + -2.0;
} else {
tmp = (2.0 / t) - 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) <= (-5.1d-40)) .or. (.not. ((x / y) <= 1.65d-21))) then
tmp = (x / y) + (-2.0d0)
else
tmp = (2.0d0 / t) - 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) <= -5.1e-40) || !((x / y) <= 1.65e-21)) {
tmp = (x / y) + -2.0;
} else {
tmp = (2.0 / t) - 2.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -5.1e-40) or not ((x / y) <= 1.65e-21): tmp = (x / y) + -2.0 else: tmp = (2.0 / t) - 2.0 return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -5.1e-40) || !(Float64(x / y) <= 1.65e-21)) tmp = Float64(Float64(x / y) + -2.0); else tmp = Float64(Float64(2.0 / t) - 2.0); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -5.1e-40) || ~(((x / y) <= 1.65e-21))) tmp = (x / y) + -2.0; else tmp = (2.0 / t) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -5.1e-40], N[Not[LessEqual[N[(x / y), $MachinePrecision], 1.65e-21]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision], N[(N[(2.0 / t), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5.1 \cdot 10^{-40} \lor \neg \left(\frac{x}{y} \leq 1.65 \cdot 10^{-21}\right):\\
\;\;\;\;\frac{x}{y} + -2\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{t} - 2\\
\end{array}
\end{array}
if (/.f64 x y) < -5.10000000000000037e-40 or 1.65000000000000004e-21 < (/.f64 x y) Initial program 85.4%
Taylor expanded in t around inf
Applied rewrites72.4%
if -5.10000000000000037e-40 < (/.f64 x y) < 1.65000000000000004e-21Initial program 90.4%
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.8
Applied rewrites99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f6462.5
Applied rewrites62.5%
Taylor expanded in t around inf
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6462.5
Applied rewrites62.5%
Final simplification67.8%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -240000.0) (not (<= (/ x y) 3900000000.0))) (/ x y) (- (/ 2.0 t) 2.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -240000.0) || !((x / y) <= 3900000000.0)) {
tmp = x / y;
} else {
tmp = (2.0 / t) - 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) <= (-240000.0d0)) .or. (.not. ((x / y) <= 3900000000.0d0))) then
tmp = x / y
else
tmp = (2.0d0 / t) - 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) <= -240000.0) || !((x / y) <= 3900000000.0)) {
tmp = x / y;
} else {
tmp = (2.0 / t) - 2.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -240000.0) or not ((x / y) <= 3900000000.0): tmp = x / y else: tmp = (2.0 / t) - 2.0 return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -240000.0) || !(Float64(x / y) <= 3900000000.0)) tmp = Float64(x / y); else tmp = Float64(Float64(2.0 / t) - 2.0); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -240000.0) || ~(((x / y) <= 3900000000.0))) tmp = x / y; else tmp = (2.0 / t) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -240000.0], N[Not[LessEqual[N[(x / y), $MachinePrecision], 3900000000.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(N[(2.0 / t), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -240000 \lor \neg \left(\frac{x}{y} \leq 3900000000\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{t} - 2\\
\end{array}
\end{array}
if (/.f64 x y) < -2.4e5 or 3.9e9 < (/.f64 x y) Initial program 85.7%
Taylor expanded in x around inf
lift-/.f6473.8
Applied rewrites73.8%
if -2.4e5 < (/.f64 x y) < 3.9e9Initial program 89.6%
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 inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f6460.2
Applied rewrites60.2%
Taylor expanded in t around inf
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6460.2
Applied rewrites60.2%
Final simplification67.0%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -2.0) (not (<= (/ x y) 2.0))) (/ x y) -2.0))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -2.0) || !((x / y) <= 2.0)) {
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) <= (-2.0d0)) .or. (.not. ((x / y) <= 2.0d0))) 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) <= -2.0) || !((x / y) <= 2.0)) {
tmp = x / y;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -2.0) or not ((x / y) <= 2.0): tmp = x / y else: tmp = -2.0 return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -2.0) || !(Float64(x / y) <= 2.0)) 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) <= -2.0) || ~(((x / y) <= 2.0))) tmp = x / y; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -2.0], N[Not[LessEqual[N[(x / y), $MachinePrecision], 2.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -2 \lor \neg \left(\frac{x}{y} \leq 2\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if (/.f64 x y) < -2 or 2 < (/.f64 x y) Initial program 85.7%
Taylor expanded in x around inf
lift-/.f6473.8
Applied rewrites73.8%
if -2 < (/.f64 x y) < 2Initial program 89.6%
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 t around inf
Applied rewrites39.4%
Final simplification56.5%
(FPCore (x y z t) :precision binary64 (+ (/ x y) (/ (fma -2.0 t (- (/ 2.0 z) -2.0)) t)))
double code(double x, double y, double z, double t) {
return (x / y) + (fma(-2.0, t, ((2.0 / z) - -2.0)) / t);
}
function code(x, y, z, t) return Float64(Float64(x / y) + Float64(fma(-2.0, t, Float64(Float64(2.0 / z) - -2.0)) / t)) end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(N[(-2.0 * t + N[(N[(2.0 / z), $MachinePrecision] - -2.0), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} + \frac{\mathsf{fma}\left(-2, t, \frac{2}{z} - -2\right)}{t}
\end{array}
Initial program 87.7%
Taylor expanded in t around 0
lower-/.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-fma.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-/.f6499.2
Applied rewrites99.2%
(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 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-*.f6464.0
Applied rewrites64.0%
Taylor expanded in t around inf
Applied rewrites21.1%
Final simplification21.1%
(FPCore (x y z t) :precision binary64 (- (/ (+ (/ 2.0 z) 2.0) t) (- 2.0 (/ x y))))
double code(double x, double y, double z, double t) {
return (((2.0 / z) + 2.0) / t) - (2.0 - (x / y));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((2.0d0 / z) + 2.0d0) / t) - (2.0d0 - (x / y))
end function
public static double code(double x, double y, double z, double t) {
return (((2.0 / z) + 2.0) / t) - (2.0 - (x / y));
}
def code(x, y, z, t): return (((2.0 / z) + 2.0) / t) - (2.0 - (x / y))
function code(x, y, z, t) return Float64(Float64(Float64(Float64(2.0 / z) + 2.0) / t) - Float64(2.0 - Float64(x / y))) end
function tmp = code(x, y, z, t) tmp = (((2.0 / z) + 2.0) / t) - (2.0 - (x / y)); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(2.0 / z), $MachinePrecision] + 2.0), $MachinePrecision] / t), $MachinePrecision] - N[(2.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{z} + 2}{t} - \left(2 - \frac{x}{y}\right)
\end{array}
herbie shell --seed 2025038
(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))))