
(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 10 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 -1.25e+45)
(*
(- x)
(fma
(sqrt (/ (+ z y) x))
2.0
(* (* z y) (sqrt (* -1.0 (/ -1.0 (* (* x x) (* (+ z y) x))))))))
(if (<= y 1100000000000.0)
(* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z))))
(* (* (sqrt (/ y z)) 2.0) z))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.25e+45) {
tmp = -x * fma(sqrt(((z + y) / x)), 2.0, ((z * y) * sqrt((-1.0 * (-1.0 / ((x * x) * ((z + y) * x)))))));
} else if (y <= 1100000000000.0) {
tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
} else {
tmp = (sqrt((y / z)) * 2.0) * z;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.25e+45) tmp = Float64(Float64(-x) * fma(sqrt(Float64(Float64(z + y) / x)), 2.0, Float64(Float64(z * y) * sqrt(Float64(-1.0 * Float64(-1.0 / Float64(Float64(x * x) * Float64(Float64(z + y) * x)))))))); elseif (y <= 1100000000000.0) tmp = Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))); else tmp = Float64(Float64(sqrt(Float64(y / z)) * 2.0) * 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.25e+45], N[((-x) * N[(N[Sqrt[N[(N[(z + y), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] * 2.0 + N[(N[(z * y), $MachinePrecision] * N[Sqrt[N[(-1.0 * N[(-1.0 / N[(N[(x * x), $MachinePrecision] * N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1100000000000.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[(N[(N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+45}:\\
\;\;\;\;\left(-x\right) \cdot \mathsf{fma}\left(\sqrt{\frac{z + y}{x}}, 2, \left(z \cdot y\right) \cdot \sqrt{-1 \cdot \frac{-1}{\left(x \cdot x\right) \cdot \left(\left(z + y\right) \cdot x\right)}}\right)\\
\mathbf{elif}\;y \leq 1100000000000:\\
\;\;\;\;2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{y}{z}} \cdot 2\right) \cdot z\\
\end{array}
\end{array}
if y < -1.25e45Initial program 33.0%
Taylor expanded in x around -inf
Applied rewrites92.1%
if -1.25e45 < y < 1.1e12Initial program 94.0%
if 1.1e12 < y Initial program 42.1%
Taylor expanded in z around inf
Applied rewrites92.4%
Taylor expanded in x around 0
metadata-evalN/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6498.3
Applied rewrites98.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 1100000000000.0) (* (sqrt (fma (+ y x) z (* y x))) 2.0) (* (* (sqrt (/ y z)) 2.0) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 1100000000000.0) {
tmp = sqrt(fma((y + x), z, (y * x))) * 2.0;
} else {
tmp = (sqrt((y / z)) * 2.0) * z;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 1100000000000.0) tmp = Float64(sqrt(fma(Float64(y + x), z, Float64(y * x))) * 2.0); else tmp = Float64(Float64(sqrt(Float64(y / z)) * 2.0) * 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, 1100000000000.0], N[(N[Sqrt[N[(N[(y + x), $MachinePrecision] * z + N[(y * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1100000000000:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(y + x, z, y \cdot x\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{y}{z}} \cdot 2\right) \cdot z\\
\end{array}
\end{array}
if y < 1.1e12Initial program 78.6%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.8%
if 1.1e12 < y Initial program 42.1%
Taylor expanded in z around inf
Applied rewrites92.4%
Taylor expanded in x around 0
metadata-evalN/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6498.3
Applied rewrites98.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.1e-273)
(* (sqrt (fma x z (* y x))) 2.0)
(if (<= y 1100000000000.0)
(* 2.0 (sqrt (* (+ y x) z)))
(* (* (sqrt (/ y z)) 2.0) z))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.1e-273) {
tmp = sqrt(fma(x, z, (y * x))) * 2.0;
} else if (y <= 1100000000000.0) {
tmp = 2.0 * sqrt(((y + x) * z));
} else {
tmp = (sqrt((y / z)) * 2.0) * z;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.1e-273) tmp = Float64(sqrt(fma(x, z, Float64(y * x))) * 2.0); elseif (y <= 1100000000000.0) tmp = Float64(2.0 * sqrt(Float64(Float64(y + x) * z))); else tmp = Float64(Float64(sqrt(Float64(y / z)) * 2.0) * 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.1e-273], N[(N[Sqrt[N[(x * z + N[(y * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], If[LessEqual[y, 1100000000000.0], N[(2.0 * N[Sqrt[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{-273}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(x, z, y \cdot x\right)} \cdot 2\\
\mathbf{elif}\;y \leq 1100000000000:\\
\;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{y}{z}} \cdot 2\right) \cdot z\\
\end{array}
\end{array}
if y < -1.0999999999999999e-273Initial program 70.3%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.5%
Taylor expanded in x around inf
Applied rewrites70.5%
if -1.0999999999999999e-273 < y < 1.1e12Initial program 93.5%
Taylor expanded in z around inf
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
distribute-lft-outN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-outN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6492.8
Applied rewrites92.8%
if 1.1e12 < y Initial program 42.1%
Taylor expanded in z around inf
Applied rewrites92.4%
Taylor expanded in x around 0
metadata-evalN/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6498.3
Applied rewrites98.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.1e-273)
(* 2.0 (sqrt (* (+ z y) x)))
(if (<= y 1100000000000.0)
(* 2.0 (sqrt (* (+ y x) z)))
(* (* (sqrt (/ y z)) 2.0) z))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.1e-273) {
tmp = 2.0 * sqrt(((z + y) * x));
} else if (y <= 1100000000000.0) {
tmp = 2.0 * sqrt(((y + x) * z));
} else {
tmp = (sqrt((y / z)) * 2.0) * 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.1d-273)) then
tmp = 2.0d0 * sqrt(((z + y) * x))
else if (y <= 1100000000000.0d0) then
tmp = 2.0d0 * sqrt(((y + x) * z))
else
tmp = (sqrt((y / z)) * 2.0d0) * 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.1e-273) {
tmp = 2.0 * Math.sqrt(((z + y) * x));
} else if (y <= 1100000000000.0) {
tmp = 2.0 * Math.sqrt(((y + x) * z));
} else {
tmp = (Math.sqrt((y / z)) * 2.0) * z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -1.1e-273: tmp = 2.0 * math.sqrt(((z + y) * x)) elif y <= 1100000000000.0: tmp = 2.0 * math.sqrt(((y + x) * z)) else: tmp = (math.sqrt((y / z)) * 2.0) * z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.1e-273) tmp = Float64(2.0 * sqrt(Float64(Float64(z + y) * x))); elseif (y <= 1100000000000.0) tmp = Float64(2.0 * sqrt(Float64(Float64(y + x) * z))); else tmp = Float64(Float64(sqrt(Float64(y / z)) * 2.0) * 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.1e-273)
tmp = 2.0 * sqrt(((z + y) * x));
elseif (y <= 1100000000000.0)
tmp = 2.0 * sqrt(((y + x) * z));
else
tmp = (sqrt((y / z)) * 2.0) * 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.1e-273], N[(2.0 * N[Sqrt[N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1100000000000.0], N[(2.0 * N[Sqrt[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{-273}:\\
\;\;\;\;2 \cdot \sqrt{\left(z + y\right) \cdot x}\\
\mathbf{elif}\;y \leq 1100000000000:\\
\;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{y}{z}} \cdot 2\right) \cdot z\\
\end{array}
\end{array}
if y < -1.0999999999999999e-273Initial program 70.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.5
Applied rewrites70.5%
if -1.0999999999999999e-273 < y < 1.1e12Initial program 93.5%
Taylor expanded in z around inf
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
distribute-lft-outN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-outN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6492.8
Applied rewrites92.8%
if 1.1e12 < y Initial program 42.1%
Taylor expanded in z around inf
Applied rewrites92.4%
Taylor expanded in x around 0
metadata-evalN/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6498.3
Applied rewrites98.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 8.8e-298) (* (sqrt (fma x z (* y x))) 2.0) (* (* (/ (sqrt y) (sqrt z)) 2.0) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 8.8e-298) {
tmp = sqrt(fma(x, z, (y * x))) * 2.0;
} else {
tmp = ((sqrt(y) / sqrt(z)) * 2.0) * z;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 8.8e-298) tmp = Float64(sqrt(fma(x, z, Float64(y * x))) * 2.0); else tmp = Float64(Float64(Float64(sqrt(y) / sqrt(z)) * 2.0) * 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, 8.8e-298], N[(N[Sqrt[N[(x * z + N[(y * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(N[(N[Sqrt[y], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.8 \cdot 10^{-298}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(x, z, y \cdot x\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{y}}{\sqrt{z}} \cdot 2\right) \cdot z\\
\end{array}
\end{array}
if y < 8.799999999999999e-298Initial program 70.1%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.3%
Taylor expanded in x around inf
Applied rewrites70.2%
if 8.799999999999999e-298 < y Initial program 70.0%
Taylor expanded in z around inf
Applied rewrites78.2%
Taylor expanded in x around 0
metadata-evalN/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6487.5
Applied rewrites87.5%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6496.8
Applied rewrites96.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -1.1e-273) (* 2.0 (sqrt (* (+ z 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 <= -1.1e-273) {
tmp = 2.0 * sqrt(((z + 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 <= (-1.1d-273)) then
tmp = 2.0d0 * sqrt(((z + 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 <= -1.1e-273) {
tmp = 2.0 * Math.sqrt(((z + 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 <= -1.1e-273: tmp = 2.0 * math.sqrt(((z + 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 <= -1.1e-273) tmp = Float64(2.0 * sqrt(Float64(Float64(z + 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 <= -1.1e-273)
tmp = 2.0 * sqrt(((z + 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, -1.1e-273], N[(2.0 * N[Sqrt[N[(N[(z + y), $MachinePrecision] * 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 -1.1 \cdot 10^{-273}:\\
\;\;\;\;2 \cdot \sqrt{\left(z + y\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
\end{array}
\end{array}
if y < -1.0999999999999999e-273Initial program 70.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.5
Applied rewrites70.5%
if -1.0999999999999999e-273 < y Initial program 69.8%
Taylor expanded in z around inf
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
distribute-lft-outN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-outN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6469.6
Applied rewrites69.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -2.9e-272) (* 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.9e-272) {
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.9d-272)) 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.9e-272) {
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.9e-272: 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.9e-272) 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.9e-272)
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.9e-272], 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.9 \cdot 10^{-272}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
\end{array}
\end{array}
if y < -2.89999999999999995e-272Initial program 70.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6468.5
Applied rewrites68.5%
if -2.89999999999999995e-272 < y Initial program 69.8%
Taylor expanded in z around inf
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
distribute-lft-outN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-outN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6469.6
Applied rewrites69.6%
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.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6468.2
Applied rewrites68.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -1.1e-273) (* 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.1e-273) {
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.1d-273)) 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.1e-273) {
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.1e-273: 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.1e-273) 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.1e-273)
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.1e-273], 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.1 \cdot 10^{-273}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot y}\\
\end{array}
\end{array}
if y < -1.0999999999999999e-273Initial program 70.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6468.5
Applied rewrites68.5%
if -1.0999999999999999e-273 < y Initial program 69.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f6467.6
Applied rewrites67.6%
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.0%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6435.1
Applied rewrites35.1%
herbie shell --seed 2025130
(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)))))