
(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 11 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 -7.2e+31)
(* 2.0 (exp (* (+ (log (- y)) (- (log (/ -1.0 x)))) 0.5)))
(if (<= y 2.8e-260)
(* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z))))
(* (* 2.0 (/ (sqrt (+ x y)) (sqrt z))) z))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+31) {
tmp = 2.0 * exp(((log(-y) + -log((-1.0 / x))) * 0.5));
} else if (y <= 2.8e-260) {
tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
} else {
tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-7.2d+31)) then
tmp = 2.0d0 * exp(((log(-y) + -log(((-1.0d0) / x))) * 0.5d0))
else if (y <= 2.8d-260) then
tmp = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
else
tmp = (2.0d0 * (sqrt((x + y)) / sqrt(z))) * z
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+31) {
tmp = 2.0 * Math.exp(((Math.log(-y) + -Math.log((-1.0 / x))) * 0.5));
} else if (y <= 2.8e-260) {
tmp = 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
} else {
tmp = (2.0 * (Math.sqrt((x + y)) / Math.sqrt(z))) * z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -7.2e+31: tmp = 2.0 * math.exp(((math.log(-y) + -math.log((-1.0 / x))) * 0.5)) elif y <= 2.8e-260: tmp = 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z))) else: tmp = (2.0 * (math.sqrt((x + y)) / math.sqrt(z))) * z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -7.2e+31) tmp = Float64(2.0 * exp(Float64(Float64(log(Float64(-y)) + Float64(-log(Float64(-1.0 / x)))) * 0.5))); elseif (y <= 2.8e-260) tmp = Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))); else tmp = Float64(Float64(2.0 * Float64(sqrt(Float64(x + y)) / sqrt(z))) * z); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -7.2e+31)
tmp = 2.0 * exp(((log(-y) + -log((-1.0 / x))) * 0.5));
elseif (y <= 2.8e-260)
tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
else
tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -7.2e+31], N[(2.0 * N[Exp[N[(N[(N[Log[(-y)], $MachinePrecision] + (-N[Log[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.8e-260], 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[(2.0 * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+31}:\\
\;\;\;\;2 \cdot e^{\left(\log \left(-y\right) + \left(-\log \left(\frac{-1}{x}\right)\right)\right) \cdot 0.5}\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-260}:\\
\;\;\;\;2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < -7.19999999999999992e31Initial program 70.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow1/2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
Applied rewrites65.5%
Taylor expanded in x around -inf
lower-+.f64N/A
lower-log.f64N/A
distribute-lft-outN/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-/.f6445.3
Applied rewrites45.3%
Taylor expanded in y around inf
Applied rewrites44.3%
if -7.19999999999999992e31 < y < 2.7999999999999998e-260Initial program 70.3%
if 2.7999999999999998e-260 < y Initial program 70.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites39.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6444.8
Applied rewrites44.8%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-+.f64N/A
lower-sqrt.f6449.7
Applied rewrites49.7%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -2.05e-297) (* 2.0 (exp (* (+ (log (- (+ y z))) (- (log (/ -1.0 x)))) 0.5))) (* (* 2.0 (/ (sqrt (+ x y)) (sqrt z))) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -2.05e-297) {
tmp = 2.0 * exp(((log(-(y + z)) + -log((-1.0 / x))) * 0.5));
} else {
tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-2.05d-297)) then
tmp = 2.0d0 * exp(((log(-(y + z)) + -log(((-1.0d0) / x))) * 0.5d0))
else
tmp = (2.0d0 * (sqrt((x + y)) / sqrt(z))) * z
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.05e-297) {
tmp = 2.0 * Math.exp(((Math.log(-(y + z)) + -Math.log((-1.0 / x))) * 0.5));
} else {
tmp = (2.0 * (Math.sqrt((x + y)) / Math.sqrt(z))) * z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -2.05e-297: tmp = 2.0 * math.exp(((math.log(-(y + z)) + -math.log((-1.0 / x))) * 0.5)) else: tmp = (2.0 * (math.sqrt((x + y)) / math.sqrt(z))) * z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -2.05e-297) tmp = Float64(2.0 * exp(Float64(Float64(log(Float64(-Float64(y + z))) + Float64(-log(Float64(-1.0 / x)))) * 0.5))); else tmp = Float64(Float64(2.0 * Float64(sqrt(Float64(x + y)) / sqrt(z))) * z); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -2.05e-297)
tmp = 2.0 * exp(((log(-(y + z)) + -log((-1.0 / x))) * 0.5));
else
tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -2.05e-297], N[(2.0 * N[Exp[N[(N[(N[Log[(-N[(y + z), $MachinePrecision])], $MachinePrecision] + (-N[Log[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.05 \cdot 10^{-297}:\\
\;\;\;\;2 \cdot e^{\left(\log \left(-\left(y + z\right)\right) + \left(-\log \left(\frac{-1}{x}\right)\right)\right) \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < -2.0500000000000001e-297Initial program 70.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow1/2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
Applied rewrites65.5%
Taylor expanded in x around -inf
lower-+.f64N/A
lower-log.f64N/A
distribute-lft-outN/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-/.f6445.3
Applied rewrites45.3%
if -2.0500000000000001e-297 < y Initial program 70.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites39.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6444.8
Applied rewrites44.8%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-+.f64N/A
lower-sqrt.f6449.7
Applied rewrites49.7%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 2.8e-260) (* (sqrt (fma (+ y x) z (* y x))) 2.0) (* (* 2.0 (/ (sqrt (+ x y)) (sqrt z))) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 2.8e-260) {
tmp = sqrt(fma((y + x), z, (y * x))) * 2.0;
} else {
tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 2.8e-260) tmp = Float64(sqrt(fma(Float64(y + x), z, Float64(y * x))) * 2.0); else tmp = Float64(Float64(2.0 * Float64(sqrt(Float64(x + y)) / sqrt(z))) * z); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 2.8e-260], N[(N[Sqrt[N[(N[(y + x), $MachinePrecision] * z + N[(y * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(2.0 * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{-260}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(y + x, z, y \cdot x\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < 2.7999999999999998e-260Initial 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.4%
if 2.7999999999999998e-260 < y Initial program 70.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites39.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6444.8
Applied rewrites44.8%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-+.f64N/A
lower-sqrt.f6449.7
Applied rewrites49.7%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 1.8e+23) (* (sqrt (fma (+ y x) z (* y x))) 2.0) (* (* 2.0 (sqrt (/ (+ x y) z))) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.8e+23) {
tmp = sqrt(fma((y + x), z, (y * x))) * 2.0;
} else {
tmp = (2.0 * sqrt(((x + y) / z))) * z;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 1.8e+23) tmp = Float64(sqrt(fma(Float64(y + x), z, Float64(y * x))) * 2.0); else tmp = Float64(Float64(2.0 * sqrt(Float64(Float64(x + y) / z))) * z); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 1.8e+23], N[(N[Sqrt[N[(N[(y + x), $MachinePrecision] * z + N[(y * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(2.0 * N[Sqrt[N[(N[(x + y), $MachinePrecision] / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{+23}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(y + x, z, y \cdot x\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < 1.7999999999999999e23Initial 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.4%
if 1.7999999999999999e23 < y Initial program 70.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites39.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6444.8
Applied rewrites44.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.8e+23) (* 2.0 (sqrt (fma (+ z y) x (* z y)))) (* (* 2.0 (sqrt (/ (+ x y) z))) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.8e+23) {
tmp = 2.0 * sqrt(fma((z + y), x, (z * y)));
} else {
tmp = (2.0 * sqrt(((x + y) / z))) * z;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 1.8e+23) tmp = Float64(2.0 * sqrt(fma(Float64(z + y), x, Float64(z * y)))); else tmp = Float64(Float64(2.0 * sqrt(Float64(Float64(x + y) / z))) * z); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 1.8e+23], N[(2.0 * N[Sqrt[N[(N[(z + y), $MachinePrecision] * x + N[(z * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sqrt[N[(N[(x + y), $MachinePrecision] / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{+23}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z + y, x, z \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < 1.7999999999999999e23Initial program 70.3%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
if 1.7999999999999999e23 < y Initial program 70.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites39.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6444.8
Applied rewrites44.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 8.2e+18) (* 2.0 (sqrt (* (+ z x) y))) (* (* 2.0 (sqrt (/ (+ x y) z))) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 8.2e+18) {
tmp = 2.0 * sqrt(((z + x) * y));
} else {
tmp = (2.0 * sqrt(((x + y) / z))) * z;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 8.2d+18) then
tmp = 2.0d0 * sqrt(((z + x) * y))
else
tmp = (2.0d0 * sqrt(((x + y) / z))) * z
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= 8.2e+18) {
tmp = 2.0 * Math.sqrt(((z + x) * y));
} else {
tmp = (2.0 * Math.sqrt(((x + y) / z))) * z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= 8.2e+18: tmp = 2.0 * math.sqrt(((z + x) * y)) else: tmp = (2.0 * math.sqrt(((x + y) / z))) * z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 8.2e+18) tmp = Float64(2.0 * sqrt(Float64(Float64(z + x) * y))); else tmp = Float64(Float64(2.0 * sqrt(Float64(Float64(x + y) / z))) * z); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= 8.2e+18)
tmp = 2.0 * sqrt(((z + x) * y));
else
tmp = (2.0 * sqrt(((x + y) / z))) * z;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 8.2e+18], N[(2.0 * N[Sqrt[N[(N[(z + x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sqrt[N[(N[(x + y), $MachinePrecision] / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.2 \cdot 10^{+18}:\\
\;\;\;\;2 \cdot \sqrt{\left(z + x\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < 8.2e18Initial program 70.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6468.5
Applied rewrites68.5%
if 8.2e18 < y Initial program 70.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites39.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6444.8
Applied rewrites44.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.6e+21) (* 2.0 (sqrt (* (+ z x) y))) (* (* 2.0 (sqrt (/ y z))) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e+21) {
tmp = 2.0 * sqrt(((z + x) * y));
} else {
tmp = (2.0 * sqrt((y / z))) * z;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.6d+21) then
tmp = 2.0d0 * sqrt(((z + x) * y))
else
tmp = (2.0d0 * sqrt((y / z))) * z
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e+21) {
tmp = 2.0 * Math.sqrt(((z + x) * y));
} else {
tmp = (2.0 * Math.sqrt((y / z))) * z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= 1.6e+21: tmp = 2.0 * math.sqrt(((z + x) * y)) else: tmp = (2.0 * math.sqrt((y / z))) * z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 1.6e+21) tmp = Float64(2.0 * sqrt(Float64(Float64(z + x) * y))); else tmp = Float64(Float64(2.0 * sqrt(Float64(y / z))) * z); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= 1.6e+21)
tmp = 2.0 * sqrt(((z + x) * y));
else
tmp = (2.0 * sqrt((y / z))) * z;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 1.6e+21], N[(2.0 * N[Sqrt[N[(N[(z + x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{+21}:\\
\;\;\;\;2 \cdot \sqrt{\left(z + x\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z\\
\end{array}
\end{array}
if y < 1.6e21Initial program 70.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6468.5
Applied rewrites68.5%
if 1.6e21 < y Initial program 70.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites39.6%
Taylor expanded in x around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lift-/.f6443.9
Applied rewrites43.9%
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-258) (* 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 <= -1.25e-258) {
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 <= (-1.25d-258)) 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 <= -1.25e-258) {
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 <= -1.25e-258: 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 <= -1.25e-258) 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 <= -1.25e-258)
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, -1.25e-258], 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 -1.25 \cdot 10^{-258}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
\end{array}
\end{array}
if y < -1.25e-258Initial program 70.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6435.9
Applied rewrites35.9%
if -1.25e-258 < y Initial program 70.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6436.9
Applied rewrites36.9%
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.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6468.5
Applied rewrites68.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -2e-310) (* 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 <= -2e-310) {
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 <= (-2d-310)) 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 <= -2e-310) {
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 <= -2e-310: 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 <= -2e-310) 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 <= -2e-310)
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, -2e-310], 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 -2 \cdot 10^{-310}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot y}\\
\end{array}
\end{array}
if y < -1.999999999999994e-310Initial program 70.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6435.9
Applied rewrites35.9%
if -1.999999999999994e-310 < y Initial program 70.3%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f6435.5
Applied rewrites35.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* 2.0 (sqrt (* 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.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6435.9
Applied rewrites35.9%
herbie shell --seed 2025124
(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)))))