
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
double code(double x, double y, double z) {
return 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
end function
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
def code(x, y, z): return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
function code(x, y, z) return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))) end
function tmp = code(x, y, z) tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z))); end
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
double code(double x, double y, double z) {
return 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
end function
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
def code(x, y, z): return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
function code(x, y, z) return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))) end
function tmp = code(x, y, z) tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z))); end
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -6.6e+21)
(* -2.0 (* x (sqrt (* -1.0 (/ (fma -1.0 y (* -1.0 z)) x)))))
(if (<= y 2.5e-230)
(* 2.0 (sqrt (* x (+ y (+ z (/ (* y z) x))))))
(* 2.0 (* y (/ (sqrt (+ x z)) (sqrt y)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -6.6e+21) {
tmp = -2.0 * (x * sqrt((-1.0 * (fma(-1.0, y, (-1.0 * z)) / x))));
} else if (y <= 2.5e-230) {
tmp = 2.0 * sqrt((x * (y + (z + ((y * z) / x)))));
} else {
tmp = 2.0 * (y * (sqrt((x + z)) / sqrt(y)));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -6.6e+21) tmp = Float64(-2.0 * Float64(x * sqrt(Float64(-1.0 * Float64(fma(-1.0, y, Float64(-1.0 * z)) / x))))); elseif (y <= 2.5e-230) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + Float64(z + Float64(Float64(y * z) / x)))))); else tmp = Float64(2.0 * Float64(y * Float64(sqrt(Float64(x + z)) / sqrt(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, -6.6e+21], N[(-2.0 * N[(x * N[Sqrt[N[(-1.0 * N[(N[(-1.0 * y + N[(-1.0 * z), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e-230], N[(2.0 * N[Sqrt[N[(x * N[(y + N[(z + N[(N[(y * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[(N[Sqrt[N[(x + z), $MachinePrecision]], $MachinePrecision] / N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \cdot 10^{+21}:\\
\;\;\;\;-2 \cdot \left(x \cdot \sqrt{-1 \cdot \frac{\mathsf{fma}\left(-1, y, -1 \cdot z\right)}{x}}\right)\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-230}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + \left(z + \frac{y \cdot z}{x}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \frac{\sqrt{x + z}}{\sqrt{y}}\right)\\
\end{array}
\end{array}
if y < -6.6e21Initial program 69.7%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f6443.7
Applied rewrites43.7%
if -6.6e21 < y < 2.50000000000000017e-230Initial program 69.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6457.6
Applied rewrites57.6%
if 2.50000000000000017e-230 < y Initial program 69.7%
lift-+.f64N/A
sum-to-multN/A
lower-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6426.3
Applied rewrites26.3%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
sum-to-mult-revN/A
lower-+.f64N/A
lower-sqrt.f6449.4
Applied rewrites49.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -6.6e+21)
(* -2.0 (* x (sqrt (* -1.0 (/ (fma -1.0 y (* -1.0 z)) x)))))
(if (<= y 2.5e-230)
(* 2.0 (sqrt (fma z y (/ 1.0 (/ 1.0 (* (+ y z) x))))))
(* 2.0 (* y (/ (sqrt (+ x z)) (sqrt y)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -6.6e+21) {
tmp = -2.0 * (x * sqrt((-1.0 * (fma(-1.0, y, (-1.0 * z)) / x))));
} else if (y <= 2.5e-230) {
tmp = 2.0 * sqrt(fma(z, y, (1.0 / (1.0 / ((y + z) * x)))));
} else {
tmp = 2.0 * (y * (sqrt((x + z)) / sqrt(y)));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -6.6e+21) tmp = Float64(-2.0 * Float64(x * sqrt(Float64(-1.0 * Float64(fma(-1.0, y, Float64(-1.0 * z)) / x))))); elseif (y <= 2.5e-230) tmp = Float64(2.0 * sqrt(fma(z, y, Float64(1.0 / Float64(1.0 / Float64(Float64(y + z) * x)))))); else tmp = Float64(2.0 * Float64(y * Float64(sqrt(Float64(x + z)) / sqrt(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, -6.6e+21], N[(-2.0 * N[(x * N[Sqrt[N[(-1.0 * N[(N[(-1.0 * y + N[(-1.0 * z), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e-230], N[(2.0 * N[Sqrt[N[(z * y + N[(1.0 / N[(1.0 / N[(N[(y + z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[(N[Sqrt[N[(x + z), $MachinePrecision]], $MachinePrecision] / N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \cdot 10^{+21}:\\
\;\;\;\;-2 \cdot \left(x \cdot \sqrt{-1 \cdot \frac{\mathsf{fma}\left(-1, y, -1 \cdot z\right)}{x}}\right)\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-230}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z, y, \frac{1}{\frac{1}{\left(y + z\right) \cdot x}}\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \frac{\sqrt{x + z}}{\sqrt{y}}\right)\\
\end{array}
\end{array}
if y < -6.6e21Initial program 69.7%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f6443.7
Applied rewrites43.7%
if -6.6e21 < y < 2.50000000000000017e-230Initial program 69.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6469.7
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6469.8
Applied rewrites69.8%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-outN/A
lift-*.f64N/A
flip3-+N/A
div-flipN/A
div-flip-revN/A
flip3-+N/A
lift-*.f64N/A
distribute-lft-outN/A
+-commutativeN/A
lift-+.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lower-/.f6469.7
Applied rewrites69.7%
if 2.50000000000000017e-230 < y Initial program 69.7%
lift-+.f64N/A
sum-to-multN/A
lower-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6426.3
Applied rewrites26.3%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
sum-to-mult-revN/A
lower-+.f64N/A
lower-sqrt.f6449.4
Applied rewrites49.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -1.7e+22)
(* (* (- y) (sqrt (/ x y))) 2.0)
(if (<= y 2.5e-230)
(* 2.0 (sqrt (* x (+ y (+ z (/ (* y z) x))))))
(* 2.0 (* y (/ (sqrt (+ x z)) (sqrt y)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.7e+22) {
tmp = (-y * sqrt((x / y))) * 2.0;
} else if (y <= 2.5e-230) {
tmp = 2.0 * sqrt((x * (y + (z + ((y * z) / x)))));
} else {
tmp = 2.0 * (y * (sqrt((x + z)) / sqrt(y)));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.7d+22)) then
tmp = (-y * sqrt((x / y))) * 2.0d0
else if (y <= 2.5d-230) then
tmp = 2.0d0 * sqrt((x * (y + (z + ((y * z) / x)))))
else
tmp = 2.0d0 * (y * (sqrt((x + z)) / sqrt(y)))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.7e+22) {
tmp = (-y * Math.sqrt((x / y))) * 2.0;
} else if (y <= 2.5e-230) {
tmp = 2.0 * Math.sqrt((x * (y + (z + ((y * z) / x)))));
} else {
tmp = 2.0 * (y * (Math.sqrt((x + z)) / Math.sqrt(y)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -1.7e+22: tmp = (-y * math.sqrt((x / y))) * 2.0 elif y <= 2.5e-230: tmp = 2.0 * math.sqrt((x * (y + (z + ((y * z) / x))))) else: tmp = 2.0 * (y * (math.sqrt((x + z)) / math.sqrt(y))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.7e+22) tmp = Float64(Float64(Float64(-y) * sqrt(Float64(x / y))) * 2.0); elseif (y <= 2.5e-230) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + Float64(z + Float64(Float64(y * z) / x)))))); else tmp = Float64(2.0 * Float64(y * Float64(sqrt(Float64(x + z)) / sqrt(y)))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -1.7e+22)
tmp = (-y * sqrt((x / y))) * 2.0;
elseif (y <= 2.5e-230)
tmp = 2.0 * sqrt((x * (y + (z + ((y * z) / x)))));
else
tmp = 2.0 * (y * (sqrt((x + z)) / sqrt(y)));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -1.7e+22], N[(N[((-y) * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], If[LessEqual[y, 2.5e-230], N[(2.0 * N[Sqrt[N[(x * N[(y + N[(z + N[(N[(y * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[(N[Sqrt[N[(x + z), $MachinePrecision]], $MachinePrecision] / N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+22}:\\
\;\;\;\;\left(\left(-y\right) \cdot \sqrt{\frac{x}{y}}\right) \cdot 2\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-230}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + \left(z + \frac{y \cdot z}{x}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \frac{\sqrt{x + z}}{\sqrt{y}}\right)\\
\end{array}
\end{array}
if y < -1.7e22Initial program 69.7%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6434.3
Applied rewrites34.3%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6442.3
Applied rewrites42.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.3
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6442.3
Applied rewrites42.3%
if -1.7e22 < y < 2.50000000000000017e-230Initial program 69.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6457.6
Applied rewrites57.6%
if 2.50000000000000017e-230 < y Initial program 69.7%
lift-+.f64N/A
sum-to-multN/A
lower-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6426.3
Applied rewrites26.3%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
sum-to-mult-revN/A
lower-+.f64N/A
lower-sqrt.f6449.4
Applied rewrites49.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -1.7e+22)
(* (* (- y) (sqrt (/ x y))) 2.0)
(if (<= y 2.5e-230)
(* 2.0 (sqrt (fma z y (* (+ z y) x))))
(* 2.0 (* y (/ (sqrt (+ x z)) (sqrt y)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.7e+22) {
tmp = (-y * sqrt((x / y))) * 2.0;
} else if (y <= 2.5e-230) {
tmp = 2.0 * sqrt(fma(z, y, ((z + y) * x)));
} else {
tmp = 2.0 * (y * (sqrt((x + z)) / sqrt(y)));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.7e+22) tmp = Float64(Float64(Float64(-y) * sqrt(Float64(x / y))) * 2.0); elseif (y <= 2.5e-230) tmp = Float64(2.0 * sqrt(fma(z, y, Float64(Float64(z + y) * x)))); else tmp = Float64(2.0 * Float64(y * Float64(sqrt(Float64(x + z)) / sqrt(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, -1.7e+22], N[(N[((-y) * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], If[LessEqual[y, 2.5e-230], N[(2.0 * N[Sqrt[N[(z * y + N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[(N[Sqrt[N[(x + z), $MachinePrecision]], $MachinePrecision] / N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+22}:\\
\;\;\;\;\left(\left(-y\right) \cdot \sqrt{\frac{x}{y}}\right) \cdot 2\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-230}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z, y, \left(z + y\right) \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \frac{\sqrt{x + z}}{\sqrt{y}}\right)\\
\end{array}
\end{array}
if y < -1.7e22Initial program 69.7%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6434.3
Applied rewrites34.3%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6442.3
Applied rewrites42.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.3
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6442.3
Applied rewrites42.3%
if -1.7e22 < y < 2.50000000000000017e-230Initial program 69.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6469.7
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6469.8
Applied rewrites69.8%
if 2.50000000000000017e-230 < y Initial program 69.7%
lift-+.f64N/A
sum-to-multN/A
lower-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6426.3
Applied rewrites26.3%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
sum-to-mult-revN/A
lower-+.f64N/A
lower-sqrt.f6449.4
Applied rewrites49.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -1.7e+22)
(* (* (- y) (sqrt (/ x y))) 2.0)
(if (<= y 2.5e-230)
(* 2.0 (sqrt (fma z y (* (+ z y) x))))
(* 2.0 (* y (/ (sqrt z) (sqrt y)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.7e+22) {
tmp = (-y * sqrt((x / y))) * 2.0;
} else if (y <= 2.5e-230) {
tmp = 2.0 * sqrt(fma(z, y, ((z + y) * x)));
} else {
tmp = 2.0 * (y * (sqrt(z) / sqrt(y)));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.7e+22) tmp = Float64(Float64(Float64(-y) * sqrt(Float64(x / y))) * 2.0); elseif (y <= 2.5e-230) tmp = Float64(2.0 * sqrt(fma(z, y, Float64(Float64(z + y) * x)))); else tmp = Float64(2.0 * Float64(y * Float64(sqrt(z) / sqrt(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, -1.7e+22], N[(N[((-y) * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], If[LessEqual[y, 2.5e-230], N[(2.0 * N[Sqrt[N[(z * y + N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[(N[Sqrt[z], $MachinePrecision] / N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+22}:\\
\;\;\;\;\left(\left(-y\right) \cdot \sqrt{\frac{x}{y}}\right) \cdot 2\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-230}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z, y, \left(z + y\right) \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \frac{\sqrt{z}}{\sqrt{y}}\right)\\
\end{array}
\end{array}
if y < -1.7e22Initial program 69.7%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6434.3
Applied rewrites34.3%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6442.3
Applied rewrites42.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.3
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6442.3
Applied rewrites42.3%
if -1.7e22 < y < 2.50000000000000017e-230Initial program 69.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6469.7
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6469.8
Applied rewrites69.8%
if 2.50000000000000017e-230 < y Initial program 69.7%
lift-+.f64N/A
sum-to-multN/A
lower-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6426.3
Applied rewrites26.3%
Taylor expanded in x around 0
Applied rewrites44.3%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6449.4
Applied rewrites49.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -1.7e+22)
(* (* (- y) (sqrt (/ x y))) 2.0)
(if (<= y 9.6e-246)
(* 2.0 (sqrt (* x (+ y z))))
(* 2.0 (* y (/ (sqrt z) (sqrt y)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.7e+22) {
tmp = (-y * sqrt((x / y))) * 2.0;
} else if (y <= 9.6e-246) {
tmp = 2.0 * sqrt((x * (y + z)));
} else {
tmp = 2.0 * (y * (sqrt(z) / sqrt(y)));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.7d+22)) then
tmp = (-y * sqrt((x / y))) * 2.0d0
else if (y <= 9.6d-246) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else
tmp = 2.0d0 * (y * (sqrt(z) / sqrt(y)))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.7e+22) {
tmp = (-y * Math.sqrt((x / y))) * 2.0;
} else if (y <= 9.6e-246) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else {
tmp = 2.0 * (y * (Math.sqrt(z) / Math.sqrt(y)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -1.7e+22: tmp = (-y * math.sqrt((x / y))) * 2.0 elif y <= 9.6e-246: tmp = 2.0 * math.sqrt((x * (y + z))) else: tmp = 2.0 * (y * (math.sqrt(z) / math.sqrt(y))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.7e+22) tmp = Float64(Float64(Float64(-y) * sqrt(Float64(x / y))) * 2.0); elseif (y <= 9.6e-246) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); else tmp = Float64(2.0 * Float64(y * Float64(sqrt(z) / sqrt(y)))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -1.7e+22)
tmp = (-y * sqrt((x / y))) * 2.0;
elseif (y <= 9.6e-246)
tmp = 2.0 * sqrt((x * (y + z)));
else
tmp = 2.0 * (y * (sqrt(z) / sqrt(y)));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -1.7e+22], N[(N[((-y) * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], If[LessEqual[y, 9.6e-246], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[(N[Sqrt[z], $MachinePrecision] / N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+22}:\\
\;\;\;\;\left(\left(-y\right) \cdot \sqrt{\frac{x}{y}}\right) \cdot 2\\
\mathbf{elif}\;y \leq 9.6 \cdot 10^{-246}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \frac{\sqrt{z}}{\sqrt{y}}\right)\\
\end{array}
\end{array}
if y < -1.7e22Initial program 69.7%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6434.3
Applied rewrites34.3%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6442.3
Applied rewrites42.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.3
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6442.3
Applied rewrites42.3%
if -1.7e22 < y < 9.5999999999999992e-246Initial program 69.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f642.3
Applied rewrites2.3%
Taylor expanded in x around 0
lower-sqrt.f64N/A
lower-*.f64N/A
lower-+.f6435.7
Applied rewrites35.7%
if 9.5999999999999992e-246 < y Initial program 69.7%
lift-+.f64N/A
sum-to-multN/A
lower-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6426.3
Applied rewrites26.3%
Taylor expanded in x around 0
Applied rewrites44.3%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6449.4
Applied rewrites49.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -7.8e+21)
(* (* (- y) (sqrt (/ x y))) 2.0)
(if (<= y 5e+59)
(* 2.0 (sqrt (* y (+ x z))))
(* 2.0 (* y (sqrt (/ z y)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -7.8e+21) {
tmp = (-y * sqrt((x / y))) * 2.0;
} else if (y <= 5e+59) {
tmp = 2.0 * sqrt((y * (x + z)));
} else {
tmp = 2.0 * (y * sqrt((z / y)));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-7.8d+21)) then
tmp = (-y * sqrt((x / y))) * 2.0d0
else if (y <= 5d+59) then
tmp = 2.0d0 * sqrt((y * (x + z)))
else
tmp = 2.0d0 * (y * sqrt((z / y)))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7.8e+21) {
tmp = (-y * Math.sqrt((x / y))) * 2.0;
} else if (y <= 5e+59) {
tmp = 2.0 * Math.sqrt((y * (x + z)));
} else {
tmp = 2.0 * (y * Math.sqrt((z / y)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -7.8e+21: tmp = (-y * math.sqrt((x / y))) * 2.0 elif y <= 5e+59: tmp = 2.0 * math.sqrt((y * (x + z))) else: tmp = 2.0 * (y * math.sqrt((z / y))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -7.8e+21) tmp = Float64(Float64(Float64(-y) * sqrt(Float64(x / y))) * 2.0); elseif (y <= 5e+59) tmp = Float64(2.0 * sqrt(Float64(y * Float64(x + z)))); else tmp = Float64(2.0 * Float64(y * sqrt(Float64(z / y)))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -7.8e+21)
tmp = (-y * sqrt((x / y))) * 2.0;
elseif (y <= 5e+59)
tmp = 2.0 * sqrt((y * (x + z)));
else
tmp = 2.0 * (y * sqrt((z / y)));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -7.8e+21], N[(N[((-y) * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], If[LessEqual[y, 5e+59], N[(2.0 * N[Sqrt[N[(y * N[(x + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[Sqrt[N[(z / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.8 \cdot 10^{+21}:\\
\;\;\;\;\left(\left(-y\right) \cdot \sqrt{\frac{x}{y}}\right) \cdot 2\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+59}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot \left(x + z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \sqrt{\frac{z}{y}}\right)\\
\end{array}
\end{array}
if y < -7.8e21Initial program 69.7%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6434.3
Applied rewrites34.3%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6442.3
Applied rewrites42.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.3
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6442.3
Applied rewrites42.3%
if -7.8e21 < y < 4.9999999999999997e59Initial program 69.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6467.8
Applied rewrites67.8%
if 4.9999999999999997e59 < y Initial program 69.7%
lift-+.f64N/A
sum-to-multN/A
lower-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6426.3
Applied rewrites26.3%
Taylor expanded in x around 0
Applied rewrites44.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -7.8e+21)
(* -2.0 (* x (sqrt (/ y x))))
(if (<= y 5e+59)
(* 2.0 (sqrt (* y (+ x z))))
(* 2.0 (* y (sqrt (/ z y)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -7.8e+21) {
tmp = -2.0 * (x * sqrt((y / x)));
} else if (y <= 5e+59) {
tmp = 2.0 * sqrt((y * (x + z)));
} else {
tmp = 2.0 * (y * sqrt((z / y)));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-7.8d+21)) then
tmp = (-2.0d0) * (x * sqrt((y / x)))
else if (y <= 5d+59) then
tmp = 2.0d0 * sqrt((y * (x + z)))
else
tmp = 2.0d0 * (y * sqrt((z / y)))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7.8e+21) {
tmp = -2.0 * (x * Math.sqrt((y / x)));
} else if (y <= 5e+59) {
tmp = 2.0 * Math.sqrt((y * (x + z)));
} else {
tmp = 2.0 * (y * Math.sqrt((z / y)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -7.8e+21: tmp = -2.0 * (x * math.sqrt((y / x))) elif y <= 5e+59: tmp = 2.0 * math.sqrt((y * (x + z))) else: tmp = 2.0 * (y * math.sqrt((z / y))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -7.8e+21) tmp = Float64(-2.0 * Float64(x * sqrt(Float64(y / x)))); elseif (y <= 5e+59) tmp = Float64(2.0 * sqrt(Float64(y * Float64(x + z)))); else tmp = Float64(2.0 * Float64(y * sqrt(Float64(z / y)))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -7.8e+21)
tmp = -2.0 * (x * sqrt((y / x)));
elseif (y <= 5e+59)
tmp = 2.0 * sqrt((y * (x + z)));
else
tmp = 2.0 * (y * sqrt((z / y)));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -7.8e+21], N[(-2.0 * N[(x * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e+59], N[(2.0 * N[Sqrt[N[(y * N[(x + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[Sqrt[N[(z / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.8 \cdot 10^{+21}:\\
\;\;\;\;-2 \cdot \left(x \cdot \sqrt{\frac{y}{x}}\right)\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+59}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot \left(x + z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \sqrt{\frac{z}{y}}\right)\\
\end{array}
\end{array}
if y < -7.8e21Initial program 69.7%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f6443.7
Applied rewrites43.7%
Taylor expanded in z around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6442.7
Applied rewrites42.7%
if -7.8e21 < y < 4.9999999999999997e59Initial program 69.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6467.8
Applied rewrites67.8%
if 4.9999999999999997e59 < y Initial program 69.7%
lift-+.f64N/A
sum-to-multN/A
lower-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6466.6
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6426.3
Applied rewrites26.3%
Taylor expanded in x around 0
Applied rewrites44.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -7.8e+21) (* -2.0 (* x (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 <= -7.8e+21) {
tmp = -2.0 * (x * 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 <= (-7.8d+21)) then
tmp = (-2.0d0) * (x * 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 <= -7.8e+21) {
tmp = -2.0 * (x * 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 <= -7.8e+21: tmp = -2.0 * (x * 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 <= -7.8e+21) tmp = Float64(-2.0 * Float64(x * sqrt(Float64(y / x)))); else tmp = Float64(2.0 * sqrt(Float64(y * Float64(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 <= -7.8e+21)
tmp = -2.0 * (x * 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, -7.8e+21], N[(-2.0 * N[(x * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(y * N[(x + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.8 \cdot 10^{+21}:\\
\;\;\;\;-2 \cdot \left(x \cdot \sqrt{\frac{y}{x}}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot \left(x + z\right)}\\
\end{array}
\end{array}
if y < -7.8e21Initial program 69.7%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f6443.7
Applied rewrites43.7%
Taylor expanded in z around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6442.7
Applied rewrites42.7%
if -7.8e21 < y Initial program 69.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6467.8
Applied rewrites67.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -4.2e-287) (* 2.0 (sqrt (* x (+ y z)))) (* 2.0 (sqrt (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e-287) {
tmp = 2.0 * sqrt((x * (y + z)));
} else {
tmp = 2.0 * sqrt((y * z));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-4.2d-287)) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else
tmp = 2.0d0 * sqrt((y * z))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e-287) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else {
tmp = 2.0 * Math.sqrt((y * z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -4.2e-287: tmp = 2.0 * math.sqrt((x * (y + z))) else: tmp = 2.0 * math.sqrt((y * z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -4.2e-287) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); else tmp = Float64(2.0 * sqrt(Float64(y * z))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -4.2e-287)
tmp = 2.0 * sqrt((x * (y + z)));
else
tmp = 2.0 * sqrt((y * z));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -4.2e-287], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{-287}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot z}\\
\end{array}
\end{array}
if y < -4.1999999999999998e-287Initial program 69.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f642.3
Applied rewrites2.3%
Taylor expanded in x around 0
lower-sqrt.f64N/A
lower-*.f64N/A
lower-+.f6435.7
Applied rewrites35.7%
if -4.1999999999999998e-287 < y Initial program 69.7%
Taylor expanded in x around 0
lower-*.f6436.4
Applied rewrites36.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* 2.0 (sqrt (* y (+ x z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return 2.0 * sqrt((y * (x + z)));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((y * (x + z)))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((y * (x + z)));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return 2.0 * math.sqrt((y * (x + z)))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(2.0 * sqrt(Float64(y * Float64(x + z)))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = 2.0 * sqrt((y * (x + z)));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(y * N[(x + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \sqrt{y \cdot \left(x + z\right)}
\end{array}
Initial program 69.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6467.8
Applied rewrites67.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -4e-310) (* 2.0 (sqrt (* x y))) (* 2.0 (sqrt (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -4e-310) {
tmp = 2.0 * sqrt((x * y));
} else {
tmp = 2.0 * sqrt((y * z));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-4d-310)) then
tmp = 2.0d0 * sqrt((x * y))
else
tmp = 2.0d0 * sqrt((y * z))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4e-310) {
tmp = 2.0 * Math.sqrt((x * y));
} else {
tmp = 2.0 * Math.sqrt((y * z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -4e-310: tmp = 2.0 * math.sqrt((x * y)) else: tmp = 2.0 * math.sqrt((y * z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -4e-310) tmp = Float64(2.0 * sqrt(Float64(x * y))); else tmp = Float64(2.0 * sqrt(Float64(y * z))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -4e-310)
tmp = 2.0 * sqrt((x * y));
else
tmp = 2.0 * sqrt((y * z));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -4e-310], N[(2.0 * N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-310}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot z}\\
\end{array}
\end{array}
if y < -3.999999999999988e-310Initial program 69.7%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6434.3
Applied rewrites34.3%
if -3.999999999999988e-310 < y Initial program 69.7%
Taylor expanded in x around 0
lower-*.f6436.4
Applied rewrites36.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* 2.0 (sqrt (* x y))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return 2.0 * sqrt((x * y));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((x * y))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((x * y));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return 2.0 * math.sqrt((x * y))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(2.0 * sqrt(Float64(x * y))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = 2.0 * sqrt((x * y));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \sqrt{x \cdot y}
\end{array}
Initial program 69.7%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6434.3
Applied rewrites34.3%
herbie shell --seed 2025150
(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)))))