
(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}
Sampling outcomes in binary64 precision:
Herbie found 12 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 z) (/ t (- 1.0 z)))))
(if (<= t_1 (- INFINITY))
(* (/ x z) y)
(if (<= t_1 2e+299) (* x t_1) (/ (* x y) z)))))
double code(double x, double y, double z, double t) {
double t_1 = (y / z) - (t / (1.0 - z));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (x / z) * y;
} else if (t_1 <= 2e+299) {
tmp = x * t_1;
} else {
tmp = (x * y) / z;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (y / z) - (t / (1.0 - z));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = (x / z) * y;
} else if (t_1 <= 2e+299) {
tmp = x * t_1;
} else {
tmp = (x * y) / z;
}
return tmp;
}
def code(x, y, z, t): t_1 = (y / z) - (t / (1.0 - z)) tmp = 0 if t_1 <= -math.inf: tmp = (x / z) * y elif t_1 <= 2e+299: tmp = x * t_1 else: tmp = (x * y) / z return tmp
function code(x, y, z, t) t_1 = Float64(Float64(y / z) - Float64(t / Float64(1.0 - z))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(x / z) * y); elseif (t_1 <= 2e+299) tmp = Float64(x * t_1); else tmp = Float64(Float64(x * y) / z); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (y / z) - (t / (1.0 - z)); tmp = 0.0; if (t_1 <= -Inf) tmp = (x / z) * y; elseif (t_1 <= 2e+299) tmp = x * t_1; else tmp = (x * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$1, 2e+299], N[(x * t$95$1), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{z} - \frac{t}{1 - z}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+299}:\\
\;\;\;\;x \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\end{array}
\end{array}
if (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < -inf.0Initial program 41.0%
lift-*.f64N/A
*-commutativeN/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6415.5
Applied rewrites15.5%
Taylor expanded in y around inf
Applied rewrites99.8%
if -inf.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < 2.0000000000000001e299Initial program 97.8%
if 2.0000000000000001e299 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) Initial program 59.0%
Taylor expanded in z around 0
Applied rewrites99.8%
Taylor expanded in y around inf
Applied rewrites99.8%
Final simplification98.0%
(FPCore (x y z t) :precision binary64 (if (<= z -9.5e+14) (/ (* (+ t y) x) z) (if (<= z 5.6e-5) (/ (* x (- y (* t z))) z) (* (+ y t) (/ x z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9.5e+14) {
tmp = ((t + y) * x) / z;
} else if (z <= 5.6e-5) {
tmp = (x * (y - (t * z))) / z;
} 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 <= (-9.5d+14)) then
tmp = ((t + y) * x) / z
else if (z <= 5.6d-5) then
tmp = (x * (y - (t * z))) / z
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 <= -9.5e+14) {
tmp = ((t + y) * x) / z;
} else if (z <= 5.6e-5) {
tmp = (x * (y - (t * z))) / z;
} else {
tmp = (y + t) * (x / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -9.5e+14: tmp = ((t + y) * x) / z elif z <= 5.6e-5: tmp = (x * (y - (t * z))) / z else: tmp = (y + t) * (x / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -9.5e+14) tmp = Float64(Float64(Float64(t + y) * x) / z); elseif (z <= 5.6e-5) tmp = Float64(Float64(x * Float64(y - Float64(t * z))) / z); else tmp = Float64(Float64(y + t) * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -9.5e+14) tmp = ((t + y) * x) / z; elseif (z <= 5.6e-5) tmp = (x * (y - (t * z))) / z; else tmp = (y + t) * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -9.5e+14], N[(N[(N[(t + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 5.6e-5], N[(N[(x * N[(y - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(y + t), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{+14}:\\
\;\;\;\;\frac{\left(t + y\right) \cdot x}{z}\\
\mathbf{elif}\;z \leq 5.6 \cdot 10^{-5}:\\
\;\;\;\;\frac{x \cdot \left(y - t \cdot z\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(y + t\right) \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -9.5e14Initial program 95.9%
Taylor expanded in z around inf
Applied rewrites84.8%
if -9.5e14 < z < 5.59999999999999992e-5Initial program 91.3%
Taylor expanded in z around 0
Applied rewrites94.1%
if 5.59999999999999992e-5 < z Initial program 96.4%
Taylor expanded in z around -inf
Applied rewrites87.2%
Final simplification90.0%
(FPCore (x y z t)
:precision binary64
(if (<= y -1.1e-81)
(/ (* x y) z)
(if (<= y -5.4e-227)
(* x (/ t z))
(if (<= y 7e-95) (* (- t) x) (* (/ x z) y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.1e-81) {
tmp = (x * y) / z;
} else if (y <= -5.4e-227) {
tmp = x * (t / z);
} else if (y <= 7e-95) {
tmp = -t * x;
} else {
tmp = (x / z) * y;
}
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.1d-81)) then
tmp = (x * y) / z
else if (y <= (-5.4d-227)) then
tmp = x * (t / z)
else if (y <= 7d-95) then
tmp = -t * x
else
tmp = (x / z) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.1e-81) {
tmp = (x * y) / z;
} else if (y <= -5.4e-227) {
tmp = x * (t / z);
} else if (y <= 7e-95) {
tmp = -t * x;
} else {
tmp = (x / z) * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.1e-81: tmp = (x * y) / z elif y <= -5.4e-227: tmp = x * (t / z) elif y <= 7e-95: tmp = -t * x else: tmp = (x / z) * y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.1e-81) tmp = Float64(Float64(x * y) / z); elseif (y <= -5.4e-227) tmp = Float64(x * Float64(t / z)); elseif (y <= 7e-95) tmp = Float64(Float64(-t) * x); else tmp = Float64(Float64(x / z) * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.1e-81) tmp = (x * y) / z; elseif (y <= -5.4e-227) tmp = x * (t / z); elseif (y <= 7e-95) tmp = -t * x; else tmp = (x / z) * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.1e-81], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, -5.4e-227], N[(x * N[(t / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7e-95], N[((-t) * x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{-81}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq -5.4 \cdot 10^{-227}:\\
\;\;\;\;x \cdot \frac{t}{z}\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-95}:\\
\;\;\;\;\left(-t\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\end{array}
\end{array}
if y < -1.1e-81Initial program 91.6%
Taylor expanded in z around 0
Applied rewrites69.6%
Taylor expanded in y around inf
Applied rewrites74.0%
if -1.1e-81 < y < -5.3999999999999999e-227Initial program 99.5%
Taylor expanded in y around 0
Applied rewrites74.1%
Taylor expanded in z around inf
Applied rewrites61.0%
if -5.3999999999999999e-227 < y < 6.9999999999999994e-95Initial program 96.7%
Taylor expanded in z around 0
Applied rewrites65.8%
Taylor expanded in y around 0
Applied rewrites56.9%
if 6.9999999999999994e-95 < y Initial program 91.4%
lift-*.f64N/A
*-commutativeN/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6444.9
Applied rewrites44.9%
Taylor expanded in y around inf
Applied rewrites75.7%
Final simplification69.0%
(FPCore (x y z t) :precision binary64 (if (or (<= z -4.2e-77) (not (<= z 2.16e+15))) (/ (* (+ t y) x) z) (* x (- (/ y z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.2e-77) || !(z <= 2.16e+15)) {
tmp = ((t + y) * x) / z;
} else {
tmp = x * ((y / 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 ((z <= (-4.2d-77)) .or. (.not. (z <= 2.16d+15))) then
tmp = ((t + y) * x) / z
else
tmp = x * ((y / z) - t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.2e-77) || !(z <= 2.16e+15)) {
tmp = ((t + y) * x) / z;
} else {
tmp = x * ((y / z) - t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -4.2e-77) or not (z <= 2.16e+15): tmp = ((t + y) * x) / z else: tmp = x * ((y / z) - t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -4.2e-77) || !(z <= 2.16e+15)) tmp = Float64(Float64(Float64(t + y) * x) / z); else tmp = Float64(x * Float64(Float64(y / z) - t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -4.2e-77) || ~((z <= 2.16e+15))) tmp = ((t + y) * x) / z; else tmp = x * ((y / z) - t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -4.2e-77], N[Not[LessEqual[z, 2.16e+15]], $MachinePrecision]], N[(N[(N[(t + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(N[(y / z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{-77} \lor \neg \left(z \leq 2.16 \cdot 10^{+15}\right):\\
\;\;\;\;\frac{\left(t + y\right) \cdot x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\
\end{array}
\end{array}
if z < -4.20000000000000031e-77 or 2.16e15 < z Initial program 94.3%
Taylor expanded in z around inf
Applied rewrites83.8%
if -4.20000000000000031e-77 < z < 2.16e15Initial program 92.8%
Taylor expanded in z around 0
Applied rewrites92.8%
Final simplification88.0%
(FPCore (x y z t) :precision binary64 (if (<= z -4.2e-77) (/ (* (+ t y) x) z) (if (<= z 2.16e+15) (* x (- (/ y z) t)) (* (+ y t) (/ x z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.2e-77) {
tmp = ((t + y) * x) / z;
} else if (z <= 2.16e+15) {
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 <= (-4.2d-77)) then
tmp = ((t + y) * x) / z
else if (z <= 2.16d+15) 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 <= -4.2e-77) {
tmp = ((t + y) * x) / z;
} else if (z <= 2.16e+15) {
tmp = x * ((y / z) - t);
} else {
tmp = (y + t) * (x / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -4.2e-77: tmp = ((t + y) * x) / z elif z <= 2.16e+15: tmp = x * ((y / z) - t) else: tmp = (y + t) * (x / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -4.2e-77) tmp = Float64(Float64(Float64(t + y) * x) / z); elseif (z <= 2.16e+15) tmp = Float64(x * Float64(Float64(y / z) - t)); else tmp = Float64(Float64(y + t) * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -4.2e-77) tmp = ((t + y) * x) / z; elseif (z <= 2.16e+15) tmp = x * ((y / z) - t); else tmp = (y + t) * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -4.2e-77], N[(N[(N[(t + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 2.16e+15], 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 -4.2 \cdot 10^{-77}:\\
\;\;\;\;\frac{\left(t + y\right) \cdot x}{z}\\
\mathbf{elif}\;z \leq 2.16 \cdot 10^{+15}:\\
\;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + t\right) \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -4.20000000000000031e-77Initial program 93.1%
Taylor expanded in z around inf
Applied rewrites83.9%
if -4.20000000000000031e-77 < z < 2.16e15Initial program 92.8%
Taylor expanded in z around 0
Applied rewrites92.8%
if 2.16e15 < z Initial program 96.3%
Taylor expanded in z around -inf
Applied rewrites86.7%
Final simplification88.6%
(FPCore (x y z t) :precision binary64 (if (<= y -1.16e-173) (/ (* (+ t y) x) z) (if (<= y 3.05e-18) (* x (/ t (- z 1.0))) (* (/ x z) y))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.16e-173) {
tmp = ((t + y) * x) / z;
} else if (y <= 3.05e-18) {
tmp = x * (t / (z - 1.0));
} else {
tmp = (x / z) * y;
}
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.16d-173)) then
tmp = ((t + y) * x) / z
else if (y <= 3.05d-18) then
tmp = x * (t / (z - 1.0d0))
else
tmp = (x / z) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.16e-173) {
tmp = ((t + y) * x) / z;
} else if (y <= 3.05e-18) {
tmp = x * (t / (z - 1.0));
} else {
tmp = (x / z) * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.16e-173: tmp = ((t + y) * x) / z elif y <= 3.05e-18: tmp = x * (t / (z - 1.0)) else: tmp = (x / z) * y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.16e-173) tmp = Float64(Float64(Float64(t + y) * x) / z); elseif (y <= 3.05e-18) tmp = Float64(x * Float64(t / Float64(z - 1.0))); else tmp = Float64(Float64(x / z) * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.16e-173) tmp = ((t + y) * x) / z; elseif (y <= 3.05e-18) tmp = x * (t / (z - 1.0)); else tmp = (x / z) * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.16e-173], N[(N[(N[(t + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 3.05e-18], N[(x * N[(t / N[(z - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.16 \cdot 10^{-173}:\\
\;\;\;\;\frac{\left(t + y\right) \cdot x}{z}\\
\mathbf{elif}\;y \leq 3.05 \cdot 10^{-18}:\\
\;\;\;\;x \cdot \frac{t}{z - 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\end{array}
\end{array}
if y < -1.16000000000000004e-173Initial program 92.8%
Taylor expanded in z around inf
Applied rewrites75.8%
if -1.16000000000000004e-173 < y < 3.0499999999999999e-18Initial program 96.7%
Taylor expanded in y around 0
Applied rewrites81.2%
if 3.0499999999999999e-18 < y Initial program 90.6%
lift-*.f64N/A
*-commutativeN/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6444.4
Applied rewrites44.4%
Taylor expanded in y around inf
Applied rewrites84.4%
Final simplification79.8%
(FPCore (x y z t) :precision binary64 (if (<= y -1.16e-173) (/ (* (+ t y) x) z) (if (<= y 4.3e-27) (* (/ x (- z 1.0)) t) (* (/ x z) y))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.16e-173) {
tmp = ((t + y) * x) / z;
} else if (y <= 4.3e-27) {
tmp = (x / (z - 1.0)) * t;
} else {
tmp = (x / z) * y;
}
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.16d-173)) then
tmp = ((t + y) * x) / z
else if (y <= 4.3d-27) then
tmp = (x / (z - 1.0d0)) * t
else
tmp = (x / z) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.16e-173) {
tmp = ((t + y) * x) / z;
} else if (y <= 4.3e-27) {
tmp = (x / (z - 1.0)) * t;
} else {
tmp = (x / z) * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.16e-173: tmp = ((t + y) * x) / z elif y <= 4.3e-27: tmp = (x / (z - 1.0)) * t else: tmp = (x / z) * y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.16e-173) tmp = Float64(Float64(Float64(t + y) * x) / z); elseif (y <= 4.3e-27) tmp = Float64(Float64(x / Float64(z - 1.0)) * t); else tmp = Float64(Float64(x / z) * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.16e-173) tmp = ((t + y) * x) / z; elseif (y <= 4.3e-27) tmp = (x / (z - 1.0)) * t; else tmp = (x / z) * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.16e-173], N[(N[(N[(t + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 4.3e-27], N[(N[(x / N[(z - 1.0), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.16 \cdot 10^{-173}:\\
\;\;\;\;\frac{\left(t + y\right) \cdot x}{z}\\
\mathbf{elif}\;y \leq 4.3 \cdot 10^{-27}:\\
\;\;\;\;\frac{x}{z - 1} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\end{array}
\end{array}
if y < -1.16000000000000004e-173Initial program 92.8%
Taylor expanded in z around inf
Applied rewrites75.8%
if -1.16000000000000004e-173 < y < 4.30000000000000002e-27Initial program 96.6%
Taylor expanded in y around inf
Applied rewrites59.7%
Taylor expanded in y around 0
Applied rewrites78.6%
if 4.30000000000000002e-27 < y Initial program 90.9%
lift-*.f64N/A
*-commutativeN/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6443.0
Applied rewrites43.0%
Taylor expanded in y around inf
Applied rewrites83.4%
Final simplification78.6%
(FPCore (x y z t) :precision binary64 (if (<= y -1.1e-89) (/ (* x y) z) (if (<= y 4.3e-27) (* (/ x (- z 1.0)) t) (* (/ x z) y))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.1e-89) {
tmp = (x * y) / z;
} else if (y <= 4.3e-27) {
tmp = (x / (z - 1.0)) * t;
} else {
tmp = (x / z) * y;
}
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.1d-89)) then
tmp = (x * y) / z
else if (y <= 4.3d-27) then
tmp = (x / (z - 1.0d0)) * t
else
tmp = (x / z) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.1e-89) {
tmp = (x * y) / z;
} else if (y <= 4.3e-27) {
tmp = (x / (z - 1.0)) * t;
} else {
tmp = (x / z) * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.1e-89: tmp = (x * y) / z elif y <= 4.3e-27: tmp = (x / (z - 1.0)) * t else: tmp = (x / z) * y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.1e-89) tmp = Float64(Float64(x * y) / z); elseif (y <= 4.3e-27) tmp = Float64(Float64(x / Float64(z - 1.0)) * t); else tmp = Float64(Float64(x / z) * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.1e-89) tmp = (x * y) / z; elseif (y <= 4.3e-27) tmp = (x / (z - 1.0)) * t; else tmp = (x / z) * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.1e-89], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 4.3e-27], N[(N[(x / N[(z - 1.0), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{-89}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 4.3 \cdot 10^{-27}:\\
\;\;\;\;\frac{x}{z - 1} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\end{array}
\end{array}
if y < -1.10000000000000006e-89Initial program 91.8%
Taylor expanded in z around 0
Applied rewrites69.2%
Taylor expanded in y around inf
Applied rewrites73.5%
if -1.10000000000000006e-89 < y < 4.30000000000000002e-27Initial program 97.0%
Taylor expanded in y around inf
Applied rewrites63.3%
Taylor expanded in y around 0
Applied rewrites75.0%
if 4.30000000000000002e-27 < y Initial program 90.9%
lift-*.f64N/A
*-commutativeN/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6443.0
Applied rewrites43.0%
Taylor expanded in y around inf
Applied rewrites83.4%
Final simplification76.5%
(FPCore (x y z t) :precision binary64 (if (or (<= y -5.5e-174) (not (<= y 1.6e-70))) (/ (* x y) z) (* (- t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -5.5e-174) || !(y <= 1.6e-70)) {
tmp = (x * y) / z;
} else {
tmp = -t * x;
}
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 <= (-5.5d-174)) .or. (.not. (y <= 1.6d-70))) then
tmp = (x * y) / z
else
tmp = -t * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -5.5e-174) || !(y <= 1.6e-70)) {
tmp = (x * y) / z;
} else {
tmp = -t * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -5.5e-174) or not (y <= 1.6e-70): tmp = (x * y) / z else: tmp = -t * x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -5.5e-174) || !(y <= 1.6e-70)) tmp = Float64(Float64(x * y) / z); else tmp = Float64(Float64(-t) * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -5.5e-174) || ~((y <= 1.6e-70))) tmp = (x * y) / z; else tmp = -t * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -5.5e-174], N[Not[LessEqual[y, 1.6e-70]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], N[((-t) * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{-174} \lor \neg \left(y \leq 1.6 \cdot 10^{-70}\right):\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(-t\right) \cdot x\\
\end{array}
\end{array}
if y < -5.4999999999999999e-174 or 1.5999999999999999e-70 < y Initial program 91.9%
Taylor expanded in z around 0
Applied rewrites65.9%
Taylor expanded in y around inf
Applied rewrites72.1%
if -5.4999999999999999e-174 < y < 1.5999999999999999e-70Initial program 97.5%
Taylor expanded in z around 0
Applied rewrites61.5%
Taylor expanded in y around 0
Applied rewrites52.6%
Final simplification66.0%
(FPCore (x y z t) :precision binary64 (if (or (<= z -9.5e+14) (not (<= z 3.1e+24))) (* (/ x z) t) (* (- x) (fma t z t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -9.5e+14) || !(z <= 3.1e+24)) {
tmp = (x / z) * t;
} else {
tmp = -x * fma(t, z, t);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -9.5e+14) || !(z <= 3.1e+24)) tmp = Float64(Float64(x / z) * t); else tmp = Float64(Float64(-x) * fma(t, z, t)); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -9.5e+14], N[Not[LessEqual[z, 3.1e+24]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] * t), $MachinePrecision], N[((-x) * N[(t * z + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{+14} \lor \neg \left(z \leq 3.1 \cdot 10^{+24}\right):\\
\;\;\;\;\frac{x}{z} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \mathsf{fma}\left(t, z, t\right)\\
\end{array}
\end{array}
if z < -9.5e14 or 3.10000000000000011e24 < z Initial program 96.0%
Taylor expanded in y around inf
Applied rewrites73.7%
Taylor expanded in y around 0
Applied rewrites53.6%
Taylor expanded in z around inf
Applied rewrites53.6%
if -9.5e14 < z < 3.10000000000000011e24Initial program 91.5%
Taylor expanded in z around 0
Applied rewrites89.3%
Taylor expanded in y around 0
Applied rewrites39.2%
Final simplification46.0%
(FPCore (x y z t) :precision binary64 (if (<= y -5.5e-174) (/ (* x y) z) (if (<= y 7e-95) (* (- t) x) (* (/ x z) y))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.5e-174) {
tmp = (x * y) / z;
} else if (y <= 7e-95) {
tmp = -t * x;
} else {
tmp = (x / z) * y;
}
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 <= (-5.5d-174)) then
tmp = (x * y) / z
else if (y <= 7d-95) then
tmp = -t * x
else
tmp = (x / z) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.5e-174) {
tmp = (x * y) / z;
} else if (y <= 7e-95) {
tmp = -t * x;
} else {
tmp = (x / z) * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -5.5e-174: tmp = (x * y) / z elif y <= 7e-95: tmp = -t * x else: tmp = (x / z) * y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -5.5e-174) tmp = Float64(Float64(x * y) / z); elseif (y <= 7e-95) tmp = Float64(Float64(-t) * x); else tmp = Float64(Float64(x / z) * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -5.5e-174) tmp = (x * y) / z; elseif (y <= 7e-95) tmp = -t * x; else tmp = (x / z) * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -5.5e-174], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 7e-95], N[((-t) * x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{-174}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-95}:\\
\;\;\;\;\left(-t\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\end{array}
\end{array}
if y < -5.4999999999999999e-174Initial program 92.8%
Taylor expanded in z around 0
Applied rewrites65.1%
Taylor expanded in y around inf
Applied rewrites69.6%
if -5.4999999999999999e-174 < y < 6.9999999999999994e-95Initial program 97.2%
Taylor expanded in z around 0
Applied rewrites63.1%
Taylor expanded in y around 0
Applied rewrites54.6%
if 6.9999999999999994e-95 < y Initial program 91.4%
lift-*.f64N/A
*-commutativeN/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6444.9
Applied rewrites44.9%
Taylor expanded in y around inf
Applied rewrites75.7%
Final simplification67.2%
(FPCore (x y z t) :precision binary64 (* (- t) x))
double code(double x, double y, double z, double t) {
return -t * x;
}
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 = -t * x
end function
public static double code(double x, double y, double z, double t) {
return -t * x;
}
def code(x, y, z, t): return -t * x
function code(x, y, z, t) return Float64(Float64(-t) * x) end
function tmp = code(x, y, z, t) tmp = -t * x; end
code[x_, y_, z_, t_] := N[((-t) * x), $MachinePrecision]
\begin{array}{l}
\\
\left(-t\right) \cdot x
\end{array}
Initial program 93.6%
Taylor expanded in z around 0
Applied rewrites64.5%
Taylor expanded in y around 0
Applied rewrites26.8%
(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 2025021
(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)))))