
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
double code(double x, double y, double z) {
return 2.0 * sqrt((((x * y) + (x * z)) + (y * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
end function
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
def code(x, y, z): return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
function code(x, y, z) return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))) end
function tmp = code(x, y, z) tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z))); end
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
double code(double x, double y, double z) {
return 2.0 * sqrt((((x * y) + (x * z)) + (y * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
end function
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
def code(x, y, z): return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
function code(x, y, z) return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))) end
function tmp = code(x, y, z) tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z))); end
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -63000000000000.0)
(* (* -2.0 (sqrt (/ y x))) x)
(if (<= y -4.4e-239)
(* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z))))
(if (<= y 3.6e-303)
(* (* 2.0 (* (sqrt (/ (* z (+ 1.0 (/ y z))) x)) -1.0)) x)
(* (* 2.0 (/ (sqrt (+ x y)) (sqrt z))) z)))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -63000000000000.0) {
tmp = (-2.0 * sqrt((y / x))) * x;
} else if (y <= -4.4e-239) {
tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
} else if (y <= 3.6e-303) {
tmp = (2.0 * (sqrt(((z * (1.0 + (y / z))) / x)) * -1.0)) * x;
} else {
tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-63000000000000.0d0)) then
tmp = ((-2.0d0) * sqrt((y / x))) * x
else if (y <= (-4.4d-239)) then
tmp = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
else if (y <= 3.6d-303) then
tmp = (2.0d0 * (sqrt(((z * (1.0d0 + (y / z))) / x)) * (-1.0d0))) * x
else
tmp = (2.0d0 * (sqrt((x + y)) / sqrt(z))) * z
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -63000000000000.0) {
tmp = (-2.0 * Math.sqrt((y / x))) * x;
} else if (y <= -4.4e-239) {
tmp = 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
} else if (y <= 3.6e-303) {
tmp = (2.0 * (Math.sqrt(((z * (1.0 + (y / z))) / x)) * -1.0)) * x;
} else {
tmp = (2.0 * (Math.sqrt((x + y)) / Math.sqrt(z))) * z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -63000000000000.0: tmp = (-2.0 * math.sqrt((y / x))) * x elif y <= -4.4e-239: tmp = 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z))) elif y <= 3.6e-303: tmp = (2.0 * (math.sqrt(((z * (1.0 + (y / z))) / x)) * -1.0)) * x else: tmp = (2.0 * (math.sqrt((x + y)) / math.sqrt(z))) * z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -63000000000000.0) tmp = Float64(Float64(-2.0 * sqrt(Float64(y / x))) * x); elseif (y <= -4.4e-239) tmp = Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))); elseif (y <= 3.6e-303) tmp = Float64(Float64(2.0 * Float64(sqrt(Float64(Float64(z * Float64(1.0 + Float64(y / z))) / x)) * -1.0)) * x); else tmp = Float64(Float64(2.0 * Float64(sqrt(Float64(x + y)) / sqrt(z))) * z); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -63000000000000.0)
tmp = (-2.0 * sqrt((y / x))) * x;
elseif (y <= -4.4e-239)
tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
elseif (y <= 3.6e-303)
tmp = (2.0 * (sqrt(((z * (1.0 + (y / z))) / x)) * -1.0)) * x;
else
tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -63000000000000.0], N[(N[(-2.0 * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, -4.4e-239], N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.6e-303], N[(N[(2.0 * N[(N[Sqrt[N[(N[(z * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(2.0 * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -63000000000000:\\
\;\;\;\;\left(-2 \cdot \sqrt{\frac{y}{x}}\right) \cdot x\\
\mathbf{elif}\;y \leq -4.4 \cdot 10^{-239}:\\
\;\;\;\;2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-303}:\\
\;\;\;\;\left(2 \cdot \left(\sqrt{\frac{z \cdot \left(1 + \frac{y}{z}\right)}{x}} \cdot -1\right)\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < -6.3e13Initial program 41.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.6%
Taylor expanded in x around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
if -6.3e13 < y < -4.39999999999999965e-239Initial program 96.5%
if -4.39999999999999965e-239 < y < 3.5999999999999998e-303Initial program 65.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.7%
Taylor expanded in x around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6458.6
Applied rewrites58.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lift-/.f6458.6
Applied rewrites58.6%
if 3.5999999999999998e-303 < y Initial program 71.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites77.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6487.6
Applied rewrites87.6%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-+.f64N/A
lift-sqrt.f6499.3
Applied rewrites99.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -63000000000000.0)
(* (* -2.0 (sqrt (/ y x))) x)
(if (<= y -4.4e-239)
(* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z))))
(if (<= y 3.6e-303)
(* (* -2.0 (sqrt (/ (+ y z) x))) x)
(* (* 2.0 (/ (sqrt (+ x y)) (sqrt z))) z)))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -63000000000000.0) {
tmp = (-2.0 * sqrt((y / x))) * x;
} else if (y <= -4.4e-239) {
tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
} else if (y <= 3.6e-303) {
tmp = (-2.0 * sqrt(((y + z) / x))) * x;
} else {
tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-63000000000000.0d0)) then
tmp = ((-2.0d0) * sqrt((y / x))) * x
else if (y <= (-4.4d-239)) then
tmp = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
else if (y <= 3.6d-303) then
tmp = ((-2.0d0) * sqrt(((y + z) / x))) * x
else
tmp = (2.0d0 * (sqrt((x + y)) / sqrt(z))) * z
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -63000000000000.0) {
tmp = (-2.0 * Math.sqrt((y / x))) * x;
} else if (y <= -4.4e-239) {
tmp = 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
} else if (y <= 3.6e-303) {
tmp = (-2.0 * Math.sqrt(((y + z) / x))) * x;
} else {
tmp = (2.0 * (Math.sqrt((x + y)) / Math.sqrt(z))) * z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -63000000000000.0: tmp = (-2.0 * math.sqrt((y / x))) * x elif y <= -4.4e-239: tmp = 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z))) elif y <= 3.6e-303: tmp = (-2.0 * math.sqrt(((y + z) / x))) * x else: tmp = (2.0 * (math.sqrt((x + y)) / math.sqrt(z))) * z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -63000000000000.0) tmp = Float64(Float64(-2.0 * sqrt(Float64(y / x))) * x); elseif (y <= -4.4e-239) tmp = Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))); elseif (y <= 3.6e-303) tmp = Float64(Float64(-2.0 * sqrt(Float64(Float64(y + z) / x))) * x); else tmp = Float64(Float64(2.0 * Float64(sqrt(Float64(x + y)) / sqrt(z))) * z); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -63000000000000.0)
tmp = (-2.0 * sqrt((y / x))) * x;
elseif (y <= -4.4e-239)
tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
elseif (y <= 3.6e-303)
tmp = (-2.0 * sqrt(((y + z) / x))) * x;
else
tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -63000000000000.0], N[(N[(-2.0 * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, -4.4e-239], N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.6e-303], N[(N[(-2.0 * N[Sqrt[N[(N[(y + z), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(2.0 * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -63000000000000:\\
\;\;\;\;\left(-2 \cdot \sqrt{\frac{y}{x}}\right) \cdot x\\
\mathbf{elif}\;y \leq -4.4 \cdot 10^{-239}:\\
\;\;\;\;2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-303}:\\
\;\;\;\;\left(-2 \cdot \sqrt{\frac{y + z}{x}}\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < -6.3e13Initial program 41.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.6%
Taylor expanded in x around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
if -6.3e13 < y < -4.39999999999999965e-239Initial program 96.5%
if -4.39999999999999965e-239 < y < 3.5999999999999998e-303Initial program 65.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.7%
Taylor expanded in x around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6458.6
Applied rewrites58.6%
Taylor expanded in x around 0
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-sqrt.f6458.6
Applied rewrites58.6%
if 3.5999999999999998e-303 < y Initial program 71.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites77.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6487.6
Applied rewrites87.6%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-+.f64N/A
lift-sqrt.f6499.3
Applied rewrites99.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -63000000000000.0)
(* (* -2.0 (sqrt (/ y x))) x)
(if (<= y -4.4e-239)
(* 2.0 (sqrt (* (+ z y) x)))
(if (<= y 3.6e-303)
(* (* -2.0 (sqrt (/ (+ y z) x))) x)
(* (* 2.0 (/ (sqrt (+ x y)) (sqrt z))) z)))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -63000000000000.0) {
tmp = (-2.0 * sqrt((y / x))) * x;
} else if (y <= -4.4e-239) {
tmp = 2.0 * sqrt(((z + y) * x));
} else if (y <= 3.6e-303) {
tmp = (-2.0 * sqrt(((y + z) / x))) * x;
} else {
tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-63000000000000.0d0)) then
tmp = ((-2.0d0) * sqrt((y / x))) * x
else if (y <= (-4.4d-239)) then
tmp = 2.0d0 * sqrt(((z + y) * x))
else if (y <= 3.6d-303) then
tmp = ((-2.0d0) * sqrt(((y + z) / x))) * x
else
tmp = (2.0d0 * (sqrt((x + y)) / sqrt(z))) * z
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -63000000000000.0) {
tmp = (-2.0 * Math.sqrt((y / x))) * x;
} else if (y <= -4.4e-239) {
tmp = 2.0 * Math.sqrt(((z + y) * x));
} else if (y <= 3.6e-303) {
tmp = (-2.0 * Math.sqrt(((y + z) / x))) * x;
} else {
tmp = (2.0 * (Math.sqrt((x + y)) / Math.sqrt(z))) * z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -63000000000000.0: tmp = (-2.0 * math.sqrt((y / x))) * x elif y <= -4.4e-239: tmp = 2.0 * math.sqrt(((z + y) * x)) elif y <= 3.6e-303: tmp = (-2.0 * math.sqrt(((y + z) / x))) * x else: tmp = (2.0 * (math.sqrt((x + y)) / math.sqrt(z))) * z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -63000000000000.0) tmp = Float64(Float64(-2.0 * sqrt(Float64(y / x))) * x); elseif (y <= -4.4e-239) tmp = Float64(2.0 * sqrt(Float64(Float64(z + y) * x))); elseif (y <= 3.6e-303) tmp = Float64(Float64(-2.0 * sqrt(Float64(Float64(y + z) / x))) * x); else tmp = Float64(Float64(2.0 * Float64(sqrt(Float64(x + y)) / sqrt(z))) * z); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -63000000000000.0)
tmp = (-2.0 * sqrt((y / x))) * x;
elseif (y <= -4.4e-239)
tmp = 2.0 * sqrt(((z + y) * x));
elseif (y <= 3.6e-303)
tmp = (-2.0 * sqrt(((y + z) / x))) * x;
else
tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -63000000000000.0], N[(N[(-2.0 * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, -4.4e-239], N[(2.0 * N[Sqrt[N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.6e-303], N[(N[(-2.0 * N[Sqrt[N[(N[(y + z), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(2.0 * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -63000000000000:\\
\;\;\;\;\left(-2 \cdot \sqrt{\frac{y}{x}}\right) \cdot x\\
\mathbf{elif}\;y \leq -4.4 \cdot 10^{-239}:\\
\;\;\;\;2 \cdot \sqrt{\left(z + y\right) \cdot x}\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-303}:\\
\;\;\;\;\left(-2 \cdot \sqrt{\frac{y + z}{x}}\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < -6.3e13Initial program 41.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.6%
Taylor expanded in x around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
if -6.3e13 < y < -4.39999999999999965e-239Initial program 96.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6496.5
Applied rewrites96.5%
if -4.39999999999999965e-239 < y < 3.5999999999999998e-303Initial program 65.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.7%
Taylor expanded in x around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6458.6
Applied rewrites58.6%
Taylor expanded in x around 0
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-sqrt.f6458.6
Applied rewrites58.6%
if 3.5999999999999998e-303 < y Initial program 71.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites77.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6487.6
Applied rewrites87.6%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-+.f64N/A
lift-sqrt.f6499.3
Applied rewrites99.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -1.5e-59)
(* (* -2.0 (sqrt (/ y x))) x)
(if (<= y -1.5e-289)
(*
2.0
(exp
(* (+ (log (fma -1.0 x (* -1.0 z))) (* -1.0 (log (/ -1.0 y)))) 0.5)))
(* (* 2.0 (/ (sqrt (+ x y)) (sqrt z))) z))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.5e-59) {
tmp = (-2.0 * sqrt((y / x))) * x;
} else if (y <= -1.5e-289) {
tmp = 2.0 * exp(((log(fma(-1.0, x, (-1.0 * z))) + (-1.0 * log((-1.0 / y)))) * 0.5));
} else {
tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.5e-59) tmp = Float64(Float64(-2.0 * sqrt(Float64(y / x))) * x); elseif (y <= -1.5e-289) tmp = Float64(2.0 * exp(Float64(Float64(log(fma(-1.0, x, Float64(-1.0 * z))) + Float64(-1.0 * log(Float64(-1.0 / y)))) * 0.5))); else tmp = Float64(Float64(2.0 * Float64(sqrt(Float64(x + y)) / sqrt(z))) * z); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -1.5e-59], N[(N[(-2.0 * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, -1.5e-289], N[(2.0 * N[Exp[N[(N[(N[Log[N[(-1.0 * x + N[(-1.0 * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-1.0 * N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{-59}:\\
\;\;\;\;\left(-2 \cdot \sqrt{\frac{y}{x}}\right) \cdot x\\
\mathbf{elif}\;y \leq -1.5 \cdot 10^{-289}:\\
\;\;\;\;2 \cdot e^{\left(\log \left(\mathsf{fma}\left(-1, x, -1 \cdot z\right)\right) + -1 \cdot \log \left(\frac{-1}{y}\right)\right) \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < -1.5e-59Initial program 57.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.8%
Taylor expanded in x around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6498.3
Applied rewrites98.3%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6496.7
Applied rewrites96.7%
if -1.5e-59 < y < -1.4999999999999999e-289Initial program 92.1%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow1/2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
Applied rewrites86.1%
Taylor expanded in y around -inf
lower-+.f64N/A
lower-log.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-/.f6487.2
Applied rewrites87.2%
if -1.4999999999999999e-289 < y Initial program 71.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites77.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6487.3
Applied rewrites87.3%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-+.f64N/A
lift-sqrt.f6499.1
Applied rewrites99.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -63000000000000.0)
(* (* -2.0 (sqrt (/ y x))) x)
(if (<= y -4.4e-239)
(* 2.0 (sqrt (* (+ z y) x)))
(if (<= y 5.4e-295)
(* (* -2.0 (sqrt (/ (+ y z) x))) x)
(* (* 2.0 (/ (sqrt y) (sqrt z))) z)))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -63000000000000.0) {
tmp = (-2.0 * sqrt((y / x))) * x;
} else if (y <= -4.4e-239) {
tmp = 2.0 * sqrt(((z + y) * x));
} else if (y <= 5.4e-295) {
tmp = (-2.0 * sqrt(((y + z) / x))) * x;
} else {
tmp = (2.0 * (sqrt(y) / sqrt(z))) * z;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-63000000000000.0d0)) then
tmp = ((-2.0d0) * sqrt((y / x))) * x
else if (y <= (-4.4d-239)) then
tmp = 2.0d0 * sqrt(((z + y) * x))
else if (y <= 5.4d-295) then
tmp = ((-2.0d0) * sqrt(((y + z) / x))) * x
else
tmp = (2.0d0 * (sqrt(y) / sqrt(z))) * z
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -63000000000000.0) {
tmp = (-2.0 * Math.sqrt((y / x))) * x;
} else if (y <= -4.4e-239) {
tmp = 2.0 * Math.sqrt(((z + y) * x));
} else if (y <= 5.4e-295) {
tmp = (-2.0 * Math.sqrt(((y + z) / x))) * x;
} else {
tmp = (2.0 * (Math.sqrt(y) / Math.sqrt(z))) * z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -63000000000000.0: tmp = (-2.0 * math.sqrt((y / x))) * x elif y <= -4.4e-239: tmp = 2.0 * math.sqrt(((z + y) * x)) elif y <= 5.4e-295: tmp = (-2.0 * math.sqrt(((y + z) / x))) * x else: tmp = (2.0 * (math.sqrt(y) / math.sqrt(z))) * z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -63000000000000.0) tmp = Float64(Float64(-2.0 * sqrt(Float64(y / x))) * x); elseif (y <= -4.4e-239) tmp = Float64(2.0 * sqrt(Float64(Float64(z + y) * x))); elseif (y <= 5.4e-295) tmp = Float64(Float64(-2.0 * sqrt(Float64(Float64(y + z) / x))) * x); else tmp = Float64(Float64(2.0 * Float64(sqrt(y) / sqrt(z))) * z); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -63000000000000.0)
tmp = (-2.0 * sqrt((y / x))) * x;
elseif (y <= -4.4e-239)
tmp = 2.0 * sqrt(((z + y) * x));
elseif (y <= 5.4e-295)
tmp = (-2.0 * sqrt(((y + z) / x))) * x;
else
tmp = (2.0 * (sqrt(y) / sqrt(z))) * z;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -63000000000000.0], N[(N[(-2.0 * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, -4.4e-239], N[(2.0 * N[Sqrt[N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.4e-295], N[(N[(-2.0 * N[Sqrt[N[(N[(y + z), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(2.0 * N[(N[Sqrt[y], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -63000000000000:\\
\;\;\;\;\left(-2 \cdot \sqrt{\frac{y}{x}}\right) \cdot x\\
\mathbf{elif}\;y \leq -4.4 \cdot 10^{-239}:\\
\;\;\;\;2 \cdot \sqrt{\left(z + y\right) \cdot x}\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{-295}:\\
\;\;\;\;\left(-2 \cdot \sqrt{\frac{y + z}{x}}\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < -6.3e13Initial program 41.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.6%
Taylor expanded in x around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
if -6.3e13 < y < -4.39999999999999965e-239Initial program 96.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6496.5
Applied rewrites96.5%
if -4.39999999999999965e-239 < y < 5.4000000000000002e-295Initial program 65.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.7%
Taylor expanded in x around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6457.9
Applied rewrites57.9%
Taylor expanded in x around 0
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-sqrt.f6457.9
Applied rewrites57.9%
if 5.4000000000000002e-295 < y Initial program 71.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6485.5
Applied rewrites85.5%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-sqrt.f6496.4
Applied rewrites96.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -63000000000000.0)
(* (* -2.0 (sqrt (/ y x))) x)
(if (<= y 1.7e-19)
(* 2.0 (sqrt (fma y x (* (+ y x) z))))
(* (* 2.0 (sqrt (/ (+ x y) z))) z))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -63000000000000.0) {
tmp = (-2.0 * sqrt((y / x))) * x;
} else if (y <= 1.7e-19) {
tmp = 2.0 * sqrt(fma(y, x, ((y + x) * z)));
} else {
tmp = (2.0 * sqrt(((x + y) / z))) * z;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -63000000000000.0) tmp = Float64(Float64(-2.0 * sqrt(Float64(y / x))) * x); elseif (y <= 1.7e-19) tmp = Float64(2.0 * sqrt(fma(y, x, Float64(Float64(y + x) * z)))); else tmp = Float64(Float64(2.0 * sqrt(Float64(Float64(x + y) / z))) * z); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -63000000000000.0], N[(N[(-2.0 * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 1.7e-19], N[(2.0 * N[Sqrt[N[(y * x + N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sqrt[N[(N[(x + y), $MachinePrecision] / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -63000000000000:\\
\;\;\;\;\left(-2 \cdot \sqrt{\frac{y}{x}}\right) \cdot x\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-19}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(y, x, \left(y + x\right) \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < -6.3e13Initial program 41.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.6%
Taylor expanded in x around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
if -6.3e13 < y < 1.7000000000000001e-19Initial program 94.1%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6494.1
Applied rewrites94.1%
if 1.7000000000000001e-19 < y Initial program 52.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.1%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6499.5
Applied rewrites99.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -63000000000000.0)
(* (* -2.0 (sqrt (/ y x))) x)
(if (<= y 5.5e-295)
(* 2.0 (sqrt (* (+ z y) x)))
(* (* 2.0 (/ (sqrt y) (sqrt z))) z))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -63000000000000.0) {
tmp = (-2.0 * sqrt((y / x))) * x;
} else if (y <= 5.5e-295) {
tmp = 2.0 * sqrt(((z + y) * x));
} else {
tmp = (2.0 * (sqrt(y) / sqrt(z))) * z;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-63000000000000.0d0)) then
tmp = ((-2.0d0) * sqrt((y / x))) * x
else if (y <= 5.5d-295) then
tmp = 2.0d0 * sqrt(((z + y) * x))
else
tmp = (2.0d0 * (sqrt(y) / sqrt(z))) * z
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -63000000000000.0) {
tmp = (-2.0 * Math.sqrt((y / x))) * x;
} else if (y <= 5.5e-295) {
tmp = 2.0 * Math.sqrt(((z + y) * x));
} else {
tmp = (2.0 * (Math.sqrt(y) / Math.sqrt(z))) * z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -63000000000000.0: tmp = (-2.0 * math.sqrt((y / x))) * x elif y <= 5.5e-295: tmp = 2.0 * math.sqrt(((z + y) * x)) else: tmp = (2.0 * (math.sqrt(y) / math.sqrt(z))) * z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -63000000000000.0) tmp = Float64(Float64(-2.0 * sqrt(Float64(y / x))) * x); elseif (y <= 5.5e-295) tmp = Float64(2.0 * sqrt(Float64(Float64(z + y) * x))); else tmp = Float64(Float64(2.0 * Float64(sqrt(y) / sqrt(z))) * z); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -63000000000000.0)
tmp = (-2.0 * sqrt((y / x))) * x;
elseif (y <= 5.5e-295)
tmp = 2.0 * sqrt(((z + y) * x));
else
tmp = (2.0 * (sqrt(y) / sqrt(z))) * z;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -63000000000000.0], N[(N[(-2.0 * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 5.5e-295], N[(2.0 * N[Sqrt[N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(N[Sqrt[y], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -63000000000000:\\
\;\;\;\;\left(-2 \cdot \sqrt{\frac{y}{x}}\right) \cdot x\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-295}:\\
\;\;\;\;2 \cdot \sqrt{\left(z + y\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < -6.3e13Initial program 41.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.6%
Taylor expanded in x around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
if -6.3e13 < y < 5.5e-295Initial program 94.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6494.0
Applied rewrites94.0%
if 5.5e-295 < y Initial program 71.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6485.5
Applied rewrites85.5%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-sqrt.f6496.4
Applied rewrites96.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -620000000000.0)
(* (* -2.0 (sqrt (/ y x))) x)
(if (<= y 3200000.0)
(* 2.0 (sqrt (* (+ z x) y)))
(* (* 2.0 (sqrt (/ y z))) z))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -620000000000.0) {
tmp = (-2.0 * sqrt((y / x))) * x;
} else if (y <= 3200000.0) {
tmp = 2.0 * sqrt(((z + x) * y));
} else {
tmp = (2.0 * sqrt((y / z))) * z;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-620000000000.0d0)) then
tmp = ((-2.0d0) * sqrt((y / x))) * x
else if (y <= 3200000.0d0) then
tmp = 2.0d0 * sqrt(((z + x) * y))
else
tmp = (2.0d0 * sqrt((y / z))) * z
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -620000000000.0) {
tmp = (-2.0 * Math.sqrt((y / x))) * x;
} else if (y <= 3200000.0) {
tmp = 2.0 * Math.sqrt(((z + x) * y));
} else {
tmp = (2.0 * Math.sqrt((y / z))) * z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -620000000000.0: tmp = (-2.0 * math.sqrt((y / x))) * x elif y <= 3200000.0: tmp = 2.0 * math.sqrt(((z + x) * y)) else: tmp = (2.0 * math.sqrt((y / z))) * z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -620000000000.0) tmp = Float64(Float64(-2.0 * sqrt(Float64(y / x))) * x); elseif (y <= 3200000.0) tmp = Float64(2.0 * sqrt(Float64(Float64(z + x) * y))); else tmp = Float64(Float64(2.0 * sqrt(Float64(y / z))) * z); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -620000000000.0)
tmp = (-2.0 * sqrt((y / x))) * x;
elseif (y <= 3200000.0)
tmp = 2.0 * sqrt(((z + x) * y));
else
tmp = (2.0 * sqrt((y / z))) * z;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -620000000000.0], N[(N[(-2.0 * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 3200000.0], N[(2.0 * N[Sqrt[N[(N[(z + x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -620000000000:\\
\;\;\;\;\left(-2 \cdot \sqrt{\frac{y}{x}}\right) \cdot x\\
\mathbf{elif}\;y \leq 3200000:\\
\;\;\;\;2 \cdot \sqrt{\left(z + x\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < -6.2e11Initial program 42.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.6%
Taylor expanded in x around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6497.9
Applied rewrites97.9%
if -6.2e11 < y < 3.2e6Initial program 94.5%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6490.9
Applied rewrites90.9%
if 3.2e6 < y Initial program 46.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6498.2
Applied rewrites98.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 3200000.0) (* 2.0 (sqrt (* (+ z x) y))) (* (* 2.0 (sqrt (/ y z))) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 3200000.0) {
tmp = 2.0 * sqrt(((z + x) * y));
} else {
tmp = (2.0 * sqrt((y / z))) * z;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 3200000.0d0) then
tmp = 2.0d0 * sqrt(((z + x) * y))
else
tmp = (2.0d0 * sqrt((y / z))) * z
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3200000.0) {
tmp = 2.0 * Math.sqrt(((z + x) * y));
} else {
tmp = (2.0 * Math.sqrt((y / z))) * z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= 3200000.0: tmp = 2.0 * math.sqrt(((z + x) * y)) else: tmp = (2.0 * math.sqrt((y / z))) * z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 3200000.0) tmp = Float64(2.0 * sqrt(Float64(Float64(z + x) * y))); else tmp = Float64(Float64(2.0 * sqrt(Float64(y / z))) * z); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= 3200000.0)
tmp = 2.0 * sqrt(((z + x) * y));
else
tmp = (2.0 * sqrt((y / z))) * z;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 3200000.0], N[(2.0 * N[Sqrt[N[(N[(z + x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3200000:\\
\;\;\;\;2 \cdot \sqrt{\left(z + x\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < 3.2e6Initial program 78.2%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6475.5
Applied rewrites75.5%
if 3.2e6 < y Initial program 46.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6498.2
Applied rewrites98.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -2.1e-286) (* 2.0 (sqrt (* y x))) (* 2.0 (sqrt (* (+ y x) z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -2.1e-286) {
tmp = 2.0 * sqrt((y * x));
} else {
tmp = 2.0 * sqrt(((y + x) * z));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-2.1d-286)) then
tmp = 2.0d0 * sqrt((y * x))
else
tmp = 2.0d0 * sqrt(((y + x) * z))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.1e-286) {
tmp = 2.0 * Math.sqrt((y * x));
} else {
tmp = 2.0 * Math.sqrt(((y + x) * z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -2.1e-286: tmp = 2.0 * math.sqrt((y * x)) else: tmp = 2.0 * math.sqrt(((y + x) * z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -2.1e-286) tmp = Float64(2.0 * sqrt(Float64(y * x))); else tmp = Float64(2.0 * sqrt(Float64(Float64(y + x) * z))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -2.1e-286)
tmp = 2.0 * sqrt((y * x));
else
tmp = 2.0 * sqrt(((y + x) * z));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -2.1e-286], N[(2.0 * N[Sqrt[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{-286}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
\end{array}
\end{array}
if y < -2.09999999999999988e-286Initial program 69.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
if -2.09999999999999988e-286 < y Initial program 71.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6471.5
Applied rewrites71.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* 2.0 (sqrt (* (+ z x) y))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return 2.0 * sqrt(((z + x) * y));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt(((z + x) * y))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt(((z + x) * y));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return 2.0 * math.sqrt(((z + x) * y))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(2.0 * sqrt(Float64(Float64(z + x) * y))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = 2.0 * sqrt(((z + x) * y));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(z + x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \sqrt{\left(z + x\right) \cdot y}
\end{array}
Initial program 70.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6468.6
Applied rewrites68.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -1.56e-289) (* 2.0 (sqrt (* y x))) (* 2.0 (sqrt (* z y)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.56e-289) {
tmp = 2.0 * sqrt((y * x));
} else {
tmp = 2.0 * sqrt((z * y));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.56d-289)) then
tmp = 2.0d0 * sqrt((y * x))
else
tmp = 2.0d0 * sqrt((z * y))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.56e-289) {
tmp = 2.0 * Math.sqrt((y * x));
} else {
tmp = 2.0 * Math.sqrt((z * y));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -1.56e-289: tmp = 2.0 * math.sqrt((y * x)) else: tmp = 2.0 * math.sqrt((z * y)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.56e-289) tmp = Float64(2.0 * sqrt(Float64(y * x))); else tmp = Float64(2.0 * sqrt(Float64(z * y))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -1.56e-289)
tmp = 2.0 * sqrt((y * x));
else
tmp = 2.0 * sqrt((z * y));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -1.56e-289], N[(2.0 * N[Sqrt[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(z * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.56 \cdot 10^{-289}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot y}\\
\end{array}
\end{array}
if y < -1.55999999999999989e-289Initial program 69.7%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
if -1.55999999999999989e-289 < y Initial program 71.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f6469.3
Applied rewrites69.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* 2.0 (sqrt (* y x))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return 2.0 * sqrt((y * x));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((y * x))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((y * x));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return 2.0 * math.sqrt((y * x))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(2.0 * sqrt(Float64(y * x))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = 2.0 * sqrt((y * x));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \sqrt{y \cdot x}
\end{array}
Initial program 70.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6435.6
Applied rewrites35.6%
herbie shell --seed 2025117
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:descartes from diagrams-contrib-1.3.0.5"
:precision binary64
(* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))