
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
double code(double x, double y, double z) {
return 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
end function
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
def code(x, y, z): return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
function code(x, y, z) return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))) end
function tmp = code(x, y, z) tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z))); end
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
double code(double x, double y, double z) {
return 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
end function
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
def code(x, y, z): return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
function code(x, y, z) return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))) end
function tmp = code(x, y, z) tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z))); end
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -2.9e+26)
(* (* -2.0 x) (sqrt (/ (+ y z) x)))
(if (<= y 46000000.0)
(* 2.0 (sqrt (fma (+ z y) x (* z y))))
(* 2.0 (* (sqrt (/ (+ y x) z)) z)))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -2.9e+26) {
tmp = (-2.0 * x) * sqrt(((y + z) / x));
} else if (y <= 46000000.0) {
tmp = 2.0 * sqrt(fma((z + y), x, (z * y)));
} else {
tmp = 2.0 * (sqrt(((y + x) / z)) * z);
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -2.9e+26) tmp = Float64(Float64(-2.0 * x) * sqrt(Float64(Float64(y + z) / x))); elseif (y <= 46000000.0) tmp = Float64(2.0 * sqrt(fma(Float64(z + y), x, Float64(z * y)))); else tmp = Float64(2.0 * Float64(sqrt(Float64(Float64(y + x) / 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.9e+26], N[(N[(-2.0 * x), $MachinePrecision] * N[Sqrt[N[(N[(y + z), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 46000000.0], N[(2.0 * N[Sqrt[N[(N[(z + y), $MachinePrecision] * x + N[(z * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[N[(N[(y + x), $MachinePrecision] / z), $MachinePrecision]], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{+26}:\\
\;\;\;\;\left(-2 \cdot x\right) \cdot \sqrt{\frac{y + z}{x}}\\
\mathbf{elif}\;y \leq 46000000:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z + y, x, z \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{\frac{y + x}{z}} \cdot z\right)\\
\end{array}
\end{array}
if y < -2.9e26Initial program 70.4%
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%
Taylor expanded in x around -inf
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-outN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
sqrt-divN/A
+-commutativeN/A
sqrt-divN/A
lift-/.f64N/A
lift-+.f64N/A
lift-sqrt.f6444.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6444.4
Applied rewrites44.4%
if -2.9e26 < y < 4.6e7Initial program 70.4%
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 4.6e7 < y Initial program 70.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6444.0
Applied rewrites44.0%
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+26)
(* (* -2.0 x) (sqrt (/ (+ y z) x)))
(if (<= y -3.7e-270)
(* 2.0 (sqrt (* (+ y z) x)))
(if (<= y 1.1e+27)
(* 2.0 (sqrt (* (+ y x) z)))
(* 2.0 (* (sqrt (/ z y)) y))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -2.8e+26) {
tmp = (-2.0 * x) * sqrt(((y + z) / x));
} else if (y <= -3.7e-270) {
tmp = 2.0 * sqrt(((y + z) * x));
} else if (y <= 1.1e+27) {
tmp = 2.0 * sqrt(((y + x) * z));
} else {
tmp = 2.0 * (sqrt((z / y)) * 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 <= (-2.8d+26)) then
tmp = ((-2.0d0) * x) * sqrt(((y + z) / x))
else if (y <= (-3.7d-270)) then
tmp = 2.0d0 * sqrt(((y + z) * x))
else if (y <= 1.1d+27) then
tmp = 2.0d0 * sqrt(((y + x) * z))
else
tmp = 2.0d0 * (sqrt((z / y)) * 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 <= -2.8e+26) {
tmp = (-2.0 * x) * Math.sqrt(((y + z) / x));
} else if (y <= -3.7e-270) {
tmp = 2.0 * Math.sqrt(((y + z) * x));
} else if (y <= 1.1e+27) {
tmp = 2.0 * Math.sqrt(((y + x) * z));
} else {
tmp = 2.0 * (Math.sqrt((z / y)) * y);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -2.8e+26: tmp = (-2.0 * x) * math.sqrt(((y + z) / x)) elif y <= -3.7e-270: tmp = 2.0 * math.sqrt(((y + z) * x)) elif y <= 1.1e+27: tmp = 2.0 * math.sqrt(((y + x) * z)) else: tmp = 2.0 * (math.sqrt((z / y)) * y) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -2.8e+26) tmp = Float64(Float64(-2.0 * x) * sqrt(Float64(Float64(y + z) / x))); elseif (y <= -3.7e-270) tmp = Float64(2.0 * sqrt(Float64(Float64(y + z) * x))); elseif (y <= 1.1e+27) tmp = Float64(2.0 * sqrt(Float64(Float64(y + x) * z))); else tmp = Float64(2.0 * Float64(sqrt(Float64(z / y)) * 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 <= -2.8e+26)
tmp = (-2.0 * x) * sqrt(((y + z) / x));
elseif (y <= -3.7e-270)
tmp = 2.0 * sqrt(((y + z) * x));
elseif (y <= 1.1e+27)
tmp = 2.0 * sqrt(((y + x) * z));
else
tmp = 2.0 * (sqrt((z / y)) * 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, -2.8e+26], N[(N[(-2.0 * x), $MachinePrecision] * N[Sqrt[N[(N[(y + z), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -3.7e-270], N[(2.0 * N[Sqrt[N[(N[(y + z), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+27], N[(2.0 * N[Sqrt[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[N[(z / y), $MachinePrecision]], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+26}:\\
\;\;\;\;\left(-2 \cdot x\right) \cdot \sqrt{\frac{y + z}{x}}\\
\mathbf{elif}\;y \leq -3.7 \cdot 10^{-270}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + z\right) \cdot x}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+27}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{\frac{z}{y}} \cdot y\right)\\
\end{array}
\end{array}
if y < -2.8e26Initial program 70.4%
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%
Taylor expanded in x around -inf
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-outN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
sqrt-divN/A
+-commutativeN/A
sqrt-divN/A
lift-/.f64N/A
lift-+.f64N/A
lift-sqrt.f6444.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6444.4
Applied rewrites44.4%
if -2.8e26 < y < -3.7000000000000001e-270Initial program 70.4%
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%
Taylor expanded in x around inf
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6436.9
Applied rewrites36.9%
if -3.7000000000000001e-270 < y < 1.0999999999999999e27Initial program 70.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6437.2
Applied rewrites37.2%
if 1.0999999999999999e27 < y Initial program 70.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6442.6
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -3e+26)
(* 2.0 (* (- y) (sqrt (/ x y))))
(if (<= y -3.7e-270)
(* 2.0 (sqrt (* (+ y z) x)))
(if (<= y 1.1e+27)
(* 2.0 (sqrt (* (+ y x) z)))
(* 2.0 (* (sqrt (/ z y)) y))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -3e+26) {
tmp = 2.0 * (-y * sqrt((x / y)));
} else if (y <= -3.7e-270) {
tmp = 2.0 * sqrt(((y + z) * x));
} else if (y <= 1.1e+27) {
tmp = 2.0 * sqrt(((y + x) * z));
} else {
tmp = 2.0 * (sqrt((z / y)) * 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 <= (-3d+26)) then
tmp = 2.0d0 * (-y * sqrt((x / y)))
else if (y <= (-3.7d-270)) then
tmp = 2.0d0 * sqrt(((y + z) * x))
else if (y <= 1.1d+27) then
tmp = 2.0d0 * sqrt(((y + x) * z))
else
tmp = 2.0d0 * (sqrt((z / y)) * 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 <= -3e+26) {
tmp = 2.0 * (-y * Math.sqrt((x / y)));
} else if (y <= -3.7e-270) {
tmp = 2.0 * Math.sqrt(((y + z) * x));
} else if (y <= 1.1e+27) {
tmp = 2.0 * Math.sqrt(((y + x) * z));
} else {
tmp = 2.0 * (Math.sqrt((z / y)) * y);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -3e+26: tmp = 2.0 * (-y * math.sqrt((x / y))) elif y <= -3.7e-270: tmp = 2.0 * math.sqrt(((y + z) * x)) elif y <= 1.1e+27: tmp = 2.0 * math.sqrt(((y + x) * z)) else: tmp = 2.0 * (math.sqrt((z / y)) * y) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -3e+26) tmp = Float64(2.0 * Float64(Float64(-y) * sqrt(Float64(x / y)))); elseif (y <= -3.7e-270) tmp = Float64(2.0 * sqrt(Float64(Float64(y + z) * x))); elseif (y <= 1.1e+27) tmp = Float64(2.0 * sqrt(Float64(Float64(y + x) * z))); else tmp = Float64(2.0 * Float64(sqrt(Float64(z / y)) * 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 <= -3e+26)
tmp = 2.0 * (-y * sqrt((x / y)));
elseif (y <= -3.7e-270)
tmp = 2.0 * sqrt(((y + z) * x));
elseif (y <= 1.1e+27)
tmp = 2.0 * sqrt(((y + x) * z));
else
tmp = 2.0 * (sqrt((z / y)) * 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, -3e+26], N[(2.0 * N[((-y) * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -3.7e-270], N[(2.0 * N[Sqrt[N[(N[(y + z), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+27], N[(2.0 * N[Sqrt[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[N[(z / y), $MachinePrecision]], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+26}:\\
\;\;\;\;2 \cdot \left(\left(-y\right) \cdot \sqrt{\frac{x}{y}}\right)\\
\mathbf{elif}\;y \leq -3.7 \cdot 10^{-270}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + z\right) \cdot x}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+27}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{\frac{z}{y}} \cdot y\right)\\
\end{array}
\end{array}
if y < -2.99999999999999997e26Initial program 70.4%
Taylor expanded in z around 0
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f6435.2
Applied rewrites35.2%
Taylor expanded in y around -inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6443.1
Applied rewrites43.1%
if -2.99999999999999997e26 < y < -3.7000000000000001e-270Initial program 70.4%
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%
Taylor expanded in x around inf
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6436.9
Applied rewrites36.9%
if -3.7000000000000001e-270 < y < 1.0999999999999999e27Initial program 70.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6437.2
Applied rewrites37.2%
if 1.0999999999999999e27 < y Initial program 70.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6442.6
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -3e+26)
(* (* -2.0 x) (sqrt (/ y x)))
(if (<= y -3.7e-270)
(* 2.0 (sqrt (* (+ y z) x)))
(if (<= y 1.1e+27)
(* 2.0 (sqrt (* (+ y x) z)))
(* 2.0 (* (sqrt (/ z y)) y))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -3e+26) {
tmp = (-2.0 * x) * sqrt((y / x));
} else if (y <= -3.7e-270) {
tmp = 2.0 * sqrt(((y + z) * x));
} else if (y <= 1.1e+27) {
tmp = 2.0 * sqrt(((y + x) * z));
} else {
tmp = 2.0 * (sqrt((z / y)) * 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 <= (-3d+26)) then
tmp = ((-2.0d0) * x) * sqrt((y / x))
else if (y <= (-3.7d-270)) then
tmp = 2.0d0 * sqrt(((y + z) * x))
else if (y <= 1.1d+27) then
tmp = 2.0d0 * sqrt(((y + x) * z))
else
tmp = 2.0d0 * (sqrt((z / y)) * 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 <= -3e+26) {
tmp = (-2.0 * x) * Math.sqrt((y / x));
} else if (y <= -3.7e-270) {
tmp = 2.0 * Math.sqrt(((y + z) * x));
} else if (y <= 1.1e+27) {
tmp = 2.0 * Math.sqrt(((y + x) * z));
} else {
tmp = 2.0 * (Math.sqrt((z / y)) * y);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -3e+26: tmp = (-2.0 * x) * math.sqrt((y / x)) elif y <= -3.7e-270: tmp = 2.0 * math.sqrt(((y + z) * x)) elif y <= 1.1e+27: tmp = 2.0 * math.sqrt(((y + x) * z)) else: tmp = 2.0 * (math.sqrt((z / y)) * y) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -3e+26) tmp = Float64(Float64(-2.0 * x) * sqrt(Float64(y / x))); elseif (y <= -3.7e-270) tmp = Float64(2.0 * sqrt(Float64(Float64(y + z) * x))); elseif (y <= 1.1e+27) tmp = Float64(2.0 * sqrt(Float64(Float64(y + x) * z))); else tmp = Float64(2.0 * Float64(sqrt(Float64(z / y)) * 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 <= -3e+26)
tmp = (-2.0 * x) * sqrt((y / x));
elseif (y <= -3.7e-270)
tmp = 2.0 * sqrt(((y + z) * x));
elseif (y <= 1.1e+27)
tmp = 2.0 * sqrt(((y + x) * z));
else
tmp = 2.0 * (sqrt((z / y)) * 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, -3e+26], N[(N[(-2.0 * x), $MachinePrecision] * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -3.7e-270], N[(2.0 * N[Sqrt[N[(N[(y + z), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+27], N[(2.0 * N[Sqrt[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[N[(z / y), $MachinePrecision]], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+26}:\\
\;\;\;\;\left(-2 \cdot x\right) \cdot \sqrt{\frac{y}{x}}\\
\mathbf{elif}\;y \leq -3.7 \cdot 10^{-270}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + z\right) \cdot x}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+27}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{\frac{z}{y}} \cdot y\right)\\
\end{array}
\end{array}
if y < -2.99999999999999997e26Initial program 70.4%
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%
Taylor expanded in x around -inf
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-outN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
sqrt-divN/A
+-commutativeN/A
sqrt-divN/A
lift-/.f64N/A
lift-+.f64N/A
lift-sqrt.f6444.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in y around inf
lower-/.f6443.4
Applied rewrites43.4%
if -2.99999999999999997e26 < y < -3.7000000000000001e-270Initial program 70.4%
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%
Taylor expanded in x around inf
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6436.9
Applied rewrites36.9%
if -3.7000000000000001e-270 < y < 1.0999999999999999e27Initial program 70.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6437.2
Applied rewrites37.2%
if 1.0999999999999999e27 < y Initial program 70.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6442.6
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -2.7e+26)
(* (* -2.0 x) (sqrt (/ (+ y z) x)))
(if (<= y 750000.0)
(* 2.0 (sqrt (* (+ z x) y)))
(* 2.0 (* (sqrt (/ (+ y x) z)) z)))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+26) {
tmp = (-2.0 * x) * sqrt(((y + z) / x));
} else if (y <= 750000.0) {
tmp = 2.0 * sqrt(((z + x) * y));
} else {
tmp = 2.0 * (sqrt(((y + x) / 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.7d+26)) then
tmp = ((-2.0d0) * x) * sqrt(((y + z) / x))
else if (y <= 750000.0d0) then
tmp = 2.0d0 * sqrt(((z + x) * y))
else
tmp = 2.0d0 * (sqrt(((y + x) / 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.7e+26) {
tmp = (-2.0 * x) * Math.sqrt(((y + z) / x));
} else if (y <= 750000.0) {
tmp = 2.0 * Math.sqrt(((z + x) * y));
} else {
tmp = 2.0 * (Math.sqrt(((y + x) / z)) * z);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -2.7e+26: tmp = (-2.0 * x) * math.sqrt(((y + z) / x)) elif y <= 750000.0: tmp = 2.0 * math.sqrt(((z + x) * y)) else: tmp = 2.0 * (math.sqrt(((y + x) / z)) * z) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -2.7e+26) tmp = Float64(Float64(-2.0 * x) * sqrt(Float64(Float64(y + z) / x))); elseif (y <= 750000.0) tmp = Float64(2.0 * sqrt(Float64(Float64(z + x) * y))); else tmp = Float64(2.0 * Float64(sqrt(Float64(Float64(y + x) / 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.7e+26)
tmp = (-2.0 * x) * sqrt(((y + z) / x));
elseif (y <= 750000.0)
tmp = 2.0 * sqrt(((z + x) * y));
else
tmp = 2.0 * (sqrt(((y + x) / 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.7e+26], N[(N[(-2.0 * x), $MachinePrecision] * N[Sqrt[N[(N[(y + z), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 750000.0], N[(2.0 * N[Sqrt[N[(N[(z + x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[N[(N[(y + x), $MachinePrecision] / z), $MachinePrecision]], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+26}:\\
\;\;\;\;\left(-2 \cdot x\right) \cdot \sqrt{\frac{y + z}{x}}\\
\mathbf{elif}\;y \leq 750000:\\
\;\;\;\;2 \cdot \sqrt{\left(z + x\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{\frac{y + x}{z}} \cdot z\right)\\
\end{array}
\end{array}
if y < -2.7e26Initial program 70.4%
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%
Taylor expanded in x around -inf
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-outN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
sqrt-divN/A
+-commutativeN/A
sqrt-divN/A
lift-/.f64N/A
lift-+.f64N/A
lift-sqrt.f6444.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6444.4
Applied rewrites44.4%
if -2.7e26 < y < 7.5e5Initial program 70.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6468.1
Applied rewrites68.1%
if 7.5e5 < y Initial program 70.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6444.0
Applied rewrites44.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -3e+26)
(* (* -2.0 x) (sqrt (/ y x)))
(if (<= y -3.7e-270)
(* 2.0 (sqrt (* (+ y z) x)))
(* 2.0 (sqrt (* (+ y x) z))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -3e+26) {
tmp = (-2.0 * x) * sqrt((y / x));
} else if (y <= -3.7e-270) {
tmp = 2.0 * sqrt(((y + z) * 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 <= (-3d+26)) then
tmp = ((-2.0d0) * x) * sqrt((y / x))
else if (y <= (-3.7d-270)) then
tmp = 2.0d0 * sqrt(((y + z) * 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 <= -3e+26) {
tmp = (-2.0 * x) * Math.sqrt((y / x));
} else if (y <= -3.7e-270) {
tmp = 2.0 * Math.sqrt(((y + z) * 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 <= -3e+26: tmp = (-2.0 * x) * math.sqrt((y / x)) elif y <= -3.7e-270: tmp = 2.0 * math.sqrt(((y + z) * 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 <= -3e+26) tmp = Float64(Float64(-2.0 * x) * sqrt(Float64(y / x))); elseif (y <= -3.7e-270) tmp = Float64(2.0 * sqrt(Float64(Float64(y + z) * 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 <= -3e+26)
tmp = (-2.0 * x) * sqrt((y / x));
elseif (y <= -3.7e-270)
tmp = 2.0 * sqrt(((y + z) * 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, -3e+26], N[(N[(-2.0 * x), $MachinePrecision] * N[Sqrt[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -3.7e-270], N[(2.0 * N[Sqrt[N[(N[(y + z), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+26}:\\
\;\;\;\;\left(-2 \cdot x\right) \cdot \sqrt{\frac{y}{x}}\\
\mathbf{elif}\;y \leq -3.7 \cdot 10^{-270}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + z\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
\end{array}
\end{array}
if y < -2.99999999999999997e26Initial program 70.4%
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%
Taylor expanded in x around -inf
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-outN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
sqrt-divN/A
+-commutativeN/A
sqrt-divN/A
lift-/.f64N/A
lift-+.f64N/A
lift-sqrt.f6444.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in y around inf
lower-/.f6443.4
Applied rewrites43.4%
if -2.99999999999999997e26 < y < -3.7000000000000001e-270Initial program 70.4%
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%
Taylor expanded in x around inf
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6436.9
Applied rewrites36.9%
if -3.7000000000000001e-270 < y Initial program 70.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6437.2
Applied rewrites37.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -3.7e-270) (* 2.0 (sqrt (* (+ y z) x))) (* 2.0 (sqrt (* (+ y x) z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -3.7e-270) {
tmp = 2.0 * sqrt(((y + z) * 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 <= (-3.7d-270)) then
tmp = 2.0d0 * sqrt(((y + z) * 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 <= -3.7e-270) {
tmp = 2.0 * Math.sqrt(((y + z) * 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 <= -3.7e-270: tmp = 2.0 * math.sqrt(((y + z) * 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 <= -3.7e-270) tmp = Float64(2.0 * sqrt(Float64(Float64(y + z) * 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 <= -3.7e-270)
tmp = 2.0 * sqrt(((y + z) * 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, -3.7e-270], N[(2.0 * N[Sqrt[N[(N[(y + z), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{-270}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + z\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
\end{array}
\end{array}
if y < -3.7000000000000001e-270Initial program 70.4%
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%
Taylor expanded in x around inf
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6436.9
Applied rewrites36.9%
if -3.7000000000000001e-270 < y Initial program 70.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6437.2
Applied rewrites37.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -3.2e-262) (* 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 <= -3.2e-262) {
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 <= (-3.2d-262)) 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 <= -3.2e-262) {
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 <= -3.2e-262: 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 <= -3.2e-262) 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 <= -3.2e-262)
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, -3.2e-262], 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 -3.2 \cdot 10^{-262}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
\end{array}
\end{array}
if y < -3.2e-262Initial program 70.4%
Taylor expanded in z around 0
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f6435.2
Applied rewrites35.2%
if -3.2e-262 < y Initial program 70.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6437.2
Applied rewrites37.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -3.7e-270) (* 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 <= -3.7e-270) {
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 <= (-3.7d-270)) 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 <= -3.7e-270) {
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 <= -3.7e-270: 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 <= -3.7e-270) 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 <= -3.7e-270)
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, -3.7e-270], 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 -3.7 \cdot 10^{-270}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot y}\\
\end{array}
\end{array}
if y < -3.7000000000000001e-270Initial program 70.4%
Taylor expanded in z around 0
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f6435.2
Applied rewrites35.2%
if -3.7000000000000001e-270 < y Initial program 70.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f6435.6
Applied rewrites35.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* 2.0 (sqrt (* y x))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return 2.0 * sqrt((y * x));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((y * x))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((y * x));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return 2.0 * math.sqrt((y * x))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(2.0 * sqrt(Float64(y * x))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = 2.0 * sqrt((y * x));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \sqrt{y \cdot x}
\end{array}
Initial program 70.4%
Taylor expanded in z around 0
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f6435.2
Applied rewrites35.2%
herbie shell --seed 2025142
(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)))))