
(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 14 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
(let* ((t_0 (fma -1.0 y (* -1.0 z))))
(if (<= y -4.6e+23)
(* 2.0 (/ t_0 (sqrt (* -1.0 (/ t_0 x)))))
(if (<= y 4.4e-284)
(* (sqrt (fma (+ z x) y (* z x))) 2.0)
(* (* z (/ (sqrt (+ x y)) (sqrt z))) 2.0)))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = fma(-1.0, y, (-1.0 * z));
double tmp;
if (y <= -4.6e+23) {
tmp = 2.0 * (t_0 / sqrt((-1.0 * (t_0 / x))));
} else if (y <= 4.4e-284) {
tmp = sqrt(fma((z + x), y, (z * x))) * 2.0;
} else {
tmp = (z * (sqrt((x + y)) / sqrt(z))) * 2.0;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = fma(-1.0, y, Float64(-1.0 * z)) tmp = 0.0 if (y <= -4.6e+23) tmp = Float64(2.0 * Float64(t_0 / sqrt(Float64(-1.0 * Float64(t_0 / x))))); elseif (y <= 4.4e-284) tmp = Float64(sqrt(fma(Float64(z + x), y, Float64(z * x))) * 2.0); else tmp = Float64(Float64(z * Float64(sqrt(Float64(x + y)) / sqrt(z))) * 2.0); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(-1.0 * y + N[(-1.0 * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.6e+23], N[(2.0 * N[(t$95$0 / N[Sqrt[N[(-1.0 * N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.4e-284], N[(N[Sqrt[N[(N[(z + x), $MachinePrecision] * y + N[(z * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(z * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-1, y, -1 \cdot z\right)\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{+23}:\\
\;\;\;\;2 \cdot \frac{t\_0}{\sqrt{-1 \cdot \frac{t\_0}{x}}}\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-284}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(z + x, y, z \cdot x\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot 2\\
\end{array}
\end{array}
if y < -4.6000000000000001e23Initial program 70.5%
lift-sqrt.f64N/A
sqrt-fabs-revN/A
lift-sqrt.f64N/A
rem-sqrt-square-revN/A
pow1/2N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
metadata-evalN/A
pow-subN/A
lower-special-pow.f32N/A
lower-pow.f32N/A
unpow1N/A
lower-special-pow.f32N/A
lower-pow.f32N/A
pow1/2N/A
Applied rewrites68.6%
Taylor expanded in x around -inf
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f6444.7
Applied rewrites44.7%
if -4.6000000000000001e23 < y < 4.4000000000000001e-284Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
if 4.4000000000000001e-284 < y Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6444.0
Applied rewrites44.0%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-special-/.f64N/A
lower-special-sqrt.f64N/A
lower-special-sqrt.f6449.3
Applied rewrites49.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -4.6e+23)
(* -2.0 (* x (sqrt (* -1.0 (/ (fma -1.0 y (* -1.0 z)) x)))))
(if (<= y 4.4e-284)
(* (sqrt (fma (+ z x) y (* z x))) 2.0)
(* (* z (/ (sqrt (+ x y)) (sqrt z))) 2.0))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -4.6e+23) {
tmp = -2.0 * (x * sqrt((-1.0 * (fma(-1.0, y, (-1.0 * z)) / x))));
} else if (y <= 4.4e-284) {
tmp = sqrt(fma((z + x), y, (z * x))) * 2.0;
} else {
tmp = (z * (sqrt((x + y)) / sqrt(z))) * 2.0;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -4.6e+23) tmp = Float64(-2.0 * Float64(x * sqrt(Float64(-1.0 * Float64(fma(-1.0, y, Float64(-1.0 * z)) / x))))); elseif (y <= 4.4e-284) tmp = Float64(sqrt(fma(Float64(z + x), y, Float64(z * x))) * 2.0); else tmp = Float64(Float64(z * Float64(sqrt(Float64(x + y)) / sqrt(z))) * 2.0); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -4.6e+23], 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, 4.4e-284], N[(N[Sqrt[N[(N[(z + x), $MachinePrecision] * y + N[(z * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(z * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.6 \cdot 10^{+23}:\\
\;\;\;\;-2 \cdot \left(x \cdot \sqrt{-1 \cdot \frac{\mathsf{fma}\left(-1, y, -1 \cdot z\right)}{x}}\right)\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-284}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(z + x, y, z \cdot x\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot 2\\
\end{array}
\end{array}
if y < -4.6000000000000001e23Initial program 70.5%
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-*.f6444.4
Applied rewrites44.4%
if -4.6000000000000001e23 < y < 4.4000000000000001e-284Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
if 4.4000000000000001e-284 < y Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6444.0
Applied rewrites44.0%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-special-/.f64N/A
lower-special-sqrt.f64N/A
lower-special-sqrt.f6449.3
Applied rewrites49.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -4.7e+23)
(* -2.0 (* y (sqrt (* -1.0 (* (/ -1.0 y) (+ x z))))))
(if (<= y 4.4e-284)
(* (sqrt (fma (+ z x) y (* z x))) 2.0)
(* (* z (/ (sqrt (+ x y)) (sqrt z))) 2.0))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -4.7e+23) {
tmp = -2.0 * (y * sqrt((-1.0 * ((-1.0 / y) * (x + z)))));
} else if (y <= 4.4e-284) {
tmp = sqrt(fma((z + x), y, (z * x))) * 2.0;
} else {
tmp = (z * (sqrt((x + y)) / sqrt(z))) * 2.0;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -4.7e+23) tmp = Float64(-2.0 * Float64(y * sqrt(Float64(-1.0 * Float64(Float64(-1.0 / y) * Float64(x + z)))))); elseif (y <= 4.4e-284) tmp = Float64(sqrt(fma(Float64(z + x), y, Float64(z * x))) * 2.0); else tmp = Float64(Float64(z * Float64(sqrt(Float64(x + y)) / sqrt(z))) * 2.0); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -4.7e+23], N[(-2.0 * N[(y * N[Sqrt[N[(-1.0 * N[(N[(-1.0 / y), $MachinePrecision] * N[(x + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.4e-284], N[(N[Sqrt[N[(N[(z + x), $MachinePrecision] * y + N[(z * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(z * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{+23}:\\
\;\;\;\;-2 \cdot \left(y \cdot \sqrt{-1 \cdot \left(\frac{-1}{y} \cdot \left(x + z\right)\right)}\right)\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-284}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(z + x, y, z \cdot x\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot 2\\
\end{array}
\end{array}
if y < -4.6999999999999997e23Initial program 70.5%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f6443.1
Applied rewrites43.1%
Applied rewrites43.1%
if -4.6999999999999997e23 < y < 4.4000000000000001e-284Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
if 4.4000000000000001e-284 < y Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6444.0
Applied rewrites44.0%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-special-/.f64N/A
lower-special-sqrt.f64N/A
lower-special-sqrt.f6449.3
Applied rewrites49.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -4.7e+23)
(* -2.0 (* y (sqrt (/ x y))))
(if (<= y 4.4e-284)
(* (sqrt (fma (+ z x) y (* z x))) 2.0)
(* (* z (/ (sqrt (+ x y)) (sqrt z))) 2.0))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -4.7e+23) {
tmp = -2.0 * (y * sqrt((x / y)));
} else if (y <= 4.4e-284) {
tmp = sqrt(fma((z + x), y, (z * x))) * 2.0;
} else {
tmp = (z * (sqrt((x + y)) / sqrt(z))) * 2.0;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -4.7e+23) tmp = Float64(-2.0 * Float64(y * sqrt(Float64(x / y)))); elseif (y <= 4.4e-284) tmp = Float64(sqrt(fma(Float64(z + x), y, Float64(z * x))) * 2.0); else tmp = Float64(Float64(z * Float64(sqrt(Float64(x + y)) / sqrt(z))) * 2.0); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -4.7e+23], N[(-2.0 * N[(y * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.4e-284], N[(N[Sqrt[N[(N[(z + x), $MachinePrecision] * y + N[(z * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(z * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{+23}:\\
\;\;\;\;-2 \cdot \left(y \cdot \sqrt{\frac{x}{y}}\right)\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-284}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(z + x, y, z \cdot x\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot 2\\
\end{array}
\end{array}
if y < -4.6999999999999997e23Initial program 70.5%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f6443.1
Applied rewrites43.1%
Taylor expanded in z around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6443.1
Applied rewrites43.1%
if -4.6999999999999997e23 < y < 4.4000000000000001e-284Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
if 4.4000000000000001e-284 < y Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6444.0
Applied rewrites44.0%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-special-/.f64N/A
lower-special-sqrt.f64N/A
lower-special-sqrt.f6449.3
Applied rewrites49.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -4.7e+23)
(* -2.0 (* y (sqrt (/ x y))))
(if (<= y 1.1e-259)
(* (sqrt (fma (+ z x) y (* z x))) 2.0)
(* 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 <= -4.7e+23) {
tmp = -2.0 * (y * sqrt((x / y)));
} else if (y <= 1.1e-259) {
tmp = sqrt(fma((z + x), y, (z * x))) * 2.0;
} 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 <= -4.7e+23) tmp = Float64(-2.0 * Float64(y * sqrt(Float64(x / y)))); elseif (y <= 1.1e-259) tmp = Float64(sqrt(fma(Float64(z + x), y, Float64(z * x))) * 2.0); 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, -4.7e+23], N[(-2.0 * N[(y * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e-259], N[(N[Sqrt[N[(N[(z + x), $MachinePrecision] * y + N[(z * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $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 -4.7 \cdot 10^{+23}:\\
\;\;\;\;-2 \cdot \left(y \cdot \sqrt{\frac{x}{y}}\right)\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-259}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(z + x, y, z \cdot x\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \frac{\sqrt{x + z}}{\sqrt{y}}\right)\\
\end{array}
\end{array}
if y < -4.6999999999999997e23Initial program 70.5%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f6443.1
Applied rewrites43.1%
Taylor expanded in z around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6443.1
Applied rewrites43.1%
if -4.6999999999999997e23 < y < 1.10000000000000005e-259Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
if 1.10000000000000005e-259 < y Initial program 70.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6442.6
Applied rewrites42.6%
Applied rewrites47.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -4.7e+23)
(* -2.0 (* y (sqrt (/ x y))))
(if (<= y 1.1e-259)
(* (sqrt (fma (+ z x) y (* z x))) 2.0)
(* 2.0 (* (sqrt (+ x z)) (sqrt y))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -4.7e+23) {
tmp = -2.0 * (y * sqrt((x / y)));
} else if (y <= 1.1e-259) {
tmp = sqrt(fma((z + x), y, (z * x))) * 2.0;
} else {
tmp = 2.0 * (sqrt((x + z)) * sqrt(y));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -4.7e+23) tmp = Float64(-2.0 * Float64(y * sqrt(Float64(x / y)))); elseif (y <= 1.1e-259) tmp = Float64(sqrt(fma(Float64(z + x), y, Float64(z * x))) * 2.0); else tmp = Float64(2.0 * 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, -4.7e+23], N[(-2.0 * N[(y * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e-259], N[(N[Sqrt[N[(N[(z + x), $MachinePrecision] * y + N[(z * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(2.0 * N[(N[Sqrt[N[(x + z), $MachinePrecision]], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{+23}:\\
\;\;\;\;-2 \cdot \left(y \cdot \sqrt{\frac{x}{y}}\right)\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-259}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(z + x, y, z \cdot x\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{x + z} \cdot \sqrt{y}\right)\\
\end{array}
\end{array}
if y < -4.6999999999999997e23Initial program 70.5%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f6443.1
Applied rewrites43.1%
Taylor expanded in z around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6443.1
Applied rewrites43.1%
if -4.6999999999999997e23 < y < 1.10000000000000005e-259Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
if 1.10000000000000005e-259 < y Initial program 70.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6442.6
Applied rewrites42.6%
Applied rewrites47.9%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-sqrt.f64N/A
pow1/2N/A
pow-flipN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6448.0
Applied rewrites48.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -4.7e+23)
(* -2.0 (* y (sqrt (/ x y))))
(if (<= y 4.4e-284)
(* (sqrt (* x (+ y z))) 2.0)
(* 2.0 (* (sqrt (+ x z)) (sqrt y))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -4.7e+23) {
tmp = -2.0 * (y * sqrt((x / y)));
} else if (y <= 4.4e-284) {
tmp = sqrt((x * (y + z))) * 2.0;
} else {
tmp = 2.0 * (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 <= (-4.7d+23)) then
tmp = (-2.0d0) * (y * sqrt((x / y)))
else if (y <= 4.4d-284) then
tmp = sqrt((x * (y + z))) * 2.0d0
else
tmp = 2.0d0 * (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 <= -4.7e+23) {
tmp = -2.0 * (y * Math.sqrt((x / y)));
} else if (y <= 4.4e-284) {
tmp = Math.sqrt((x * (y + z))) * 2.0;
} else {
tmp = 2.0 * (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 <= -4.7e+23: tmp = -2.0 * (y * math.sqrt((x / y))) elif y <= 4.4e-284: tmp = math.sqrt((x * (y + z))) * 2.0 else: tmp = 2.0 * (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 <= -4.7e+23) tmp = Float64(-2.0 * Float64(y * sqrt(Float64(x / y)))); elseif (y <= 4.4e-284) tmp = Float64(sqrt(Float64(x * Float64(y + z))) * 2.0); else tmp = Float64(2.0 * 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 <= -4.7e+23)
tmp = -2.0 * (y * sqrt((x / y)));
elseif (y <= 4.4e-284)
tmp = sqrt((x * (y + z))) * 2.0;
else
tmp = 2.0 * (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, -4.7e+23], N[(-2.0 * N[(y * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.4e-284], N[(N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(2.0 * N[(N[Sqrt[N[(x + z), $MachinePrecision]], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{+23}:\\
\;\;\;\;-2 \cdot \left(y \cdot \sqrt{\frac{x}{y}}\right)\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-284}:\\
\;\;\;\;\sqrt{x \cdot \left(y + z\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{x + z} \cdot \sqrt{y}\right)\\
\end{array}
\end{array}
if y < -4.6999999999999997e23Initial program 70.5%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f6443.1
Applied rewrites43.1%
Taylor expanded in z around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6443.1
Applied rewrites43.1%
if -4.6999999999999997e23 < y < 4.4000000000000001e-284Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6437.4
Applied rewrites37.4%
if 4.4000000000000001e-284 < y Initial program 70.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6442.6
Applied rewrites42.6%
Applied rewrites47.9%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-sqrt.f64N/A
pow1/2N/A
pow-flipN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6448.0
Applied rewrites48.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -4.7e+23)
(* -2.0 (* y (sqrt (/ x y))))
(if (<= y 5e-296)
(* (sqrt (* x (+ y z))) 2.0)
(if (<= y 64000000.0)
(* 2.0 (sqrt (* z (+ x y))))
(* 2.0 (* y (sqrt (/ z y))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -4.7e+23) {
tmp = -2.0 * (y * sqrt((x / y)));
} else if (y <= 5e-296) {
tmp = sqrt((x * (y + z))) * 2.0;
} else if (y <= 64000000.0) {
tmp = 2.0 * sqrt((z * (x + y)));
} 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 <= (-4.7d+23)) then
tmp = (-2.0d0) * (y * sqrt((x / y)))
else if (y <= 5d-296) then
tmp = sqrt((x * (y + z))) * 2.0d0
else if (y <= 64000000.0d0) then
tmp = 2.0d0 * sqrt((z * (x + y)))
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 <= -4.7e+23) {
tmp = -2.0 * (y * Math.sqrt((x / y)));
} else if (y <= 5e-296) {
tmp = Math.sqrt((x * (y + z))) * 2.0;
} else if (y <= 64000000.0) {
tmp = 2.0 * Math.sqrt((z * (x + y)));
} 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 <= -4.7e+23: tmp = -2.0 * (y * math.sqrt((x / y))) elif y <= 5e-296: tmp = math.sqrt((x * (y + z))) * 2.0 elif y <= 64000000.0: tmp = 2.0 * math.sqrt((z * (x + y))) 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 <= -4.7e+23) tmp = Float64(-2.0 * Float64(y * sqrt(Float64(x / y)))); elseif (y <= 5e-296) tmp = Float64(sqrt(Float64(x * Float64(y + z))) * 2.0); elseif (y <= 64000000.0) tmp = Float64(2.0 * sqrt(Float64(z * Float64(x + y)))); 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 <= -4.7e+23)
tmp = -2.0 * (y * sqrt((x / y)));
elseif (y <= 5e-296)
tmp = sqrt((x * (y + z))) * 2.0;
elseif (y <= 64000000.0)
tmp = 2.0 * sqrt((z * (x + y)));
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, -4.7e+23], N[(-2.0 * N[(y * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e-296], N[(N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], If[LessEqual[y, 64000000.0], N[(2.0 * N[Sqrt[N[(z * N[(x + y), $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 -4.7 \cdot 10^{+23}:\\
\;\;\;\;-2 \cdot \left(y \cdot \sqrt{\frac{x}{y}}\right)\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-296}:\\
\;\;\;\;\sqrt{x \cdot \left(y + z\right)} \cdot 2\\
\mathbf{elif}\;y \leq 64000000:\\
\;\;\;\;2 \cdot \sqrt{z \cdot \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot \sqrt{\frac{z}{y}}\right)\\
\end{array}
\end{array}
if y < -4.6999999999999997e23Initial program 70.5%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f6443.1
Applied rewrites43.1%
Taylor expanded in z around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6443.1
Applied rewrites43.1%
if -4.6999999999999997e23 < y < 5.0000000000000003e-296Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6437.4
Applied rewrites37.4%
if 5.0000000000000003e-296 < y < 6.4e7Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6436.9
Applied rewrites36.9%
if 6.4e7 < y Initial program 70.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6442.6
Applied rewrites42.6%
Taylor expanded in x around 0
lower-/.f6442.6
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 -4.7e+23)
(* -2.0 (* y (sqrt (/ x y))))
(if (<= y 5e-296)
(* (sqrt (* x (+ y z))) 2.0)
(* 2.0 (sqrt (* z (+ x y)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -4.7e+23) {
tmp = -2.0 * (y * sqrt((x / y)));
} else if (y <= 5e-296) {
tmp = sqrt((x * (y + z))) * 2.0;
} else {
tmp = 2.0 * sqrt((z * (x + 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 <= (-4.7d+23)) then
tmp = (-2.0d0) * (y * sqrt((x / y)))
else if (y <= 5d-296) then
tmp = sqrt((x * (y + z))) * 2.0d0
else
tmp = 2.0d0 * sqrt((z * (x + 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 <= -4.7e+23) {
tmp = -2.0 * (y * Math.sqrt((x / y)));
} else if (y <= 5e-296) {
tmp = Math.sqrt((x * (y + z))) * 2.0;
} else {
tmp = 2.0 * Math.sqrt((z * (x + y)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -4.7e+23: tmp = -2.0 * (y * math.sqrt((x / y))) elif y <= 5e-296: tmp = math.sqrt((x * (y + z))) * 2.0 else: tmp = 2.0 * math.sqrt((z * (x + y))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -4.7e+23) tmp = Float64(-2.0 * Float64(y * sqrt(Float64(x / y)))); elseif (y <= 5e-296) tmp = Float64(sqrt(Float64(x * Float64(y + z))) * 2.0); else tmp = Float64(2.0 * sqrt(Float64(z * Float64(x + 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 <= -4.7e+23)
tmp = -2.0 * (y * sqrt((x / y)));
elseif (y <= 5e-296)
tmp = sqrt((x * (y + z))) * 2.0;
else
tmp = 2.0 * sqrt((z * (x + 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, -4.7e+23], N[(-2.0 * N[(y * N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e-296], N[(N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(2.0 * N[Sqrt[N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{+23}:\\
\;\;\;\;-2 \cdot \left(y \cdot \sqrt{\frac{x}{y}}\right)\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-296}:\\
\;\;\;\;\sqrt{x \cdot \left(y + z\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot \left(x + y\right)}\\
\end{array}
\end{array}
if y < -4.6999999999999997e23Initial program 70.5%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f6443.1
Applied rewrites43.1%
Taylor expanded in z around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6443.1
Applied rewrites43.1%
if -4.6999999999999997e23 < y < 5.0000000000000003e-296Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6437.4
Applied rewrites37.4%
if 5.0000000000000003e-296 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6436.9
Applied rewrites36.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 5e-296) (* (sqrt (* x (+ y z))) 2.0) (* 2.0 (sqrt (* z (+ x y))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 5e-296) {
tmp = sqrt((x * (y + z))) * 2.0;
} else {
tmp = 2.0 * sqrt((z * (x + 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 <= 5d-296) then
tmp = sqrt((x * (y + z))) * 2.0d0
else
tmp = 2.0d0 * sqrt((z * (x + 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 <= 5e-296) {
tmp = Math.sqrt((x * (y + z))) * 2.0;
} else {
tmp = 2.0 * Math.sqrt((z * (x + y)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= 5e-296: tmp = math.sqrt((x * (y + z))) * 2.0 else: tmp = 2.0 * math.sqrt((z * (x + y))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 5e-296) tmp = Float64(sqrt(Float64(x * Float64(y + z))) * 2.0); else tmp = Float64(2.0 * sqrt(Float64(z * Float64(x + 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 <= 5e-296)
tmp = sqrt((x * (y + z))) * 2.0;
else
tmp = 2.0 * sqrt((z * (x + 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, 5e-296], N[(N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(2.0 * N[Sqrt[N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-296}:\\
\;\;\;\;\sqrt{x \cdot \left(y + z\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot \left(x + y\right)}\\
\end{array}
\end{array}
if y < 5.0000000000000003e-296Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6437.4
Applied rewrites37.4%
if 5.0000000000000003e-296 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6436.9
Applied rewrites36.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* 2.0 (sqrt (* 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 70.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6468.5
Applied rewrites68.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -1.35e-285) (* 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 <= -1.35e-285) {
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 <= (-1.35d-285)) 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 <= -1.35e-285) {
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 <= -1.35e-285: 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 <= -1.35e-285) 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 <= -1.35e-285)
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, -1.35e-285], 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 -1.35 \cdot 10^{-285}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot z}\\
\end{array}
\end{array}
if y < -1.3499999999999999e-285Initial program 70.5%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
if -1.3499999999999999e-285 < y Initial program 70.5%
Taylor expanded in x around 0
lower-*.f6435.4
Applied rewrites35.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -2.4e-308) (* 2.0 (sqrt (* x y))) (* (sqrt (fabs (* y z))) 2.0)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -2.4e-308) {
tmp = 2.0 * sqrt((x * y));
} else {
tmp = sqrt(fabs((y * z))) * 2.0;
}
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.4d-308)) then
tmp = 2.0d0 * sqrt((x * y))
else
tmp = sqrt(abs((y * z))) * 2.0d0
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.4e-308) {
tmp = 2.0 * Math.sqrt((x * y));
} else {
tmp = Math.sqrt(Math.abs((y * z))) * 2.0;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -2.4e-308: tmp = 2.0 * math.sqrt((x * y)) else: tmp = math.sqrt(math.fabs((y * z))) * 2.0 return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -2.4e-308) tmp = Float64(2.0 * sqrt(Float64(x * y))); else tmp = Float64(sqrt(abs(Float64(y * z))) * 2.0); 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.4e-308)
tmp = 2.0 * sqrt((x * y));
else
tmp = sqrt(abs((y * z))) * 2.0;
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.4e-308], N[(2.0 * N[Sqrt[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[Abs[N[(y * z), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{-308}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left|y \cdot z\right|} \cdot 2\\
\end{array}
\end{array}
if y < -2.40000000000000008e-308Initial program 70.5%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
if -2.40000000000000008e-308 < y Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6436.9
Applied rewrites36.9%
Taylor expanded in x around 0
Applied rewrites35.4%
rem-square-sqrtN/A
sqrt-unprodN/A
rem-sqrt-square-revN/A
lower-fabs.f6436.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.3
Applied rewrites36.3%
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 70.5%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
herbie shell --seed 2025152
(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)))))