
(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 12 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 (fma (/ 2.0 t) (- (/ (+ 1.0 z) z) t) (/ x y)))
double code(double x, double y, double z, double t) {
return fma((2.0 / t), (((1.0 + z) / z) - t), (x / y));
}
function code(x, y, z, t) return fma(Float64(2.0 / t), Float64(Float64(Float64(1.0 + z) / z) - t), Float64(x / y)) end
code[x_, y_, z_, t_] := N[(N[(2.0 / t), $MachinePrecision] * N[(N[(N[(1.0 + z), $MachinePrecision] / z), $MachinePrecision] - t), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{2}{t}, \frac{1 + z}{z} - t, \frac{x}{y}\right)
\end{array}
Initial program 84.2%
Taylor expanded in x around 0
Applied rewrites99.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 -2000000000000.0)
(not (or (<= t_1 2e+44) (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 <= -2000000000000.0) || !((t_1 <= 2e+44) || !(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 <= -2000000000000.0) || !((t_1 <= 2e+44) || !(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 <= -2000000000000.0) or not ((t_1 <= 2e+44) 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 <= -2000000000000.0) || !((t_1 <= 2e+44) || !(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 <= -2000000000000.0) || ~(((t_1 <= 2e+44) || ~((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, -2000000000000.0], N[Not[Or[LessEqual[t$95$1, 2e+44], 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 -2000000000000 \lor \neg \left(t\_1 \leq 2 \cdot 10^{+44} \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)) < -2e12 or 2.0000000000000002e44 < (/.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.3%
Taylor expanded in t around 0
lower-/.f64N/A
metadata-evalN/A
*-inversesN/A
associate-/l*N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
div-subN/A
metadata-evalN/A
associate-*r/N/A
associate-*l/N/A
metadata-evalN/A
associate-*r/N/A
associate-*l*N/A
lft-mult-inverseN/A
metadata-evalN/A
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6473.6
Applied rewrites73.6%
if -2e12 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < 2.0000000000000002e44 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 66.0%
Taylor expanded in t around inf
Applied rewrites93.9%
Final simplification82.5%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -5000.0) (not (<= (/ x y) 4e-15))) (+ (/ x y) (/ (fma 2.0 z 2.0) (* t z))) (- -2.0 (/ (- (/ -2.0 z) 2.0) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -5000.0) || !((x / y) <= 4e-15)) {
tmp = (x / y) + (fma(2.0, z, 2.0) / (t * z));
} else {
tmp = -2.0 - (((-2.0 / z) - 2.0) / t);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -5000.0) || !(Float64(x / y) <= 4e-15)) tmp = Float64(Float64(x / y) + Float64(fma(2.0, z, 2.0) / Float64(t * z))); else tmp = Float64(-2.0 - Float64(Float64(Float64(-2.0 / z) - 2.0) / t)); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -5000.0], N[Not[LessEqual[N[(x / y), $MachinePrecision], 4e-15]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 * z + 2.0), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 - N[(N[(N[(-2.0 / z), $MachinePrecision] - 2.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5000 \lor \neg \left(\frac{x}{y} \leq 4 \cdot 10^{-15}\right):\\
\;\;\;\;\frac{x}{y} + \frac{\mathsf{fma}\left(2, z, 2\right)}{t \cdot z}\\
\mathbf{else}:\\
\;\;\;\;-2 - \frac{\frac{-2}{z} - 2}{t}\\
\end{array}
\end{array}
if (/.f64 x y) < -5e3 or 4.0000000000000003e-15 < (/.f64 x y) Initial program 81.0%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f6497.0
Applied rewrites97.0%
if -5e3 < (/.f64 x y) < 4.0000000000000003e-15Initial program 87.7%
Taylor expanded in x around 0
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
Final simplification98.4%
(FPCore (x y z t)
:precision binary64
(if (<= (/ x y) -5000.0)
(+ (/ x y) (- (/ 2.0 t) 2.0))
(if (<= (/ x y) 0.1)
(- -2.0 (/ (- (/ -2.0 z) 2.0) t))
(+ (/ x y) (/ 2.0 (* t z))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -5000.0) {
tmp = (x / y) + ((2.0 / t) - 2.0);
} else if ((x / y) <= 0.1) {
tmp = -2.0 - (((-2.0 / z) - 2.0) / t);
} else {
tmp = (x / y) + (2.0 / (t * z));
}
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) <= (-5000.0d0)) then
tmp = (x / y) + ((2.0d0 / t) - 2.0d0)
else if ((x / y) <= 0.1d0) then
tmp = (-2.0d0) - ((((-2.0d0) / z) - 2.0d0) / t)
else
tmp = (x / y) + (2.0d0 / (t * z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -5000.0) {
tmp = (x / y) + ((2.0 / t) - 2.0);
} else if ((x / y) <= 0.1) {
tmp = -2.0 - (((-2.0 / z) - 2.0) / t);
} else {
tmp = (x / y) + (2.0 / (t * z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -5000.0: tmp = (x / y) + ((2.0 / t) - 2.0) elif (x / y) <= 0.1: tmp = -2.0 - (((-2.0 / z) - 2.0) / t) else: tmp = (x / y) + (2.0 / (t * z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -5000.0) tmp = Float64(Float64(x / y) + Float64(Float64(2.0 / t) - 2.0)); elseif (Float64(x / y) <= 0.1) tmp = Float64(-2.0 - Float64(Float64(Float64(-2.0 / z) - 2.0) / t)); else tmp = Float64(Float64(x / y) + Float64(2.0 / Float64(t * z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -5000.0) tmp = (x / y) + ((2.0 / t) - 2.0); elseif ((x / y) <= 0.1) tmp = -2.0 - (((-2.0 / z) - 2.0) / t); else tmp = (x / y) + (2.0 / (t * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -5000.0], N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 / t), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 0.1], N[(-2.0 - N[(N[(N[(-2.0 / z), $MachinePrecision] - 2.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5000:\\
\;\;\;\;\frac{x}{y} + \left(\frac{2}{t} - 2\right)\\
\mathbf{elif}\;\frac{x}{y} \leq 0.1:\\
\;\;\;\;-2 - \frac{\frac{-2}{z} - 2}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + \frac{2}{t \cdot z}\\
\end{array}
\end{array}
if (/.f64 x y) < -5e3Initial program 80.5%
Taylor expanded in t around 0
Applied rewrites96.9%
Taylor expanded in z around inf
Applied rewrites88.4%
if -5e3 < (/.f64 x y) < 0.10000000000000001Initial program 87.8%
Taylor expanded in x around 0
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
if 0.10000000000000001 < (/.f64 x y) Initial program 80.9%
Taylor expanded in z around 0
Applied rewrites92.4%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -29.5) (not (<= (/ x y) 6.2e+15))) (+ (/ x y) (- (/ 2.0 t) 2.0)) (- -2.0 (/ (- (/ -2.0 z) 2.0) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -29.5) || !((x / y) <= 6.2e+15)) {
tmp = (x / y) + ((2.0 / t) - 2.0);
} else {
tmp = -2.0 - (((-2.0 / z) - 2.0) / t);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((x / y) <= (-29.5d0)) .or. (.not. ((x / y) <= 6.2d+15))) then
tmp = (x / y) + ((2.0d0 / t) - 2.0d0)
else
tmp = (-2.0d0) - ((((-2.0d0) / z) - 2.0d0) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -29.5) || !((x / y) <= 6.2e+15)) {
tmp = (x / y) + ((2.0 / t) - 2.0);
} else {
tmp = -2.0 - (((-2.0 / z) - 2.0) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -29.5) or not ((x / y) <= 6.2e+15): tmp = (x / y) + ((2.0 / t) - 2.0) else: tmp = -2.0 - (((-2.0 / z) - 2.0) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -29.5) || !(Float64(x / y) <= 6.2e+15)) tmp = Float64(Float64(x / y) + Float64(Float64(2.0 / t) - 2.0)); else tmp = Float64(-2.0 - Float64(Float64(Float64(-2.0 / z) - 2.0) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -29.5) || ~(((x / y) <= 6.2e+15))) tmp = (x / y) + ((2.0 / t) - 2.0); else tmp = -2.0 - (((-2.0 / z) - 2.0) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -29.5], N[Not[LessEqual[N[(x / y), $MachinePrecision], 6.2e+15]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 / t), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision], N[(-2.0 - N[(N[(N[(-2.0 / z), $MachinePrecision] - 2.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -29.5 \lor \neg \left(\frac{x}{y} \leq 6.2 \cdot 10^{+15}\right):\\
\;\;\;\;\frac{x}{y} + \left(\frac{2}{t} - 2\right)\\
\mathbf{else}:\\
\;\;\;\;-2 - \frac{\frac{-2}{z} - 2}{t}\\
\end{array}
\end{array}
if (/.f64 x y) < -29.5 or 6.2e15 < (/.f64 x y) Initial program 80.2%
Taylor expanded in t around 0
Applied rewrites98.4%
Taylor expanded in z around inf
Applied rewrites85.2%
if -29.5 < (/.f64 x y) < 6.2e15Initial program 88.1%
Taylor expanded in x around 0
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.0%
Final simplification92.2%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -5.6e+71) (not (<= (/ x y) 7.5e+176))) (+ (/ x y) -2.0) (- -2.0 (/ (- (/ -2.0 z) 2.0) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -5.6e+71) || !((x / y) <= 7.5e+176)) {
tmp = (x / y) + -2.0;
} else {
tmp = -2.0 - (((-2.0 / z) - 2.0) / t);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((x / y) <= (-5.6d+71)) .or. (.not. ((x / y) <= 7.5d+176))) then
tmp = (x / y) + (-2.0d0)
else
tmp = (-2.0d0) - ((((-2.0d0) / z) - 2.0d0) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -5.6e+71) || !((x / y) <= 7.5e+176)) {
tmp = (x / y) + -2.0;
} else {
tmp = -2.0 - (((-2.0 / z) - 2.0) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -5.6e+71) or not ((x / y) <= 7.5e+176): tmp = (x / y) + -2.0 else: tmp = -2.0 - (((-2.0 / z) - 2.0) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -5.6e+71) || !(Float64(x / y) <= 7.5e+176)) tmp = Float64(Float64(x / y) + -2.0); else tmp = Float64(-2.0 - Float64(Float64(Float64(-2.0 / z) - 2.0) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -5.6e+71) || ~(((x / y) <= 7.5e+176))) tmp = (x / y) + -2.0; else tmp = -2.0 - (((-2.0 / z) - 2.0) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -5.6e+71], N[Not[LessEqual[N[(x / y), $MachinePrecision], 7.5e+176]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision], N[(-2.0 - N[(N[(N[(-2.0 / z), $MachinePrecision] - 2.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5.6 \cdot 10^{+71} \lor \neg \left(\frac{x}{y} \leq 7.5 \cdot 10^{+176}\right):\\
\;\;\;\;\frac{x}{y} + -2\\
\mathbf{else}:\\
\;\;\;\;-2 - \frac{\frac{-2}{z} - 2}{t}\\
\end{array}
\end{array}
if (/.f64 x y) < -5.60000000000000004e71 or 7.499999999999999e176 < (/.f64 x y) Initial program 79.9%
Taylor expanded in t around inf
Applied rewrites88.6%
if -5.60000000000000004e71 < (/.f64 x y) < 7.499999999999999e176Initial program 86.7%
Taylor expanded in x around 0
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites90.2%
Final simplification89.6%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -2.6) (not (<= (/ x y) 6.2e+15))) (+ (/ x y) -2.0) (- -2.0 (/ (/ -2.0 z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -2.6) || !((x / y) <= 6.2e+15)) {
tmp = (x / y) + -2.0;
} else {
tmp = -2.0 - ((-2.0 / z) / t);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((x / y) <= (-2.6d0)) .or. (.not. ((x / y) <= 6.2d+15))) then
tmp = (x / y) + (-2.0d0)
else
tmp = (-2.0d0) - (((-2.0d0) / z) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -2.6) || !((x / y) <= 6.2e+15)) {
tmp = (x / y) + -2.0;
} else {
tmp = -2.0 - ((-2.0 / z) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -2.6) or not ((x / y) <= 6.2e+15): tmp = (x / y) + -2.0 else: tmp = -2.0 - ((-2.0 / z) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -2.6) || !(Float64(x / y) <= 6.2e+15)) tmp = Float64(Float64(x / y) + -2.0); else tmp = Float64(-2.0 - Float64(Float64(-2.0 / z) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -2.6) || ~(((x / y) <= 6.2e+15))) tmp = (x / y) + -2.0; else tmp = -2.0 - ((-2.0 / z) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -2.6], N[Not[LessEqual[N[(x / y), $MachinePrecision], 6.2e+15]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision], N[(-2.0 - N[(N[(-2.0 / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -2.6 \lor \neg \left(\frac{x}{y} \leq 6.2 \cdot 10^{+15}\right):\\
\;\;\;\;\frac{x}{y} + -2\\
\mathbf{else}:\\
\;\;\;\;-2 - \frac{\frac{-2}{z}}{t}\\
\end{array}
\end{array}
if (/.f64 x y) < -2.60000000000000009 or 6.2e15 < (/.f64 x y) Initial program 80.4%
Taylor expanded in t around inf
Applied rewrites76.6%
if -2.60000000000000009 < (/.f64 x y) < 6.2e15Initial program 88.0%
Taylor expanded in x around 0
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.0%
Taylor expanded in z around 0
Applied rewrites72.3%
Final simplification74.4%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -225.0) (not (<= (/ x y) 0.16))) (+ (/ x y) -2.0) (* (/ (- 1.0 t) t) 2.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -225.0) || !((x / y) <= 0.16)) {
tmp = (x / y) + -2.0;
} else {
tmp = ((1.0 - t) / 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) <= (-225.0d0)) .or. (.not. ((x / y) <= 0.16d0))) then
tmp = (x / y) + (-2.0d0)
else
tmp = ((1.0d0 - t) / 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) <= -225.0) || !((x / y) <= 0.16)) {
tmp = (x / y) + -2.0;
} else {
tmp = ((1.0 - t) / t) * 2.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -225.0) or not ((x / y) <= 0.16): tmp = (x / y) + -2.0 else: tmp = ((1.0 - t) / t) * 2.0 return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -225.0) || !(Float64(x / y) <= 0.16)) tmp = Float64(Float64(x / y) + -2.0); else tmp = Float64(Float64(Float64(1.0 - t) / t) * 2.0); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -225.0) || ~(((x / y) <= 0.16))) tmp = (x / y) + -2.0; else tmp = ((1.0 - t) / t) * 2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -225.0], N[Not[LessEqual[N[(x / y), $MachinePrecision], 0.16]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision], N[(N[(N[(1.0 - t), $MachinePrecision] / t), $MachinePrecision] * 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -225 \lor \neg \left(\frac{x}{y} \leq 0.16\right):\\
\;\;\;\;\frac{x}{y} + -2\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - t}{t} \cdot 2\\
\end{array}
\end{array}
if (/.f64 x y) < -225 or 0.160000000000000003 < (/.f64 x y) Initial program 80.7%
Taylor expanded in t around inf
Applied rewrites76.2%
if -225 < (/.f64 x y) < 0.160000000000000003Initial program 87.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6462.3
Applied rewrites62.3%
Taylor expanded in x around 0
Applied rewrites62.2%
Taylor expanded in x around 0
Applied rewrites62.2%
Final simplification69.3%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -225.0) (not (<= (/ x y) 0.16))) (+ (/ x y) -2.0) (- (/ 2.0 t) 2.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -225.0) || !((x / y) <= 0.16)) {
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) <= (-225.0d0)) .or. (.not. ((x / y) <= 0.16d0))) 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) <= -225.0) || !((x / y) <= 0.16)) {
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) <= -225.0) or not ((x / y) <= 0.16): 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) <= -225.0) || !(Float64(x / y) <= 0.16)) 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) <= -225.0) || ~(((x / y) <= 0.16))) 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], -225.0], N[Not[LessEqual[N[(x / y), $MachinePrecision], 0.16]], $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 -225 \lor \neg \left(\frac{x}{y} \leq 0.16\right):\\
\;\;\;\;\frac{x}{y} + -2\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{t} - 2\\
\end{array}
\end{array}
if (/.f64 x y) < -225 or 0.160000000000000003 < (/.f64 x y) Initial program 80.7%
Taylor expanded in t around inf
Applied rewrites76.2%
if -225 < (/.f64 x y) < 0.160000000000000003Initial program 87.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6462.3
Applied rewrites62.3%
Taylor expanded in x around 0
Applied rewrites62.2%
Final simplification69.3%
(FPCore (x y z t) :precision binary64 (+ (/ x y) (- (/ (- (/ 2.0 z) -2.0) t) 2.0)))
double code(double x, double y, double z, double t) {
return (x / y) + ((((2.0 / z) - -2.0) / t) - 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 = (x / y) + ((((2.0d0 / z) - (-2.0d0)) / t) - 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x / y) + ((((2.0 / z) - -2.0) / t) - 2.0);
}
def code(x, y, z, t): return (x / y) + ((((2.0 / z) - -2.0) / t) - 2.0)
function code(x, y, z, t) return Float64(Float64(x / y) + Float64(Float64(Float64(Float64(2.0 / z) - -2.0) / t) - 2.0)) end
function tmp = code(x, y, z, t) tmp = (x / y) + ((((2.0 / z) - -2.0) / t) - 2.0); end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(N[(N[(N[(2.0 / z), $MachinePrecision] - -2.0), $MachinePrecision] / t), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} + \left(\frac{\frac{2}{z} - -2}{t} - 2\right)
\end{array}
Initial program 84.2%
Taylor expanded in t around 0
Applied rewrites99.1%
(FPCore (x y z t) :precision binary64 (- (/ 2.0 t) 2.0))
double code(double x, double y, double z, double t) {
return (2.0 / t) - 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 / t) - 2.0d0
end function
public static double code(double x, double y, double z, double t) {
return (2.0 / t) - 2.0;
}
def code(x, y, z, t): return (2.0 / t) - 2.0
function code(x, y, z, t) return Float64(Float64(2.0 / t) - 2.0) end
function tmp = code(x, y, z, t) tmp = (2.0 / t) - 2.0; end
code[x_, y_, z_, t_] := N[(N[(2.0 / t), $MachinePrecision] - 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{t} - 2
\end{array}
Initial program 84.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6473.3
Applied rewrites73.3%
Taylor expanded in x around 0
Applied rewrites34.5%
(FPCore (x y z t) :precision binary64 (* -1.0 2.0))
double code(double x, double y, double z, double t) {
return -1.0 * 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 = (-1.0d0) * 2.0d0
end function
public static double code(double x, double y, double z, double t) {
return -1.0 * 2.0;
}
def code(x, y, z, t): return -1.0 * 2.0
function code(x, y, z, t) return Float64(-1.0 * 2.0) end
function tmp = code(x, y, z, t) tmp = -1.0 * 2.0; end
code[x_, y_, z_, t_] := N[(-1.0 * 2.0), $MachinePrecision]
\begin{array}{l}
\\
-1 \cdot 2
\end{array}
Initial program 84.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6473.3
Applied rewrites73.3%
Taylor expanded in x around 0
Applied rewrites34.5%
Taylor expanded in x around 0
Applied rewrites34.5%
Taylor expanded in t around inf
Applied rewrites18.8%
(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 2024364
(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))))