
(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 -68000.0)
(* (* (sqrt (/ (+ z y) x)) x) -2.0)
(if (<= y 15.0)
(* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z))))
(* 2.0 (* z (sqrt (* (/ 1.0 z) (+ x y))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -68000.0) {
tmp = (sqrt(((z + y) / x)) * x) * -2.0;
} else if (y <= 15.0) {
tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
} else {
tmp = 2.0 * (z * sqrt(((1.0 / z) * (x + 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 <= (-68000.0d0)) then
tmp = (sqrt(((z + y) / x)) * x) * (-2.0d0)
else if (y <= 15.0d0) then
tmp = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
else
tmp = 2.0d0 * (z * sqrt(((1.0d0 / z) * (x + 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 <= -68000.0) {
tmp = (Math.sqrt(((z + y) / x)) * x) * -2.0;
} else if (y <= 15.0) {
tmp = 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
} else {
tmp = 2.0 * (z * Math.sqrt(((1.0 / z) * (x + y))));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -68000.0: tmp = (math.sqrt(((z + y) / x)) * x) * -2.0 elif y <= 15.0: tmp = 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z))) else: tmp = 2.0 * (z * math.sqrt(((1.0 / z) * (x + y)))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -68000.0) tmp = Float64(Float64(sqrt(Float64(Float64(z + y) / x)) * x) * -2.0); elseif (y <= 15.0) tmp = Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))); else tmp = Float64(2.0 * Float64(z * sqrt(Float64(Float64(1.0 / z) * Float64(x + 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 <= -68000.0)
tmp = (sqrt(((z + y) / x)) * x) * -2.0;
elseif (y <= 15.0)
tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
else
tmp = 2.0 * (z * sqrt(((1.0 / z) * (x + 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, -68000.0], N[(N[(N[Sqrt[N[(N[(z + y), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[y, 15.0], N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(z * N[Sqrt[N[(N[(1.0 / z), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -68000:\\
\;\;\;\;\left(\sqrt{\frac{z + y}{x}} \cdot x\right) \cdot -2\\
\mathbf{elif}\;y \leq 15:\\
\;\;\;\;2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(z \cdot \sqrt{\frac{1}{z} \cdot \left(x + y\right)}\right)\\
\end{array}
\end{array}
if y < -68000Initial program 70.5%
Taylor expanded in x around -inf
Applied rewrites44.3%
Applied rewrites44.3%
if -68000 < y < 15Initial program 70.5%
if 15 < y Initial program 70.5%
Taylor expanded in z around inf
Applied rewrites44.4%
Applied rewrites44.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -68000.0)
(* (* (sqrt (/ (+ z y) x)) x) -2.0)
(if (<= y 15.0)
(* 2.0 (sqrt (fma (+ z y) x (* y z))))
(* 2.0 (* z (sqrt (* (/ 1.0 z) (+ x y))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -68000.0) {
tmp = (sqrt(((z + y) / x)) * x) * -2.0;
} else if (y <= 15.0) {
tmp = 2.0 * sqrt(fma((z + y), x, (y * z)));
} else {
tmp = 2.0 * (z * sqrt(((1.0 / z) * (x + y))));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -68000.0) tmp = Float64(Float64(sqrt(Float64(Float64(z + y) / x)) * x) * -2.0); elseif (y <= 15.0) tmp = Float64(2.0 * sqrt(fma(Float64(z + y), x, Float64(y * z)))); else tmp = Float64(2.0 * Float64(z * sqrt(Float64(Float64(1.0 / z) * Float64(x + y))))); 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, -68000.0], N[(N[(N[Sqrt[N[(N[(z + y), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[y, 15.0], N[(2.0 * N[Sqrt[N[(N[(z + y), $MachinePrecision] * x + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(z * N[Sqrt[N[(N[(1.0 / z), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -68000:\\
\;\;\;\;\left(\sqrt{\frac{z + y}{x}} \cdot x\right) \cdot -2\\
\mathbf{elif}\;y \leq 15:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z + y, x, y \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(z \cdot \sqrt{\frac{1}{z} \cdot \left(x + y\right)}\right)\\
\end{array}
\end{array}
if y < -68000Initial program 70.5%
Taylor expanded in x around -inf
Applied rewrites44.3%
Applied rewrites44.3%
if -68000 < y < 15Initial program 70.5%
Applied rewrites70.6%
if 15 < y Initial program 70.5%
Taylor expanded in z around inf
Applied rewrites44.4%
Applied rewrites44.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -68000.0)
(* (* (sqrt (/ (+ z y) x)) x) -2.0)
(if (<= y 5.0)
(* 2.0 (sqrt (fma (+ z y) x (* y z))))
(* 2.0 (* z (sqrt (/ (+ x y) z)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -68000.0) {
tmp = (sqrt(((z + y) / x)) * x) * -2.0;
} else if (y <= 5.0) {
tmp = 2.0 * sqrt(fma((z + y), x, (y * z)));
} else {
tmp = 2.0 * (z * sqrt(((x + y) / z)));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -68000.0) tmp = Float64(Float64(sqrt(Float64(Float64(z + y) / x)) * x) * -2.0); elseif (y <= 5.0) tmp = Float64(2.0 * sqrt(fma(Float64(z + y), x, Float64(y * z)))); else tmp = Float64(2.0 * Float64(z * sqrt(Float64(Float64(x + y) / 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, -68000.0], N[(N[(N[Sqrt[N[(N[(z + y), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[y, 5.0], N[(2.0 * N[Sqrt[N[(N[(z + y), $MachinePrecision] * x + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(z * N[Sqrt[N[(N[(x + y), $MachinePrecision] / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -68000:\\
\;\;\;\;\left(\sqrt{\frac{z + y}{x}} \cdot x\right) \cdot -2\\
\mathbf{elif}\;y \leq 5:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z + y, x, y \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(z \cdot \sqrt{\frac{x + y}{z}}\right)\\
\end{array}
\end{array}
if y < -68000Initial program 70.5%
Taylor expanded in x around -inf
Applied rewrites44.3%
Applied rewrites44.3%
if -68000 < y < 5Initial program 70.5%
Applied rewrites70.6%
if 5 < y Initial program 70.5%
Taylor expanded in z around inf
Applied rewrites44.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -68000.0)
(* (* (sqrt (/ (+ z y) x)) x) -2.0)
(if (<= y -1.5e-303)
(* 2.0 (sqrt (* x (+ y z))))
(if (<= y 5.0)
(* 2.0 (sqrt (* z (+ x y))))
(* 2.0 (* z (sqrt (/ (+ x y) z))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -68000.0) {
tmp = (sqrt(((z + y) / x)) * x) * -2.0;
} else if (y <= -1.5e-303) {
tmp = 2.0 * sqrt((x * (y + z)));
} else if (y <= 5.0) {
tmp = 2.0 * sqrt((z * (x + y)));
} else {
tmp = 2.0 * (z * sqrt(((x + y) / 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 <= (-68000.0d0)) then
tmp = (sqrt(((z + y) / x)) * x) * (-2.0d0)
else if (y <= (-1.5d-303)) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else if (y <= 5.0d0) then
tmp = 2.0d0 * sqrt((z * (x + y)))
else
tmp = 2.0d0 * (z * sqrt(((x + y) / 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 <= -68000.0) {
tmp = (Math.sqrt(((z + y) / x)) * x) * -2.0;
} else if (y <= -1.5e-303) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else if (y <= 5.0) {
tmp = 2.0 * Math.sqrt((z * (x + y)));
} else {
tmp = 2.0 * (z * Math.sqrt(((x + y) / z)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -68000.0: tmp = (math.sqrt(((z + y) / x)) * x) * -2.0 elif y <= -1.5e-303: tmp = 2.0 * math.sqrt((x * (y + z))) elif y <= 5.0: tmp = 2.0 * math.sqrt((z * (x + y))) else: tmp = 2.0 * (z * math.sqrt(((x + y) / z))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -68000.0) tmp = Float64(Float64(sqrt(Float64(Float64(z + y) / x)) * x) * -2.0); elseif (y <= -1.5e-303) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); elseif (y <= 5.0) tmp = Float64(2.0 * sqrt(Float64(z * Float64(x + y)))); else tmp = Float64(2.0 * Float64(z * sqrt(Float64(Float64(x + y) / 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 <= -68000.0)
tmp = (sqrt(((z + y) / x)) * x) * -2.0;
elseif (y <= -1.5e-303)
tmp = 2.0 * sqrt((x * (y + z)));
elseif (y <= 5.0)
tmp = 2.0 * sqrt((z * (x + y)));
else
tmp = 2.0 * (z * sqrt(((x + y) / 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, -68000.0], N[(N[(N[Sqrt[N[(N[(z + y), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[y, -1.5e-303], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.0], N[(2.0 * N[Sqrt[N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(z * N[Sqrt[N[(N[(x + y), $MachinePrecision] / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -68000:\\
\;\;\;\;\left(\sqrt{\frac{z + y}{x}} \cdot x\right) \cdot -2\\
\mathbf{elif}\;y \leq -1.5 \cdot 10^{-303}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{elif}\;y \leq 5:\\
\;\;\;\;2 \cdot \sqrt{z \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(z \cdot \sqrt{\frac{x + y}{z}}\right)\\
\end{array}
\end{array}
if y < -68000Initial program 70.5%
Taylor expanded in x around -inf
Applied rewrites44.3%
Applied rewrites44.3%
if -68000 < y < -1.50000000000000014e-303Initial program 70.5%
Applied rewrites70.6%
Taylor expanded in x around inf
Applied rewrites36.7%
if -1.50000000000000014e-303 < y < 5Initial program 70.5%
Taylor expanded in z around inf
Applied rewrites37.5%
if 5 < y Initial program 70.5%
Taylor expanded in z around inf
Applied rewrites44.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -68000.0)
(* (* (sqrt (/ (+ z y) x)) x) -2.0)
(if (<= y -1.5e-303)
(* 2.0 (sqrt (* x (+ y z))))
(if (<= y 1e-10)
(* 2.0 (sqrt (* z (+ x y))))
(* 2.0 (* y (sqrt (/ z y))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -68000.0) {
tmp = (sqrt(((z + y) / x)) * x) * -2.0;
} else if (y <= -1.5e-303) {
tmp = 2.0 * sqrt((x * (y + z)));
} else if (y <= 1e-10) {
tmp = 2.0 * sqrt((z * (x + y)));
} else {
tmp = 2.0 * (y * 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 <= (-68000.0d0)) then
tmp = (sqrt(((z + y) / x)) * x) * (-2.0d0)
else if (y <= (-1.5d-303)) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else if (y <= 1d-10) then
tmp = 2.0d0 * sqrt((z * (x + y)))
else
tmp = 2.0d0 * (y * 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 <= -68000.0) {
tmp = (Math.sqrt(((z + y) / x)) * x) * -2.0;
} else if (y <= -1.5e-303) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else if (y <= 1e-10) {
tmp = 2.0 * Math.sqrt((z * (x + y)));
} else {
tmp = 2.0 * (y * Math.sqrt((z / y)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -68000.0: tmp = (math.sqrt(((z + y) / x)) * x) * -2.0 elif y <= -1.5e-303: tmp = 2.0 * math.sqrt((x * (y + z))) elif y <= 1e-10: tmp = 2.0 * math.sqrt((z * (x + y))) else: tmp = 2.0 * (y * math.sqrt((z / y))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -68000.0) tmp = Float64(Float64(sqrt(Float64(Float64(z + y) / x)) * x) * -2.0); elseif (y <= -1.5e-303) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); elseif (y <= 1e-10) tmp = Float64(2.0 * sqrt(Float64(z * Float64(x + y)))); else tmp = Float64(2.0 * Float64(y * 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 <= -68000.0)
tmp = (sqrt(((z + y) / x)) * x) * -2.0;
elseif (y <= -1.5e-303)
tmp = 2.0 * sqrt((x * (y + z)));
elseif (y <= 1e-10)
tmp = 2.0 * sqrt((z * (x + y)));
else
tmp = 2.0 * (y * 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, -68000.0], N[(N[(N[Sqrt[N[(N[(z + y), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[y, -1.5e-303], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e-10], N[(2.0 * N[Sqrt[N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[Sqrt[N[(z / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -68000:\\
\;\;\;\;\left(\sqrt{\frac{z + y}{x}} \cdot x\right) \cdot -2\\
\mathbf{elif}\;y \leq -1.5 \cdot 10^{-303}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{elif}\;y \leq 10^{-10}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \sqrt{\frac{z}{y}}\right)\\
\end{array}
\end{array}
if y < -68000Initial program 70.5%
Taylor expanded in x around -inf
Applied rewrites44.3%
Applied rewrites44.3%
if -68000 < y < -1.50000000000000014e-303Initial program 70.5%
Applied rewrites70.6%
Taylor expanded in x around inf
Applied rewrites36.7%
if -1.50000000000000014e-303 < y < 1.00000000000000004e-10Initial program 70.5%
Taylor expanded in z around inf
Applied rewrites37.5%
if 1.00000000000000004e-10 < y Initial program 70.5%
Taylor expanded in y around inf
Applied rewrites42.9%
Taylor expanded in x around 0
Applied rewrites42.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -70000.0)
(* 2.0 (* (sqrt (/ x y)) (- y)))
(if (<= y -1.5e-303)
(* 2.0 (sqrt (* x (+ y z))))
(if (<= y 1e-10)
(* 2.0 (sqrt (* z (+ x y))))
(* 2.0 (* y (sqrt (/ z y))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -70000.0) {
tmp = 2.0 * (sqrt((x / y)) * -y);
} else if (y <= -1.5e-303) {
tmp = 2.0 * sqrt((x * (y + z)));
} else if (y <= 1e-10) {
tmp = 2.0 * sqrt((z * (x + y)));
} else {
tmp = 2.0 * (y * 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 <= (-70000.0d0)) then
tmp = 2.0d0 * (sqrt((x / y)) * -y)
else if (y <= (-1.5d-303)) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else if (y <= 1d-10) then
tmp = 2.0d0 * sqrt((z * (x + y)))
else
tmp = 2.0d0 * (y * 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 <= -70000.0) {
tmp = 2.0 * (Math.sqrt((x / y)) * -y);
} else if (y <= -1.5e-303) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else if (y <= 1e-10) {
tmp = 2.0 * Math.sqrt((z * (x + y)));
} else {
tmp = 2.0 * (y * Math.sqrt((z / y)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -70000.0: tmp = 2.0 * (math.sqrt((x / y)) * -y) elif y <= -1.5e-303: tmp = 2.0 * math.sqrt((x * (y + z))) elif y <= 1e-10: tmp = 2.0 * math.sqrt((z * (x + y))) else: tmp = 2.0 * (y * math.sqrt((z / y))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -70000.0) tmp = Float64(2.0 * Float64(sqrt(Float64(x / y)) * Float64(-y))); elseif (y <= -1.5e-303) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); elseif (y <= 1e-10) tmp = Float64(2.0 * sqrt(Float64(z * Float64(x + y)))); else tmp = Float64(2.0 * Float64(y * 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 <= -70000.0)
tmp = 2.0 * (sqrt((x / y)) * -y);
elseif (y <= -1.5e-303)
tmp = 2.0 * sqrt((x * (y + z)));
elseif (y <= 1e-10)
tmp = 2.0 * sqrt((z * (x + y)));
else
tmp = 2.0 * (y * 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, -70000.0], N[(2.0 * N[(N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision] * (-y)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.5e-303], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e-10], N[(2.0 * N[Sqrt[N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[Sqrt[N[(z / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -70000:\\
\;\;\;\;2 \cdot \left(\sqrt{\frac{x}{y}} \cdot \left(-y\right)\right)\\
\mathbf{elif}\;y \leq -1.5 \cdot 10^{-303}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{elif}\;y \leq 10^{-10}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \sqrt{\frac{z}{y}}\right)\\
\end{array}
\end{array}
if y < -7e4Initial program 70.5%
Taylor expanded in z around 0
Applied rewrites35.2%
Taylor expanded in y around -inf
Applied rewrites43.0%
Applied rewrites43.0%
if -7e4 < y < -1.50000000000000014e-303Initial program 70.5%
Applied rewrites70.6%
Taylor expanded in x around inf
Applied rewrites36.7%
if -1.50000000000000014e-303 < y < 1.00000000000000004e-10Initial program 70.5%
Taylor expanded in z around inf
Applied rewrites37.5%
if 1.00000000000000004e-10 < y Initial program 70.5%
Taylor expanded in y around inf
Applied rewrites42.9%
Taylor expanded in x around 0
Applied rewrites42.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -68000.0)
(* -2.0 (* x (sqrt (/ y x))))
(if (<= y -1.5e-303)
(* 2.0 (sqrt (* x (+ y z))))
(if (<= y 1e-10)
(* 2.0 (sqrt (* z (+ x y))))
(* 2.0 (* y (sqrt (/ z y))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -68000.0) {
tmp = -2.0 * (x * sqrt((y / x)));
} else if (y <= -1.5e-303) {
tmp = 2.0 * sqrt((x * (y + z)));
} else if (y <= 1e-10) {
tmp = 2.0 * sqrt((z * (x + y)));
} else {
tmp = 2.0 * (y * 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 <= (-68000.0d0)) then
tmp = (-2.0d0) * (x * sqrt((y / x)))
else if (y <= (-1.5d-303)) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else if (y <= 1d-10) then
tmp = 2.0d0 * sqrt((z * (x + y)))
else
tmp = 2.0d0 * (y * 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 <= -68000.0) {
tmp = -2.0 * (x * Math.sqrt((y / x)));
} else if (y <= -1.5e-303) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else if (y <= 1e-10) {
tmp = 2.0 * Math.sqrt((z * (x + y)));
} else {
tmp = 2.0 * (y * Math.sqrt((z / y)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -68000.0: tmp = -2.0 * (x * math.sqrt((y / x))) elif y <= -1.5e-303: tmp = 2.0 * math.sqrt((x * (y + z))) elif y <= 1e-10: tmp = 2.0 * math.sqrt((z * (x + y))) else: tmp = 2.0 * (y * math.sqrt((z / y))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -68000.0) tmp = Float64(-2.0 * Float64(x * sqrt(Float64(y / x)))); elseif (y <= -1.5e-303) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); elseif (y <= 1e-10) tmp = Float64(2.0 * sqrt(Float64(z * Float64(x + y)))); else tmp = Float64(2.0 * Float64(y * 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 <= -68000.0)
tmp = -2.0 * (x * sqrt((y / x)));
elseif (y <= -1.5e-303)
tmp = 2.0 * sqrt((x * (y + z)));
elseif (y <= 1e-10)
tmp = 2.0 * sqrt((z * (x + y)));
else
tmp = 2.0 * (y * 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, -68000.0], N[(-2.0 * N[(x * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.5e-303], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e-10], N[(2.0 * N[Sqrt[N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[Sqrt[N[(z / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -68000:\\
\;\;\;\;-2 \cdot \left(x \cdot \sqrt{\frac{y}{x}}\right)\\
\mathbf{elif}\;y \leq -1.5 \cdot 10^{-303}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{elif}\;y \leq 10^{-10}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \sqrt{\frac{z}{y}}\right)\\
\end{array}
\end{array}
if y < -68000Initial program 70.5%
Taylor expanded in x around -inf
Applied rewrites44.3%
Taylor expanded in y around inf
Applied rewrites43.4%
if -68000 < y < -1.50000000000000014e-303Initial program 70.5%
Applied rewrites70.6%
Taylor expanded in x around inf
Applied rewrites36.7%
if -1.50000000000000014e-303 < y < 1.00000000000000004e-10Initial program 70.5%
Taylor expanded in z around inf
Applied rewrites37.5%
if 1.00000000000000004e-10 < y Initial program 70.5%
Taylor expanded in y around inf
Applied rewrites42.9%
Taylor expanded in x around 0
Applied rewrites42.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -68000.0)
(* -2.0 (* x (sqrt (/ y x))))
(if (<= y -1.5e-303)
(* 2.0 (sqrt (* x (+ y z))))
(* 2.0 (sqrt (* z (+ x y)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -68000.0) {
tmp = -2.0 * (x * sqrt((y / x)));
} else if (y <= -1.5e-303) {
tmp = 2.0 * sqrt((x * (y + z)));
} else {
tmp = 2.0 * sqrt((z * (x + 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 <= (-68000.0d0)) then
tmp = (-2.0d0) * (x * sqrt((y / x)))
else if (y <= (-1.5d-303)) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else
tmp = 2.0d0 * sqrt((z * (x + 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 <= -68000.0) {
tmp = -2.0 * (x * Math.sqrt((y / x)));
} else if (y <= -1.5e-303) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else {
tmp = 2.0 * Math.sqrt((z * (x + y)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -68000.0: tmp = -2.0 * (x * math.sqrt((y / x))) elif y <= -1.5e-303: tmp = 2.0 * math.sqrt((x * (y + z))) else: tmp = 2.0 * math.sqrt((z * (x + y))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -68000.0) tmp = Float64(-2.0 * Float64(x * sqrt(Float64(y / x)))); elseif (y <= -1.5e-303) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); else tmp = Float64(2.0 * sqrt(Float64(z * Float64(x + 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 <= -68000.0)
tmp = -2.0 * (x * sqrt((y / x)));
elseif (y <= -1.5e-303)
tmp = 2.0 * sqrt((x * (y + z)));
else
tmp = 2.0 * sqrt((z * (x + 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, -68000.0], N[(-2.0 * N[(x * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.5e-303], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -68000:\\
\;\;\;\;-2 \cdot \left(x \cdot \sqrt{\frac{y}{x}}\right)\\
\mathbf{elif}\;y \leq -1.5 \cdot 10^{-303}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot \left(x + y\right)}\\
\end{array}
\end{array}
if y < -68000Initial program 70.5%
Taylor expanded in x around -inf
Applied rewrites44.3%
Taylor expanded in y around inf
Applied rewrites43.4%
if -68000 < y < -1.50000000000000014e-303Initial program 70.5%
Applied rewrites70.6%
Taylor expanded in x around inf
Applied rewrites36.7%
if -1.50000000000000014e-303 < y Initial program 70.5%
Taylor expanded in z around inf
Applied rewrites37.5%
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-303) (* 2.0 (sqrt (* x (+ y z)))) (* 2.0 (sqrt (* z (+ x y))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.5e-303) {
tmp = 2.0 * sqrt((x * (y + z)));
} else {
tmp = 2.0 * sqrt((z * (x + 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.5d-303)) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else
tmp = 2.0d0 * sqrt((z * (x + 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.5e-303) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else {
tmp = 2.0 * Math.sqrt((z * (x + y)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -1.5e-303: tmp = 2.0 * math.sqrt((x * (y + z))) else: tmp = 2.0 * math.sqrt((z * (x + y))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.5e-303) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); else tmp = Float64(2.0 * sqrt(Float64(z * Float64(x + 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.5e-303)
tmp = 2.0 * sqrt((x * (y + z)));
else
tmp = 2.0 * sqrt((z * (x + 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.5e-303], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{-303}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot \left(x + y\right)}\\
\end{array}
\end{array}
if y < -1.50000000000000014e-303Initial program 70.5%
Applied rewrites70.6%
Taylor expanded in x around inf
Applied rewrites36.7%
if -1.50000000000000014e-303 < y Initial program 70.5%
Taylor expanded in z around inf
Applied rewrites37.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 1.15e-297) (* 2.0 (sqrt (* x (+ y z)))) (* 2.0 (sqrt (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.15e-297) {
tmp = 2.0 * sqrt((x * (y + z)));
} else {
tmp = 2.0 * sqrt((y * 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 <= 1.15d-297) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else
tmp = 2.0d0 * sqrt((y * 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 <= 1.15e-297) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else {
tmp = 2.0 * Math.sqrt((y * z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= 1.15e-297: tmp = 2.0 * math.sqrt((x * (y + z))) else: tmp = 2.0 * math.sqrt((y * z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 1.15e-297) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); else tmp = Float64(2.0 * sqrt(Float64(y * 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 <= 1.15e-297)
tmp = 2.0 * sqrt((x * (y + z)));
else
tmp = 2.0 * sqrt((y * 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, 1.15e-297], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.15 \cdot 10^{-297}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot z}\\
\end{array}
\end{array}
if y < 1.15e-297Initial program 70.5%
Applied rewrites70.6%
Taylor expanded in x around inf
Applied rewrites36.7%
if 1.15e-297 < y Initial program 70.5%
Taylor expanded in x around 0
Applied rewrites36.0%
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 z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return 2.0 * sqrt((y * (x + z)));
}
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 + z)))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((y * (x + z)));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return 2.0 * math.sqrt((y * (x + z)))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(2.0 * sqrt(Float64(y * Float64(x + z)))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = 2.0 * sqrt((y * (x + z)));
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 * N[(x + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \sqrt{y \cdot \left(x + z\right)}
\end{array}
Initial program 70.5%
Taylor expanded in y around inf
Applied rewrites68.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -4e-304) (* 2.0 (sqrt (* x y))) (* 2.0 (sqrt (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -4e-304) {
tmp = 2.0 * sqrt((x * y));
} else {
tmp = 2.0 * sqrt((y * 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 <= (-4d-304)) then
tmp = 2.0d0 * sqrt((x * y))
else
tmp = 2.0d0 * sqrt((y * 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 <= -4e-304) {
tmp = 2.0 * Math.sqrt((x * y));
} else {
tmp = 2.0 * Math.sqrt((y * z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -4e-304: tmp = 2.0 * math.sqrt((x * y)) else: tmp = 2.0 * math.sqrt((y * z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -4e-304) tmp = Float64(2.0 * sqrt(Float64(x * y))); else tmp = Float64(2.0 * sqrt(Float64(y * 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 <= -4e-304)
tmp = 2.0 * sqrt((x * y));
else
tmp = 2.0 * sqrt((y * 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, -4e-304], N[(2.0 * N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-304}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot z}\\
\end{array}
\end{array}
if y < -3.99999999999999988e-304Initial program 70.5%
Taylor expanded in z around 0
Applied rewrites35.2%
if -3.99999999999999988e-304 < y Initial program 70.5%
Taylor expanded in x around 0
Applied rewrites36.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* 2.0 (sqrt (* x y))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return 2.0 * sqrt((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((x * y))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((x * y));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return 2.0 * math.sqrt((x * y))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(2.0 * sqrt(Float64(x * y))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = 2.0 * sqrt((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[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \sqrt{x \cdot y}
\end{array}
Initial program 70.5%
Taylor expanded in z around 0
Applied rewrites35.2%
herbie shell --seed 2025153
(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)))))