
(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 15 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 -5.4e+44)
(* 2.0 (* (* (pow (/ (+ x z) y) 0.5) -1.0) y))
(if (<= y 0.0095)
(* 2.0 (sqrt (fma y x (* (+ y x) z))))
(*
2.0
(fma
(pow y 0.5)
(sqrt z)
(*
x
(*
y
(fma
0.5
(pow (pow (* y z) -1.0) 0.5)
(* 0.5 (pow (/ z (pow y 3.0)) 0.5))))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -5.4e+44) {
tmp = 2.0 * ((pow(((x + z) / y), 0.5) * -1.0) * y);
} else if (y <= 0.0095) {
tmp = 2.0 * sqrt(fma(y, x, ((y + x) * z)));
} else {
tmp = 2.0 * fma(pow(y, 0.5), sqrt(z), (x * (y * fma(0.5, pow(pow((y * z), -1.0), 0.5), (0.5 * pow((z / pow(y, 3.0)), 0.5))))));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -5.4e+44) tmp = Float64(2.0 * Float64(Float64((Float64(Float64(x + z) / y) ^ 0.5) * -1.0) * y)); elseif (y <= 0.0095) tmp = Float64(2.0 * sqrt(fma(y, x, Float64(Float64(y + x) * z)))); else tmp = Float64(2.0 * fma((y ^ 0.5), sqrt(z), Float64(x * Float64(y * fma(0.5, ((Float64(y * z) ^ -1.0) ^ 0.5), Float64(0.5 * (Float64(z / (y ^ 3.0)) ^ 0.5))))))); 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, -5.4e+44], N[(2.0 * N[(N[(N[Power[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision], 0.5], $MachinePrecision] * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.0095], N[(2.0 * N[Sqrt[N[(y * x + N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Power[y, 0.5], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(y * N[(0.5 * N[Power[N[Power[N[(y * z), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] + N[(0.5 * N[Power[N[(z / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+44}:\\
\;\;\;\;2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{0.5} \cdot -1\right) \cdot y\right)\\
\mathbf{elif}\;y \leq 0.0095:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(y, x, \left(y + x\right) \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left({y}^{0.5}, \sqrt{z}, x \cdot \left(y \cdot \mathsf{fma}\left(0.5, {\left({\left(y \cdot z\right)}^{-1}\right)}^{0.5}, 0.5 \cdot {\left(\frac{z}{{y}^{3}}\right)}^{0.5}\right)\right)\right)\\
\end{array}
\end{array}
if y < -5.4e44Initial program 35.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.5%
Taylor expanded in y around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-+.f6498.1
Applied rewrites98.1%
if -5.4e44 < y < 0.00949999999999999976Initial program 94.5%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6494.5
Applied rewrites94.5%
if 0.00949999999999999976 < y Initial program 47.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites86.9%
Taylor expanded in x around 0
sqrt-prodN/A
pow1/2N/A
lower-fma.f64N/A
lift-pow.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites98.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -5.4e+44)
(* 2.0 (* (* (pow (/ (+ x z) y) 0.5) -1.0) y))
(if (<= y 0.0095)
(* 2.0 (sqrt (fma x (- (* 2.0 z) (* -1.0 (- y z))) (* y z))))
(*
2.0
(fma
(pow y 0.5)
(sqrt z)
(*
x
(*
y
(fma
0.5
(pow (pow (* y z) -1.0) 0.5)
(* 0.5 (pow (/ z (pow y 3.0)) 0.5))))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -5.4e+44) {
tmp = 2.0 * ((pow(((x + z) / y), 0.5) * -1.0) * y);
} else if (y <= 0.0095) {
tmp = 2.0 * sqrt(fma(x, ((2.0 * z) - (-1.0 * (y - z))), (y * z)));
} else {
tmp = 2.0 * fma(pow(y, 0.5), sqrt(z), (x * (y * fma(0.5, pow(pow((y * z), -1.0), 0.5), (0.5 * pow((z / pow(y, 3.0)), 0.5))))));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -5.4e+44) tmp = Float64(2.0 * Float64(Float64((Float64(Float64(x + z) / y) ^ 0.5) * -1.0) * y)); elseif (y <= 0.0095) tmp = Float64(2.0 * sqrt(fma(x, Float64(Float64(2.0 * z) - Float64(-1.0 * Float64(y - z))), Float64(y * z)))); else tmp = Float64(2.0 * fma((y ^ 0.5), sqrt(z), Float64(x * Float64(y * fma(0.5, ((Float64(y * z) ^ -1.0) ^ 0.5), Float64(0.5 * (Float64(z / (y ^ 3.0)) ^ 0.5))))))); 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, -5.4e+44], N[(2.0 * N[(N[(N[Power[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision], 0.5], $MachinePrecision] * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.0095], N[(2.0 * N[Sqrt[N[(x * N[(N[(2.0 * z), $MachinePrecision] - N[(-1.0 * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Power[y, 0.5], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(y * N[(0.5 * N[Power[N[Power[N[(y * z), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] + N[(0.5 * N[Power[N[(z / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+44}:\\
\;\;\;\;2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{0.5} \cdot -1\right) \cdot y\right)\\
\mathbf{elif}\;y \leq 0.0095:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(x, 2 \cdot z - -1 \cdot \left(y - z\right), y \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left({y}^{0.5}, \sqrt{z}, x \cdot \left(y \cdot \mathsf{fma}\left(0.5, {\left({\left(y \cdot z\right)}^{-1}\right)}^{0.5}, 0.5 \cdot {\left(\frac{z}{{y}^{3}}\right)}^{0.5}\right)\right)\right)\\
\end{array}
\end{array}
if y < -5.4e44Initial program 35.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.5%
Taylor expanded in y around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-+.f6498.1
Applied rewrites98.1%
if -5.4e44 < y < 0.00949999999999999976Initial program 94.5%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites63.8%
Taylor expanded in x around 0
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6494.5
Applied rewrites94.5%
if 0.00949999999999999976 < y Initial program 47.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites86.9%
Taylor expanded in x around 0
sqrt-prodN/A
pow1/2N/A
lower-fma.f64N/A
lift-pow.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites98.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(let* ((t_0 (pow (/ (+ x z) y) 0.5)) (t_1 (* 2.0 (* (* t_0 -1.0) y))))
(if (<= y -5e+16)
t_1
(if (<= y -1.15e-159)
(* 2.0 (sqrt (/ (* x (- (* y y) (* z z))) (- y z))))
(if (<= y -4e-310) t_1 (* 2.0 (* t_0 y)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = pow(((x + z) / y), 0.5);
double t_1 = 2.0 * ((t_0 * -1.0) * y);
double tmp;
if (y <= -5e+16) {
tmp = t_1;
} else if (y <= -1.15e-159) {
tmp = 2.0 * sqrt(((x * ((y * y) - (z * z))) / (y - z)));
} else if (y <= -4e-310) {
tmp = t_1;
} else {
tmp = 2.0 * (t_0 * 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((x + z) / y) ** 0.5d0
t_1 = 2.0d0 * ((t_0 * (-1.0d0)) * y)
if (y <= (-5d+16)) then
tmp = t_1
else if (y <= (-1.15d-159)) then
tmp = 2.0d0 * sqrt(((x * ((y * y) - (z * z))) / (y - z)))
else if (y <= (-4d-310)) then
tmp = t_1
else
tmp = 2.0d0 * (t_0 * y)
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double t_0 = Math.pow(((x + z) / y), 0.5);
double t_1 = 2.0 * ((t_0 * -1.0) * y);
double tmp;
if (y <= -5e+16) {
tmp = t_1;
} else if (y <= -1.15e-159) {
tmp = 2.0 * Math.sqrt(((x * ((y * y) - (z * z))) / (y - z)));
} else if (y <= -4e-310) {
tmp = t_1;
} else {
tmp = 2.0 * (t_0 * y);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = math.pow(((x + z) / y), 0.5) t_1 = 2.0 * ((t_0 * -1.0) * y) tmp = 0 if y <= -5e+16: tmp = t_1 elif y <= -1.15e-159: tmp = 2.0 * math.sqrt(((x * ((y * y) - (z * z))) / (y - z))) elif y <= -4e-310: tmp = t_1 else: tmp = 2.0 * (t_0 * y) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(Float64(x + z) / y) ^ 0.5 t_1 = Float64(2.0 * Float64(Float64(t_0 * -1.0) * y)) tmp = 0.0 if (y <= -5e+16) tmp = t_1; elseif (y <= -1.15e-159) tmp = Float64(2.0 * sqrt(Float64(Float64(x * Float64(Float64(y * y) - Float64(z * z))) / Float64(y - z)))); elseif (y <= -4e-310) tmp = t_1; else tmp = Float64(2.0 * Float64(t_0 * y)); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
t_0 = ((x + z) / y) ^ 0.5;
t_1 = 2.0 * ((t_0 * -1.0) * y);
tmp = 0.0;
if (y <= -5e+16)
tmp = t_1;
elseif (y <= -1.15e-159)
tmp = 2.0 * sqrt(((x * ((y * y) - (z * z))) / (y - z)));
elseif (y <= -4e-310)
tmp = t_1;
else
tmp = 2.0 * (t_0 * 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_] := Block[{t$95$0 = N[Power[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(N[(t$95$0 * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5e+16], t$95$1, If[LessEqual[y, -1.15e-159], N[(2.0 * N[Sqrt[N[(N[(x * N[(N[(y * y), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -4e-310], t$95$1, N[(2.0 * N[(t$95$0 * y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{x + z}{y}\right)}^{0.5}\\
t_1 := 2 \cdot \left(\left(t\_0 \cdot -1\right) \cdot y\right)\\
\mathbf{if}\;y \leq -5 \cdot 10^{+16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.15 \cdot 10^{-159}:\\
\;\;\;\;2 \cdot \sqrt{\frac{x \cdot \left(y \cdot y - z \cdot z\right)}{y - z}}\\
\mathbf{elif}\;y \leq -4 \cdot 10^{-310}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t\_0 \cdot y\right)\\
\end{array}
\end{array}
if y < -5e16 or -1.14999999999999989e-159 < y < -3.999999999999988e-310Initial program 51.5%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.6%
Taylor expanded in y around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-+.f6487.5
Applied rewrites87.5%
if -5e16 < y < -1.14999999999999989e-159Initial program 99.6%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites68.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6494.1
Applied rewrites94.1%
if -3.999999999999988e-310 < y Initial program 71.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites63.2%
Taylor expanded in y around inf
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-+.f6484.3
Applied rewrites84.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (let* ((t_0 (pow (/ (+ x z) y) 0.5))) (if (<= y -4e-310) (* 2.0 (* (* t_0 -1.0) y)) (* 2.0 (* t_0 y)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = pow(((x + z) / y), 0.5);
double tmp;
if (y <= -4e-310) {
tmp = 2.0 * ((t_0 * -1.0) * y);
} else {
tmp = 2.0 * (t_0 * 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) :: t_0
real(8) :: tmp
t_0 = ((x + z) / y) ** 0.5d0
if (y <= (-4d-310)) then
tmp = 2.0d0 * ((t_0 * (-1.0d0)) * y)
else
tmp = 2.0d0 * (t_0 * y)
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double t_0 = Math.pow(((x + z) / y), 0.5);
double tmp;
if (y <= -4e-310) {
tmp = 2.0 * ((t_0 * -1.0) * y);
} else {
tmp = 2.0 * (t_0 * y);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = math.pow(((x + z) / y), 0.5) tmp = 0 if y <= -4e-310: tmp = 2.0 * ((t_0 * -1.0) * y) else: tmp = 2.0 * (t_0 * y) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(Float64(x + z) / y) ^ 0.5 tmp = 0.0 if (y <= -4e-310) tmp = Float64(2.0 * Float64(Float64(t_0 * -1.0) * y)); else tmp = Float64(2.0 * Float64(t_0 * y)); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
t_0 = ((x + z) / y) ^ 0.5;
tmp = 0.0;
if (y <= -4e-310)
tmp = 2.0 * ((t_0 * -1.0) * y);
else
tmp = 2.0 * (t_0 * 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_] := Block[{t$95$0 = N[Power[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision], 0.5], $MachinePrecision]}, If[LessEqual[y, -4e-310], N[(2.0 * N[(N[(t$95$0 * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$0 * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{x + z}{y}\right)}^{0.5}\\
\mathbf{if}\;y \leq -4 \cdot 10^{-310}:\\
\;\;\;\;2 \cdot \left(\left(t\_0 \cdot -1\right) \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t\_0 \cdot y\right)\\
\end{array}
\end{array}
if y < -3.999999999999988e-310Initial program 70.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.8%
Taylor expanded in y around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-+.f6485.0
Applied rewrites85.0%
if -3.999999999999988e-310 < y Initial program 71.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites63.2%
Taylor expanded in y around inf
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-+.f6484.3
Applied rewrites84.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(let* ((t_0 (pow (pow (* y z) -1.0) 0.5)))
(if (<= y 1.95e-177)
(* 2.0 (* (* (pow (/ (+ x z) y) 0.5) -1.0) y))
(if (<= y 2.4e-12)
(*
2.0
(*
(*
-1.0
(*
z
(fma
-0.5
(* (* x -1.0) (pow (pow (* (pow y 3.0) z) -1.0) 0.5))
(* t_0 -1.0))))
y))
(*
2.0
(fma
(pow y 0.5)
(sqrt z)
(* x (* y (fma 0.5 t_0 (* 0.5 (pow (/ z (pow y 3.0)) 0.5)))))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = pow(pow((y * z), -1.0), 0.5);
double tmp;
if (y <= 1.95e-177) {
tmp = 2.0 * ((pow(((x + z) / y), 0.5) * -1.0) * y);
} else if (y <= 2.4e-12) {
tmp = 2.0 * ((-1.0 * (z * fma(-0.5, ((x * -1.0) * pow(pow((pow(y, 3.0) * z), -1.0), 0.5)), (t_0 * -1.0)))) * y);
} else {
tmp = 2.0 * fma(pow(y, 0.5), sqrt(z), (x * (y * fma(0.5, t_0, (0.5 * pow((z / pow(y, 3.0)), 0.5))))));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = (Float64(y * z) ^ -1.0) ^ 0.5 tmp = 0.0 if (y <= 1.95e-177) tmp = Float64(2.0 * Float64(Float64((Float64(Float64(x + z) / y) ^ 0.5) * -1.0) * y)); elseif (y <= 2.4e-12) tmp = Float64(2.0 * Float64(Float64(-1.0 * Float64(z * fma(-0.5, Float64(Float64(x * -1.0) * ((Float64((y ^ 3.0) * z) ^ -1.0) ^ 0.5)), Float64(t_0 * -1.0)))) * y)); else tmp = Float64(2.0 * fma((y ^ 0.5), sqrt(z), Float64(x * Float64(y * fma(0.5, t_0, Float64(0.5 * (Float64(z / (y ^ 3.0)) ^ 0.5))))))); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[Power[N[Power[N[(y * z), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision]}, If[LessEqual[y, 1.95e-177], N[(2.0 * N[(N[(N[Power[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision], 0.5], $MachinePrecision] * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.4e-12], N[(2.0 * N[(N[(-1.0 * N[(z * N[(-0.5 * N[(N[(x * -1.0), $MachinePrecision] * N[Power[N[Power[N[(N[Power[y, 3.0], $MachinePrecision] * z), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Power[y, 0.5], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(y * N[(0.5 * t$95$0 + N[(0.5 * N[Power[N[(z / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := {\left({\left(y \cdot z\right)}^{-1}\right)}^{0.5}\\
\mathbf{if}\;y \leq 1.95 \cdot 10^{-177}:\\
\;\;\;\;2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{0.5} \cdot -1\right) \cdot y\right)\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-12}:\\
\;\;\;\;2 \cdot \left(\left(-1 \cdot \left(z \cdot \mathsf{fma}\left(-0.5, \left(x \cdot -1\right) \cdot {\left({\left({y}^{3} \cdot z\right)}^{-1}\right)}^{0.5}, t\_0 \cdot -1\right)\right)\right) \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left({y}^{0.5}, \sqrt{z}, x \cdot \left(y \cdot \mathsf{fma}\left(0.5, t\_0, 0.5 \cdot {\left(\frac{z}{{y}^{3}}\right)}^{0.5}\right)\right)\right)\\
\end{array}
\end{array}
if y < 1.95000000000000007e-177Initial program 71.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.9%
Taylor expanded in y around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-+.f6476.6
Applied rewrites76.6%
if 1.95000000000000007e-177 < y < 2.39999999999999987e-12Initial program 99.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites48.2%
Taylor expanded in z around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites58.0%
if 2.39999999999999987e-12 < y Initial program 49.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.2%
Taylor expanded in x around 0
sqrt-prodN/A
pow1/2N/A
lower-fma.f64N/A
lift-pow.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites97.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(let* ((t_0 (pow (pow (* y z) -1.0) 0.5)) (t_1 (pow (/ (+ x z) y) 0.25)))
(if (<= y 1.95e-177)
(* 2.0 (* (* (* t_1 t_1) -1.0) y))
(if (<= y 2.4e-12)
(*
2.0
(*
(*
-1.0
(*
z
(fma
-0.5
(* (* x -1.0) (pow (pow (* (pow y 3.0) z) -1.0) 0.5))
(* t_0 -1.0))))
y))
(*
2.0
(fma
(pow y 0.5)
(sqrt z)
(* x (* y (fma 0.5 t_0 (* 0.5 (pow (/ z (pow y 3.0)) 0.5)))))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = pow(pow((y * z), -1.0), 0.5);
double t_1 = pow(((x + z) / y), 0.25);
double tmp;
if (y <= 1.95e-177) {
tmp = 2.0 * (((t_1 * t_1) * -1.0) * y);
} else if (y <= 2.4e-12) {
tmp = 2.0 * ((-1.0 * (z * fma(-0.5, ((x * -1.0) * pow(pow((pow(y, 3.0) * z), -1.0), 0.5)), (t_0 * -1.0)))) * y);
} else {
tmp = 2.0 * fma(pow(y, 0.5), sqrt(z), (x * (y * fma(0.5, t_0, (0.5 * pow((z / pow(y, 3.0)), 0.5))))));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = (Float64(y * z) ^ -1.0) ^ 0.5 t_1 = Float64(Float64(x + z) / y) ^ 0.25 tmp = 0.0 if (y <= 1.95e-177) tmp = Float64(2.0 * Float64(Float64(Float64(t_1 * t_1) * -1.0) * y)); elseif (y <= 2.4e-12) tmp = Float64(2.0 * Float64(Float64(-1.0 * Float64(z * fma(-0.5, Float64(Float64(x * -1.0) * ((Float64((y ^ 3.0) * z) ^ -1.0) ^ 0.5)), Float64(t_0 * -1.0)))) * y)); else tmp = Float64(2.0 * fma((y ^ 0.5), sqrt(z), Float64(x * Float64(y * fma(0.5, t_0, Float64(0.5 * (Float64(z / (y ^ 3.0)) ^ 0.5))))))); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[Power[N[Power[N[(y * z), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision], 0.25], $MachinePrecision]}, If[LessEqual[y, 1.95e-177], N[(2.0 * N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.4e-12], N[(2.0 * N[(N[(-1.0 * N[(z * N[(-0.5 * N[(N[(x * -1.0), $MachinePrecision] * N[Power[N[Power[N[(N[Power[y, 3.0], $MachinePrecision] * z), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Power[y, 0.5], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(y * N[(0.5 * t$95$0 + N[(0.5 * N[Power[N[(z / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := {\left({\left(y \cdot z\right)}^{-1}\right)}^{0.5}\\
t_1 := {\left(\frac{x + z}{y}\right)}^{0.25}\\
\mathbf{if}\;y \leq 1.95 \cdot 10^{-177}:\\
\;\;\;\;2 \cdot \left(\left(\left(t\_1 \cdot t\_1\right) \cdot -1\right) \cdot y\right)\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-12}:\\
\;\;\;\;2 \cdot \left(\left(-1 \cdot \left(z \cdot \mathsf{fma}\left(-0.5, \left(x \cdot -1\right) \cdot {\left({\left({y}^{3} \cdot z\right)}^{-1}\right)}^{0.5}, t\_0 \cdot -1\right)\right)\right) \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left({y}^{0.5}, \sqrt{z}, x \cdot \left(y \cdot \mathsf{fma}\left(0.5, t\_0, 0.5 \cdot {\left(\frac{z}{{y}^{3}}\right)}^{0.5}\right)\right)\right)\\
\end{array}
\end{array}
if y < 1.95000000000000007e-177Initial program 71.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.9%
Taylor expanded in y around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-+.f6476.6
Applied rewrites76.6%
lift-pow.f64N/A
lift-+.f64N/A
lift-/.f64N/A
sqr-powN/A
lower-*.f64N/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-+.f64N/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-+.f6476.3
Applied rewrites76.3%
if 1.95000000000000007e-177 < y < 2.39999999999999987e-12Initial program 99.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites48.2%
Taylor expanded in z around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites58.0%
if 2.39999999999999987e-12 < y Initial program 49.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.2%
Taylor expanded in x around 0
sqrt-prodN/A
pow1/2N/A
lower-fma.f64N/A
lift-pow.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites97.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(let* ((t_0 (pow (pow (* y z) -1.0) 0.5)))
(if (<= y -2e-110)
(*
2.0
(*
-1.0
(*
x
(*
y
(fma
-0.5
(* (pow (pow (* x (pow y 3.0)) -1.0) 0.5) (* z -1.0))
(* (pow (pow (* x y) -1.0) 0.5) -1.0))))))
(if (<= y 2.4e-12)
(*
2.0
(*
(*
-1.0
(*
z
(fma
-0.5
(* (* x -1.0) (pow (pow (* (pow y 3.0) z) -1.0) 0.5))
(* t_0 -1.0))))
y))
(*
2.0
(fma
(pow y 0.5)
(sqrt z)
(* x (* y (fma 0.5 t_0 (* 0.5 (pow (/ z (pow y 3.0)) 0.5)))))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = pow(pow((y * z), -1.0), 0.5);
double tmp;
if (y <= -2e-110) {
tmp = 2.0 * (-1.0 * (x * (y * fma(-0.5, (pow(pow((x * pow(y, 3.0)), -1.0), 0.5) * (z * -1.0)), (pow(pow((x * y), -1.0), 0.5) * -1.0)))));
} else if (y <= 2.4e-12) {
tmp = 2.0 * ((-1.0 * (z * fma(-0.5, ((x * -1.0) * pow(pow((pow(y, 3.0) * z), -1.0), 0.5)), (t_0 * -1.0)))) * y);
} else {
tmp = 2.0 * fma(pow(y, 0.5), sqrt(z), (x * (y * fma(0.5, t_0, (0.5 * pow((z / pow(y, 3.0)), 0.5))))));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = (Float64(y * z) ^ -1.0) ^ 0.5 tmp = 0.0 if (y <= -2e-110) tmp = Float64(2.0 * Float64(-1.0 * Float64(x * Float64(y * fma(-0.5, Float64(((Float64(x * (y ^ 3.0)) ^ -1.0) ^ 0.5) * Float64(z * -1.0)), Float64(((Float64(x * y) ^ -1.0) ^ 0.5) * -1.0)))))); elseif (y <= 2.4e-12) tmp = Float64(2.0 * Float64(Float64(-1.0 * Float64(z * fma(-0.5, Float64(Float64(x * -1.0) * ((Float64((y ^ 3.0) * z) ^ -1.0) ^ 0.5)), Float64(t_0 * -1.0)))) * y)); else tmp = Float64(2.0 * fma((y ^ 0.5), sqrt(z), Float64(x * Float64(y * fma(0.5, t_0, Float64(0.5 * (Float64(z / (y ^ 3.0)) ^ 0.5))))))); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[Power[N[Power[N[(y * z), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision]}, If[LessEqual[y, -2e-110], N[(2.0 * N[(-1.0 * N[(x * N[(y * N[(-0.5 * N[(N[Power[N[Power[N[(x * N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * N[(z * -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Power[N[(x * y), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.4e-12], N[(2.0 * N[(N[(-1.0 * N[(z * N[(-0.5 * N[(N[(x * -1.0), $MachinePrecision] * N[Power[N[Power[N[(N[Power[y, 3.0], $MachinePrecision] * z), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Power[y, 0.5], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(y * N[(0.5 * t$95$0 + N[(0.5 * N[Power[N[(z / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := {\left({\left(y \cdot z\right)}^{-1}\right)}^{0.5}\\
\mathbf{if}\;y \leq -2 \cdot 10^{-110}:\\
\;\;\;\;2 \cdot \left(-1 \cdot \left(x \cdot \left(y \cdot \mathsf{fma}\left(-0.5, {\left({\left(x \cdot {y}^{3}\right)}^{-1}\right)}^{0.5} \cdot \left(z \cdot -1\right), {\left({\left(x \cdot y\right)}^{-1}\right)}^{0.5} \cdot -1\right)\right)\right)\right)\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-12}:\\
\;\;\;\;2 \cdot \left(\left(-1 \cdot \left(z \cdot \mathsf{fma}\left(-0.5, \left(x \cdot -1\right) \cdot {\left({\left({y}^{3} \cdot z\right)}^{-1}\right)}^{0.5}, t\_0 \cdot -1\right)\right)\right) \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left({y}^{0.5}, \sqrt{z}, x \cdot \left(y \cdot \mathsf{fma}\left(0.5, t\_0, 0.5 \cdot {\left(\frac{z}{{y}^{3}}\right)}^{0.5}\right)\right)\right)\\
\end{array}
\end{array}
if y < -2.0000000000000001e-110Initial program 64.7%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.8%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites60.1%
if -2.0000000000000001e-110 < y < 2.39999999999999987e-12Initial program 92.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites24.2%
Taylor expanded in z around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites29.3%
if 2.39999999999999987e-12 < y Initial program 49.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.2%
Taylor expanded in x around 0
sqrt-prodN/A
pow1/2N/A
lower-fma.f64N/A
lift-pow.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites97.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -3.1e-280)
(*
2.0
(*
-1.0
(*
x
(*
y
(fma
-0.5
(* (pow (pow (* x (pow y 3.0)) -1.0) 0.5) (* z -1.0))
(* (pow (pow (* x y) -1.0) 0.5) -1.0))))))
(*
2.0
(fma
(pow y 0.5)
(sqrt z)
(*
x
(*
y
(fma
0.5
(pow (pow (* y z) -1.0) 0.5)
(* 0.5 (pow (/ z (pow y 3.0)) 0.5)))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -3.1e-280) {
tmp = 2.0 * (-1.0 * (x * (y * fma(-0.5, (pow(pow((x * pow(y, 3.0)), -1.0), 0.5) * (z * -1.0)), (pow(pow((x * y), -1.0), 0.5) * -1.0)))));
} else {
tmp = 2.0 * fma(pow(y, 0.5), sqrt(z), (x * (y * fma(0.5, pow(pow((y * z), -1.0), 0.5), (0.5 * pow((z / pow(y, 3.0)), 0.5))))));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -3.1e-280) tmp = Float64(2.0 * Float64(-1.0 * Float64(x * Float64(y * fma(-0.5, Float64(((Float64(x * (y ^ 3.0)) ^ -1.0) ^ 0.5) * Float64(z * -1.0)), Float64(((Float64(x * y) ^ -1.0) ^ 0.5) * -1.0)))))); else tmp = Float64(2.0 * fma((y ^ 0.5), sqrt(z), Float64(x * Float64(y * fma(0.5, ((Float64(y * z) ^ -1.0) ^ 0.5), Float64(0.5 * (Float64(z / (y ^ 3.0)) ^ 0.5))))))); 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, -3.1e-280], N[(2.0 * N[(-1.0 * N[(x * N[(y * N[(-0.5 * N[(N[Power[N[Power[N[(x * N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * N[(z * -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Power[N[(x * y), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Power[y, 0.5], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(y * N[(0.5 * N[Power[N[Power[N[(y * z), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] + N[(0.5 * N[Power[N[(z / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{-280}:\\
\;\;\;\;2 \cdot \left(-1 \cdot \left(x \cdot \left(y \cdot \mathsf{fma}\left(-0.5, {\left({\left(x \cdot {y}^{3}\right)}^{-1}\right)}^{0.5} \cdot \left(z \cdot -1\right), {\left({\left(x \cdot y\right)}^{-1}\right)}^{0.5} \cdot -1\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left({y}^{0.5}, \sqrt{z}, x \cdot \left(y \cdot \mathsf{fma}\left(0.5, {\left({\left(y \cdot z\right)}^{-1}\right)}^{0.5}, 0.5 \cdot {\left(\frac{z}{{y}^{3}}\right)}^{0.5}\right)\right)\right)\\
\end{array}
\end{array}
if y < -3.10000000000000021e-280Initial program 70.7%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.8%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites45.7%
if -3.10000000000000021e-280 < y Initial program 71.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites62.6%
Taylor expanded in x around 0
sqrt-prodN/A
pow1/2N/A
lower-fma.f64N/A
lift-pow.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites63.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -4.4e-109)
(*
2.0
(*
-1.0
(*
x
(*
y
(fma
-0.5
(* (pow (pow (* x (pow y 3.0)) -1.0) 0.5) (* z -1.0))
(* (pow (pow (* x y) -1.0) 0.5) -1.0))))))
(* (pow (/ z x) 0.5) y)))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -4.4e-109) {
tmp = 2.0 * (-1.0 * (x * (y * fma(-0.5, (pow(pow((x * pow(y, 3.0)), -1.0), 0.5) * (z * -1.0)), (pow(pow((x * y), -1.0), 0.5) * -1.0)))));
} else {
tmp = pow((z / x), 0.5) * y;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -4.4e-109) tmp = Float64(2.0 * Float64(-1.0 * Float64(x * Float64(y * fma(-0.5, Float64(((Float64(x * (y ^ 3.0)) ^ -1.0) ^ 0.5) * Float64(z * -1.0)), Float64(((Float64(x * y) ^ -1.0) ^ 0.5) * -1.0)))))); else tmp = Float64((Float64(z / x) ^ 0.5) * 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, -4.4e-109], N[(2.0 * N[(-1.0 * N[(x * N[(y * N[(-0.5 * N[(N[Power[N[Power[N[(x * N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * N[(z * -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Power[N[(x * y), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(z / x), $MachinePrecision], 0.5], $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.4 \cdot 10^{-109}:\\
\;\;\;\;2 \cdot \left(-1 \cdot \left(x \cdot \left(y \cdot \mathsf{fma}\left(-0.5, {\left({\left(x \cdot {y}^{3}\right)}^{-1}\right)}^{0.5} \cdot \left(z \cdot -1\right), {\left({\left(x \cdot y\right)}^{-1}\right)}^{0.5} \cdot -1\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{z}{x}\right)}^{0.5} \cdot y\\
\end{array}
\end{array}
if y < -4.3999999999999999e-109Initial program 64.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.8%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites60.5%
if -4.3999999999999999e-109 < y Initial program 74.8%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f643.9
Applied rewrites3.9%
Taylor expanded in x around 0
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f643.8
Applied rewrites3.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(*
2.0
(*
x
(*
y
(+
(pow (pow (* x y) -1.0) 0.5)
(* 0.5 (* (pow (pow (* x (pow y 3.0)) -1.0) 0.5) z)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
return 2.0 * (x * (y * (pow(pow((x * y), -1.0), 0.5) + (0.5 * (pow(pow((x * pow(y, 3.0)), -1.0), 0.5) * 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 * (x * (y * ((((x * y) ** (-1.0d0)) ** 0.5d0) + (0.5d0 * ((((x * (y ** 3.0d0)) ** (-1.0d0)) ** 0.5d0) * z)))))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return 2.0 * (x * (y * (Math.pow(Math.pow((x * y), -1.0), 0.5) + (0.5 * (Math.pow(Math.pow((x * Math.pow(y, 3.0)), -1.0), 0.5) * z)))));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return 2.0 * (x * (y * (math.pow(math.pow((x * y), -1.0), 0.5) + (0.5 * (math.pow(math.pow((x * math.pow(y, 3.0)), -1.0), 0.5) * z)))))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(2.0 * Float64(x * Float64(y * Float64(((Float64(x * y) ^ -1.0) ^ 0.5) + Float64(0.5 * Float64(((Float64(x * (y ^ 3.0)) ^ -1.0) ^ 0.5) * z)))))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = 2.0 * (x * (y * ((((x * y) ^ -1.0) ^ 0.5) + (0.5 * ((((x * (y ^ 3.0)) ^ -1.0) ^ 0.5) * 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[(x * N[(y * N[(N[Power[N[Power[N[(x * y), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] + N[(0.5 * N[(N[Power[N[Power[N[(x * N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \left(x \cdot \left(y \cdot \left({\left({\left(x \cdot y\right)}^{-1}\right)}^{0.5} + 0.5 \cdot \left({\left({\left(x \cdot {y}^{3}\right)}^{-1}\right)}^{0.5} \cdot z\right)\right)\right)\right)
\end{array}
Initial program 70.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites31.6%
Taylor expanded in z around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites23.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
pow1/2N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites24.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (fma (* (pow (* z x) -0.5) y) (+ z x) (* (pow (* z x) 0.5) 2.0)))
assert(x < y && y < z);
double code(double x, double y, double z) {
return fma((pow((z * x), -0.5) * y), (z + x), (pow((z * x), 0.5) * 2.0));
}
x, y, z = sort([x, y, z]) function code(x, y, z) return fma(Float64((Float64(z * x) ^ -0.5) * y), Float64(z + x), Float64((Float64(z * x) ^ 0.5) * 2.0)) end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(N[Power[N[(z * x), $MachinePrecision], -0.5], $MachinePrecision] * y), $MachinePrecision] * N[(z + x), $MachinePrecision] + N[(N[Power[N[(z * x), $MachinePrecision], 0.5], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\mathsf{fma}\left({\left(z \cdot x\right)}^{-0.5} \cdot y, z + x, {\left(z \cdot x\right)}^{0.5} \cdot 2\right)
\end{array}
Initial program 70.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f643.8
Applied rewrites3.8%
lift-pow.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
pow-powN/A
metadata-evalN/A
lower-pow.f64N/A
lift-*.f643.8
Applied rewrites3.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* (pow (/ z x) 0.5) y))
assert(x < y && y < z);
double code(double x, double y, double z) {
return pow((z / x), 0.5) * 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 = ((z / x) ** 0.5d0) * y
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return Math.pow((z / x), 0.5) * y;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return math.pow((z / x), 0.5) * y
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64((Float64(z / x) ^ 0.5) * y) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = ((z / x) ^ 0.5) * y;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[Power[N[(z / x), $MachinePrecision], 0.5], $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
{\left(\frac{z}{x}\right)}^{0.5} \cdot y
\end{array}
Initial program 70.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f643.8
Applied rewrites3.8%
Taylor expanded in x around 0
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f643.0
Applied rewrites3.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* x (fma 2.0 (pow (/ z x) 0.5) (fma (pow (pow (* x z) -1.0) 0.5) y (* (pow (/ z (pow x 3.0)) 0.5) y)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return x * fma(2.0, pow((z / x), 0.5), fma(pow(pow((x * z), -1.0), 0.5), y, (pow((z / pow(x, 3.0)), 0.5) * y)));
}
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(x * fma(2.0, (Float64(z / x) ^ 0.5), fma(((Float64(x * z) ^ -1.0) ^ 0.5), y, Float64((Float64(z / (x ^ 3.0)) ^ 0.5) * y)))) end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(x * N[(2.0 * N[Power[N[(z / x), $MachinePrecision], 0.5], $MachinePrecision] + N[(N[Power[N[Power[N[(x * z), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * y + N[(N[Power[N[(z / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x \cdot \mathsf{fma}\left(2, {\left(\frac{z}{x}\right)}^{0.5}, \mathsf{fma}\left({\left({\left(x \cdot z\right)}^{-1}\right)}^{0.5}, y, {\left(\frac{z}{{x}^{3}}\right)}^{0.5} \cdot y\right)\right)
\end{array}
Initial program 70.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f643.8
Applied rewrites3.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites2.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* x (fma 2.0 (* (pow (/ z x) 0.5) -1.0) (fma (pow (pow (* x z) -1.0) 0.5) y (* (pow (/ z (pow x 3.0)) 0.5) y)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return x * fma(2.0, (pow((z / x), 0.5) * -1.0), fma(pow(pow((x * z), -1.0), 0.5), y, (pow((z / pow(x, 3.0)), 0.5) * y)));
}
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(x * fma(2.0, Float64((Float64(z / x) ^ 0.5) * -1.0), fma(((Float64(x * z) ^ -1.0) ^ 0.5), y, Float64((Float64(z / (x ^ 3.0)) ^ 0.5) * y)))) end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(x * N[(2.0 * N[(N[Power[N[(z / x), $MachinePrecision], 0.5], $MachinePrecision] * -1.0), $MachinePrecision] + N[(N[Power[N[Power[N[(x * z), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * y + N[(N[Power[N[(z / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x \cdot \mathsf{fma}\left(2, {\left(\frac{z}{x}\right)}^{0.5} \cdot -1, \mathsf{fma}\left({\left({\left(x \cdot z\right)}^{-1}\right)}^{0.5}, y, {\left(\frac{z}{{x}^{3}}\right)}^{0.5} \cdot y\right)\right)
\end{array}
Initial program 70.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f643.8
Applied rewrites3.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites2.9%
Taylor expanded in x around -inf
pow1/2N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-/.f642.3
Applied rewrites2.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(let* ((t_0 (pow (/ z x) 0.5)))
(*
x
(/ (fma z (fma 2.0 t_0 (* (pow (/ z (pow x 3.0)) 0.5) y)) (* t_0 y)) z))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = pow((z / x), 0.5);
return x * (fma(z, fma(2.0, t_0, (pow((z / pow(x, 3.0)), 0.5) * y)), (t_0 * y)) / z);
}
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(z / x) ^ 0.5 return Float64(x * Float64(fma(z, fma(2.0, t_0, Float64((Float64(z / (x ^ 3.0)) ^ 0.5) * y)), Float64(t_0 * y)) / z)) end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[Power[N[(z / x), $MachinePrecision], 0.5], $MachinePrecision]}, N[(x * N[(N[(z * N[(2.0 * t$95$0 + N[(N[Power[N[(z / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{z}{x}\right)}^{0.5}\\
x \cdot \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(2, t\_0, {\left(\frac{z}{{x}^{3}}\right)}^{0.5} \cdot y\right), t\_0 \cdot y\right)}{z}
\end{array}
\end{array}
Initial program 70.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f643.8
Applied rewrites3.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites2.9%
Taylor expanded in z around 0
lower-/.f64N/A
Applied rewrites2.0%
herbie shell --seed 2025093
(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)))))