
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - 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 / z) - (t / (1.0d0 - z)))
end function
public static double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
def code(x, y, z, t): return x * ((y / z) - (t / (1.0 - z)))
function code(x, y, z, t) return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))) end
function tmp = code(x, y, z, t) tmp = x * ((y / z) - (t / (1.0 - z))); end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - 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 / z) - (t / (1.0d0 - z)))
end function
public static double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
def code(x, y, z, t): return x * ((y / z) - (t / (1.0 - z)))
function code(x, y, z, t) return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))) end
function tmp = code(x, y, z, t) tmp = x * ((y / z) - (t / (1.0 - z))); end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\end{array}
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (/ x z))) (t_2 (- (/ y z) (/ t (- 1.0 z))))) (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 1e+308) (* x t_2) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = y * (x / z);
double t_2 = (y / z) - (t / (1.0 - z));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 1e+308) {
tmp = x * t_2;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = y * (x / z);
double t_2 = (y / z) - (t / (1.0 - z));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 1e+308) {
tmp = x * t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * (x / z) t_2 = (y / z) - (t / (1.0 - z)) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 1e+308: tmp = x * t_2 else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(x / z)) t_2 = Float64(Float64(y / z) - Float64(t / Float64(1.0 - z))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 1e+308) tmp = Float64(x * t_2); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * (x / z); t_2 = (y / z) - (t / (1.0 - z)); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 1e+308) tmp = x * t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 1e+308], N[(x * t$95$2), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \frac{x}{z}\\
t_2 := \frac{y}{z} - \frac{t}{1 - z}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+308}:\\
\;\;\;\;x \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < -inf.0 or 1e308 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) Initial program 67.8%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6487.0
Applied rewrites87.0%
Taylor expanded in y around inf
Applied rewrites99.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.6
Applied rewrites99.6%
if -inf.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < 1e308Initial program 98.4%
(FPCore (x y z t) :precision binary64 (if (<= z -1.0) (/ (* (+ t y) x) z) (if (<= z 1.0) (/ (fma (- t) (* z x) (* y x)) z) (* x (/ (- y (- t)) z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.0) {
tmp = ((t + y) * x) / z;
} else if (z <= 1.0) {
tmp = fma(-t, (z * x), (y * x)) / z;
} else {
tmp = x * ((y - -t) / z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -1.0) tmp = Float64(Float64(Float64(t + y) * x) / z); elseif (z <= 1.0) tmp = Float64(fma(Float64(-t), Float64(z * x), Float64(y * x)) / z); else tmp = Float64(x * Float64(Float64(y - Float64(-t)) / z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.0], N[(N[(N[(t + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 1.0], N[(N[((-t) * N[(z * x), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(N[(y - (-t)), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;\frac{\left(t + y\right) \cdot x}{z}\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{\mathsf{fma}\left(-t, z \cdot x, y \cdot x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y - \left(-t\right)}{z}\\
\end{array}
\end{array}
if z < -1Initial program 97.3%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6485.6
Applied rewrites85.6%
Taylor expanded in y around 0
lower-+.f6485.6
Applied rewrites85.6%
if -1 < z < 1Initial program 91.6%
Taylor expanded in z around 0
lower-/.f64N/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6489.8
Applied rewrites89.8%
if 1 < z Initial program 97.4%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6496.6
Applied rewrites96.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* (+ t y) x) z)))
(if (<= z -1.6e-36)
t_1
(if (<= z 1.4e-167) (/ (* y x) z) (if (<= z 6.2e-114) (* x (- t)) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = ((t + y) * x) / z;
double tmp;
if (z <= -1.6e-36) {
tmp = t_1;
} else if (z <= 1.4e-167) {
tmp = (y * x) / z;
} else if (z <= 6.2e-114) {
tmp = x * -t;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = ((t + y) * x) / z
if (z <= (-1.6d-36)) then
tmp = t_1
else if (z <= 1.4d-167) then
tmp = (y * x) / z
else if (z <= 6.2d-114) then
tmp = x * -t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = ((t + y) * x) / z;
double tmp;
if (z <= -1.6e-36) {
tmp = t_1;
} else if (z <= 1.4e-167) {
tmp = (y * x) / z;
} else if (z <= 6.2e-114) {
tmp = x * -t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = ((t + y) * x) / z tmp = 0 if z <= -1.6e-36: tmp = t_1 elif z <= 1.4e-167: tmp = (y * x) / z elif z <= 6.2e-114: tmp = x * -t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(t + y) * x) / z) tmp = 0.0 if (z <= -1.6e-36) tmp = t_1; elseif (z <= 1.4e-167) tmp = Float64(Float64(y * x) / z); elseif (z <= 6.2e-114) tmp = Float64(x * Float64(-t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = ((t + y) * x) / z; tmp = 0.0; if (z <= -1.6e-36) tmp = t_1; elseif (z <= 1.4e-167) tmp = (y * x) / z; elseif (z <= 6.2e-114) tmp = x * -t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(t + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -1.6e-36], t$95$1, If[LessEqual[z, 1.4e-167], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 6.2e-114], N[(x * (-t)), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(t + y\right) \cdot x}{z}\\
\mathbf{if}\;z \leq -1.6 \cdot 10^{-36}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{-167}:\\
\;\;\;\;\frac{y \cdot x}{z}\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{-114}:\\
\;\;\;\;x \cdot \left(-t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.60000000000000011e-36 or 6.2e-114 < z Initial program 97.2%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6480.4
Applied rewrites80.4%
Taylor expanded in y around 0
lower-+.f6480.4
Applied rewrites80.4%
if -1.60000000000000011e-36 < z < 1.39999999999999993e-167Initial program 90.0%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6457.6
Applied rewrites57.6%
Taylor expanded in y around inf
Applied rewrites72.2%
if 1.39999999999999993e-167 < z < 6.2e-114Initial program 90.4%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6490.4
Applied rewrites90.4%
Taylor expanded in y around 0
mul-1-negN/A
lift-neg.f6434.7
Applied rewrites34.7%
(FPCore (x y z t) :precision binary64 (if (<= z -0.8) (/ (* (+ t y) x) z) (if (<= z 1.0) (* x (- (/ y z) t)) (* x (/ (- y (- t)) z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.8) {
tmp = ((t + y) * x) / z;
} else if (z <= 1.0) {
tmp = x * ((y / z) - t);
} else {
tmp = x * ((y - -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 (z <= (-0.8d0)) then
tmp = ((t + y) * x) / z
else if (z <= 1.0d0) then
tmp = x * ((y / z) - t)
else
tmp = x * ((y - -t) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.8) {
tmp = ((t + y) * x) / z;
} else if (z <= 1.0) {
tmp = x * ((y / z) - t);
} else {
tmp = x * ((y - -t) / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.8: tmp = ((t + y) * x) / z elif z <= 1.0: tmp = x * ((y / z) - t) else: tmp = x * ((y - -t) / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.8) tmp = Float64(Float64(Float64(t + y) * x) / z); elseif (z <= 1.0) tmp = Float64(x * Float64(Float64(y / z) - t)); else tmp = Float64(x * Float64(Float64(y - Float64(-t)) / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -0.8) tmp = ((t + y) * x) / z; elseif (z <= 1.0) tmp = x * ((y / z) - t); else tmp = x * ((y - -t) / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.8], N[(N[(N[(t + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 1.0], N[(x * N[(N[(y / z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(y - (-t)), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.8:\\
\;\;\;\;\frac{\left(t + y\right) \cdot x}{z}\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y - \left(-t\right)}{z}\\
\end{array}
\end{array}
if z < -0.80000000000000004Initial program 97.3%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6485.6
Applied rewrites85.6%
Taylor expanded in y around 0
lower-+.f6485.6
Applied rewrites85.6%
if -0.80000000000000004 < z < 1Initial program 91.6%
Taylor expanded in z around 0
Applied rewrites90.8%
if 1 < z Initial program 97.4%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6496.6
Applied rewrites96.6%
(FPCore (x y z t) :precision binary64 (if (<= z -0.8) (/ (* (+ t y) x) z) (if (<= z 1.0) (* x (- (/ y z) t)) (* (- y (- t)) (/ x z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.8) {
tmp = ((t + y) * x) / z;
} else if (z <= 1.0) {
tmp = x * ((y / z) - t);
} else {
tmp = (y - -t) * (x / 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 (z <= (-0.8d0)) then
tmp = ((t + y) * x) / z
else if (z <= 1.0d0) then
tmp = x * ((y / z) - t)
else
tmp = (y - -t) * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.8) {
tmp = ((t + y) * x) / z;
} else if (z <= 1.0) {
tmp = x * ((y / z) - t);
} else {
tmp = (y - -t) * (x / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.8: tmp = ((t + y) * x) / z elif z <= 1.0: tmp = x * ((y / z) - t) else: tmp = (y - -t) * (x / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.8) tmp = Float64(Float64(Float64(t + y) * x) / z); elseif (z <= 1.0) tmp = Float64(x * Float64(Float64(y / z) - t)); else tmp = Float64(Float64(y - Float64(-t)) * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -0.8) tmp = ((t + y) * x) / z; elseif (z <= 1.0) tmp = x * ((y / z) - t); else tmp = (y - -t) * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.8], N[(N[(N[(t + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 1.0], N[(x * N[(N[(y / z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(y - (-t)), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.8:\\
\;\;\;\;\frac{\left(t + y\right) \cdot x}{z}\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y - \left(-t\right)\right) \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -0.80000000000000004Initial program 97.3%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6485.6
Applied rewrites85.6%
Taylor expanded in y around 0
lower-+.f6485.6
Applied rewrites85.6%
if -0.80000000000000004 < z < 1Initial program 91.6%
Taylor expanded in z around 0
Applied rewrites90.8%
if 1 < z Initial program 97.4%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6485.8
Applied rewrites85.8%
lift-/.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-neg.f64N/A
lower-/.f6486.7
Applied rewrites86.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (/ (* (+ t y) x) z))) (if (<= z -0.8) t_1 (if (<= z 1.0) (* x (- (/ y z) t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = ((t + y) * x) / z;
double tmp;
if (z <= -0.8) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x * ((y / z) - t);
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = ((t + y) * x) / z
if (z <= (-0.8d0)) then
tmp = t_1
else if (z <= 1.0d0) then
tmp = x * ((y / z) - t)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = ((t + y) * x) / z;
double tmp;
if (z <= -0.8) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x * ((y / z) - t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = ((t + y) * x) / z tmp = 0 if z <= -0.8: tmp = t_1 elif z <= 1.0: tmp = x * ((y / z) - t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(t + y) * x) / z) tmp = 0.0 if (z <= -0.8) tmp = t_1; elseif (z <= 1.0) tmp = Float64(x * Float64(Float64(y / z) - t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = ((t + y) * x) / z; tmp = 0.0; if (z <= -0.8) tmp = t_1; elseif (z <= 1.0) tmp = x * ((y / z) - t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(t + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -0.8], t$95$1, If[LessEqual[z, 1.0], N[(x * N[(N[(y / z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(t + y\right) \cdot x}{z}\\
\mathbf{if}\;z \leq -0.8:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -0.80000000000000004 or 1 < z Initial program 97.3%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6485.7
Applied rewrites85.7%
Taylor expanded in y around 0
lower-+.f6485.7
Applied rewrites85.7%
if -0.80000000000000004 < z < 1Initial program 91.6%
Taylor expanded in z around 0
Applied rewrites90.8%
(FPCore (x y z t) :precision binary64 (if (<= y -1.82e-183) (/ (* y x) z) (if (<= y 7.6e-251) (* x (- t)) (* y (/ x z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.82e-183) {
tmp = (y * x) / z;
} else if (y <= 7.6e-251) {
tmp = x * -t;
} else {
tmp = y * (x / 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 (y <= (-1.82d-183)) then
tmp = (y * x) / z
else if (y <= 7.6d-251) then
tmp = x * -t
else
tmp = y * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.82e-183) {
tmp = (y * x) / z;
} else if (y <= 7.6e-251) {
tmp = x * -t;
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.82e-183: tmp = (y * x) / z elif y <= 7.6e-251: tmp = x * -t else: tmp = y * (x / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.82e-183) tmp = Float64(Float64(y * x) / z); elseif (y <= 7.6e-251) tmp = Float64(x * Float64(-t)); else tmp = Float64(y * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.82e-183) tmp = (y * x) / z; elseif (y <= 7.6e-251) tmp = x * -t; else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.82e-183], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 7.6e-251], N[(x * (-t)), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.82 \cdot 10^{-183}:\\
\;\;\;\;\frac{y \cdot x}{z}\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{-251}:\\
\;\;\;\;x \cdot \left(-t\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -1.82e-183Initial program 93.7%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6475.0
Applied rewrites75.0%
Taylor expanded in y around inf
Applied rewrites67.7%
if -1.82e-183 < y < 7.5999999999999994e-251Initial program 97.2%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6458.5
Applied rewrites58.5%
Taylor expanded in y around 0
mul-1-negN/A
lift-neg.f6444.3
Applied rewrites44.3%
if 7.5999999999999994e-251 < y Initial program 94.2%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6472.6
Applied rewrites72.6%
Taylor expanded in y around inf
Applied rewrites64.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6464.6
Applied rewrites64.6%
(FPCore (x y z t) :precision binary64 (if (<= t -1.5e+193) (* x (- t)) (if (<= t 8.2e+235) (* y (/ x z)) (/ (* t x) z))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.5e+193) {
tmp = x * -t;
} else if (t <= 8.2e+235) {
tmp = y * (x / z);
} else {
tmp = (t * x) / 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 (t <= (-1.5d+193)) then
tmp = x * -t
else if (t <= 8.2d+235) then
tmp = y * (x / z)
else
tmp = (t * x) / z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.5e+193) {
tmp = x * -t;
} else if (t <= 8.2e+235) {
tmp = y * (x / z);
} else {
tmp = (t * x) / z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.5e+193: tmp = x * -t elif t <= 8.2e+235: tmp = y * (x / z) else: tmp = (t * x) / z return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.5e+193) tmp = Float64(x * Float64(-t)); elseif (t <= 8.2e+235) tmp = Float64(y * Float64(x / z)); else tmp = Float64(Float64(t * x) / z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.5e+193) tmp = x * -t; elseif (t <= 8.2e+235) tmp = y * (x / z); else tmp = (t * x) / z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.5e+193], N[(x * (-t)), $MachinePrecision], If[LessEqual[t, 8.2e+235], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(t * x), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.5 \cdot 10^{+193}:\\
\;\;\;\;x \cdot \left(-t\right)\\
\mathbf{elif}\;t \leq 8.2 \cdot 10^{+235}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{t \cdot x}{z}\\
\end{array}
\end{array}
if t < -1.5e193Initial program 96.3%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6456.4
Applied rewrites56.4%
Taylor expanded in y around 0
mul-1-negN/A
lift-neg.f6445.4
Applied rewrites45.4%
if -1.5e193 < t < 8.2000000000000003e235Initial program 94.2%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6474.4
Applied rewrites74.4%
Taylor expanded in y around inf
Applied rewrites67.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6467.3
Applied rewrites67.3%
if 8.2000000000000003e235 < t Initial program 95.2%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6455.9
Applied rewrites55.9%
Taylor expanded in y around 0
Applied rewrites52.0%
(FPCore (x y z t) :precision binary64 (if (<= t -1.5e+193) (* x (- t)) (if (<= t 8.2e+235) (* y (/ x z)) (* t (/ x z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.5e+193) {
tmp = x * -t;
} else if (t <= 8.2e+235) {
tmp = y * (x / z);
} else {
tmp = t * (x / 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 (t <= (-1.5d+193)) then
tmp = x * -t
else if (t <= 8.2d+235) then
tmp = y * (x / z)
else
tmp = t * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.5e+193) {
tmp = x * -t;
} else if (t <= 8.2e+235) {
tmp = y * (x / z);
} else {
tmp = t * (x / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.5e+193: tmp = x * -t elif t <= 8.2e+235: tmp = y * (x / z) else: tmp = t * (x / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.5e+193) tmp = Float64(x * Float64(-t)); elseif (t <= 8.2e+235) tmp = Float64(y * Float64(x / z)); else tmp = Float64(t * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.5e+193) tmp = x * -t; elseif (t <= 8.2e+235) tmp = y * (x / z); else tmp = t * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.5e+193], N[(x * (-t)), $MachinePrecision], If[LessEqual[t, 8.2e+235], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(t * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.5 \cdot 10^{+193}:\\
\;\;\;\;x \cdot \left(-t\right)\\
\mathbf{elif}\;t \leq 8.2 \cdot 10^{+235}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{x}{z}\\
\end{array}
\end{array}
if t < -1.5e193Initial program 96.3%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6456.4
Applied rewrites56.4%
Taylor expanded in y around 0
mul-1-negN/A
lift-neg.f6445.4
Applied rewrites45.4%
if -1.5e193 < t < 8.2000000000000003e235Initial program 94.2%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6474.4
Applied rewrites74.4%
Taylor expanded in y around inf
Applied rewrites67.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6467.3
Applied rewrites67.3%
if 8.2000000000000003e235 < t Initial program 95.2%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6472.7
Applied rewrites72.7%
Taylor expanded in z around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f6451.6
Applied rewrites51.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* t (/ x z)))) (if (<= z -0.016) t_1 (if (<= z 1860.0) (* x (* (- (- z) 1.0) t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = t * (x / z);
double tmp;
if (z <= -0.016) {
tmp = t_1;
} else if (z <= 1860.0) {
tmp = x * ((-z - 1.0) * t);
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = t * (x / z)
if (z <= (-0.016d0)) then
tmp = t_1
else if (z <= 1860.0d0) then
tmp = x * ((-z - 1.0d0) * t)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = t * (x / z);
double tmp;
if (z <= -0.016) {
tmp = t_1;
} else if (z <= 1860.0) {
tmp = x * ((-z - 1.0) * t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = t * (x / z) tmp = 0 if z <= -0.016: tmp = t_1 elif z <= 1860.0: tmp = x * ((-z - 1.0) * t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(t * Float64(x / z)) tmp = 0.0 if (z <= -0.016) tmp = t_1; elseif (z <= 1860.0) tmp = Float64(x * Float64(Float64(Float64(-z) - 1.0) * t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = t * (x / z); tmp = 0.0; if (z <= -0.016) tmp = t_1; elseif (z <= 1860.0) tmp = x * ((-z - 1.0) * t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.016], t$95$1, If[LessEqual[z, 1860.0], N[(x * N[(N[((-z) - 1.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -0.016:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1860:\\
\;\;\;\;x \cdot \left(\left(\left(-z\right) - 1\right) \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -0.016 or 1860 < z Initial program 97.3%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6453.3
Applied rewrites53.3%
Taylor expanded in z around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f6452.7
Applied rewrites52.7%
if -0.016 < z < 1860Initial program 91.6%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6433.8
Applied rewrites33.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lift-neg.f64N/A
mul-1-negN/A
lift-neg.f6433.2
Applied rewrites33.2%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f6433.2
Applied rewrites33.2%
(FPCore (x y z t) :precision binary64 (* x (- t)))
double code(double x, double y, double z, double t) {
return x * -t;
}
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 * -t
end function
public static double code(double x, double y, double z, double t) {
return x * -t;
}
def code(x, y, z, t): return x * -t
function code(x, y, z, t) return Float64(x * Float64(-t)) end
function tmp = code(x, y, z, t) tmp = x * -t; end
code[x_, y_, z_, t_] := N[(x * (-t)), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(-t\right)
\end{array}
Initial program 94.4%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6464.6
Applied rewrites64.6%
Taylor expanded in y around 0
mul-1-negN/A
lift-neg.f6423.3
Applied rewrites23.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z))))))
(t_2 (* x (- (/ y z) (/ t (- 1.0 z))))))
(if (< t_2 -7.623226303312042e-196)
t_1
(if (< t_2 1.4133944927702302e-211)
(+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z))))
t_1))))
double code(double x, double y, double z, double t) {
double t_1 = x * ((y / z) - (t * (1.0 / (1.0 - z))));
double t_2 = x * ((y / z) - (t / (1.0 - z)));
double tmp;
if (t_2 < -7.623226303312042e-196) {
tmp = t_1;
} else if (t_2 < 1.4133944927702302e-211) {
tmp = ((y * x) / z) + -((t * x) / (1.0 - z));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x * ((y / z) - (t * (1.0d0 / (1.0d0 - z))))
t_2 = x * ((y / z) - (t / (1.0d0 - z)))
if (t_2 < (-7.623226303312042d-196)) then
tmp = t_1
else if (t_2 < 1.4133944927702302d-211) then
tmp = ((y * x) / z) + -((t * x) / (1.0d0 - z))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x * ((y / z) - (t * (1.0 / (1.0 - z))));
double t_2 = x * ((y / z) - (t / (1.0 - z)));
double tmp;
if (t_2 < -7.623226303312042e-196) {
tmp = t_1;
} else if (t_2 < 1.4133944927702302e-211) {
tmp = ((y * x) / z) + -((t * x) / (1.0 - z));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * ((y / z) - (t * (1.0 / (1.0 - z)))) t_2 = x * ((y / z) - (t / (1.0 - z))) tmp = 0 if t_2 < -7.623226303312042e-196: tmp = t_1 elif t_2 < 1.4133944927702302e-211: tmp = ((y * x) / z) + -((t * x) / (1.0 - z)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x * Float64(Float64(y / z) - Float64(t * Float64(1.0 / Float64(1.0 - z))))) t_2 = Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))) tmp = 0.0 if (t_2 < -7.623226303312042e-196) tmp = t_1; elseif (t_2 < 1.4133944927702302e-211) tmp = Float64(Float64(Float64(y * x) / z) + Float64(-Float64(Float64(t * x) / Float64(1.0 - z)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * ((y / z) - (t * (1.0 / (1.0 - z)))); t_2 = x * ((y / z) - (t / (1.0 - z))); tmp = 0.0; if (t_2 < -7.623226303312042e-196) tmp = t_1; elseif (t_2 < 1.4133944927702302e-211) tmp = ((y * x) / z) + -((t * x) / (1.0 - z)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(N[(y / z), $MachinePrecision] - N[(t * N[(1.0 / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$2, -7.623226303312042e-196], t$95$1, If[Less[t$95$2, 1.4133944927702302e-211], N[(N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision] + (-N[(N[(t * x), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\
t_2 := x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\\
\mathbf{if}\;t\_2 < -7.623226303312042 \cdot 10^{-196}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 < 1.4133944927702302 \cdot 10^{-211}:\\
\;\;\;\;\frac{y \cdot x}{z} + \left(-\frac{t \cdot x}{1 - z}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2025093
(FPCore (x y z t)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
:precision binary64
:alt
(! :herbie-platform default (if (< (* x (- (/ y z) (/ t (- 1 z)))) -3811613151656021/5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* x (- (/ y z) (* t (/ 1 (- 1 z))))) (if (< (* x (- (/ y z) (/ t (- 1 z)))) 7066972463851151/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (/ (* y x) z) (- (/ (* t x) (- 1 z)))) (* x (- (/ y z) (* t (/ 1 (- 1 z))))))))
(* x (- (/ y z) (/ t (- 1.0 z)))))