
(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]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
double code(double x, double y, double z) {
return 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
end function
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
def code(x, y, z): return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
function code(x, y, z) return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))) end
function tmp = code(x, y, z) tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z))); end
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmin (fmin x y) z))
(t_1 (fmax (fmin x y) z))
(t_2 (fmin (fmax x y) t_1))
(t_3 (fmax (fmax x y) t_1)))
(if (<= t_2 -1.5e+14)
(*
-2.0
(* t_0 (sqrt (* -1.0 (/ (fma -1.0 t_2 (* -1.0 t_3)) t_0)))))
(if (<= t_2 6.4e-12)
(* 2.0 (sqrt (+ (+ (* t_0 t_2) (* t_0 t_3)) (* t_2 t_3))))
(* 2.0 (* t_3 (sqrt (* (/ 1.0 t_3) (+ t_2 t_0)))))))))double code(double x, double y, double z) {
double t_0 = fmin(fmin(x, y), z);
double t_1 = fmax(fmin(x, y), z);
double t_2 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -1.5e+14) {
tmp = -2.0 * (t_0 * sqrt((-1.0 * (fma(-1.0, t_2, (-1.0 * t_3)) / t_0))));
} else if (t_2 <= 6.4e-12) {
tmp = 2.0 * sqrt((((t_0 * t_2) + (t_0 * t_3)) + (t_2 * t_3)));
} else {
tmp = 2.0 * (t_3 * sqrt(((1.0 / t_3) * (t_2 + t_0))));
}
return tmp;
}
function code(x, y, z) t_0 = fmin(fmin(x, y), z) t_1 = fmax(fmin(x, y), z) t_2 = fmin(fmax(x, y), t_1) t_3 = fmax(fmax(x, y), t_1) tmp = 0.0 if (t_2 <= -1.5e+14) tmp = Float64(-2.0 * Float64(t_0 * sqrt(Float64(-1.0 * Float64(fma(-1.0, t_2, Float64(-1.0 * t_3)) / t_0))))); elseif (t_2 <= 6.4e-12) tmp = Float64(2.0 * sqrt(Float64(Float64(Float64(t_0 * t_2) + Float64(t_0 * t_3)) + Float64(t_2 * t_3)))); else tmp = Float64(2.0 * Float64(t_3 * sqrt(Float64(Float64(1.0 / t_3) * Float64(t_2 + t_0))))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, If[LessEqual[t$95$2, -1.5e+14], N[(-2.0 * N[(t$95$0 * N[Sqrt[N[(-1.0 * N[(N[(-1.0 * t$95$2 + N[(-1.0 * t$95$3), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 6.4e-12], N[(2.0 * N[Sqrt[N[(N[(N[(t$95$0 * t$95$2), $MachinePrecision] + N[(t$95$0 * t$95$3), $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$3 * N[Sqrt[N[(N[(1.0 / t$95$3), $MachinePrecision] * N[(t$95$2 + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_2 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
\mathbf{if}\;t\_2 \leq -1.5 \cdot 10^{+14}:\\
\;\;\;\;-2 \cdot \left(t\_0 \cdot \sqrt{-1 \cdot \frac{\mathsf{fma}\left(-1, t\_2, -1 \cdot t\_3\right)}{t\_0}}\right)\\
\mathbf{elif}\;t\_2 \leq 6.4 \cdot 10^{-12}:\\
\;\;\;\;2 \cdot \sqrt{\left(t\_0 \cdot t\_2 + t\_0 \cdot t\_3\right) + t\_2 \cdot t\_3}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t\_3 \cdot \sqrt{\frac{1}{t\_3} \cdot \left(t\_2 + t\_0\right)}\right)\\
\end{array}
if y < -1.5e14Initial 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-*.f6429.5%
Applied rewrites29.5%
if -1.5e14 < y < 6.4000000000000002e-12Initial program 70.5%
if 6.4000000000000002e-12 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6431.2%
Applied rewrites31.2%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6431.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6431.2%
Applied rewrites31.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmin (fmin x y) z))
(t_1 (fmax (fmin x y) z))
(t_2 (fmin (fmax x y) t_1))
(t_3 (fmax (fmax x y) t_1)))
(if (<= t_2 -1.5e+14)
(* 2.0 (* -1.0 (* t_0 (sqrt (/ t_2 t_0)))))
(if (<= t_2 6.4e-12)
(* 2.0 (sqrt (+ (+ (* t_0 t_2) (* t_0 t_3)) (* t_2 t_3))))
(* 2.0 (* t_3 (sqrt (* (/ 1.0 t_3) (+ t_2 t_0)))))))))double code(double x, double y, double z) {
double t_0 = fmin(fmin(x, y), z);
double t_1 = fmax(fmin(x, y), z);
double t_2 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -1.5e+14) {
tmp = 2.0 * (-1.0 * (t_0 * sqrt((t_2 / t_0))));
} else if (t_2 <= 6.4e-12) {
tmp = 2.0 * sqrt((((t_0 * t_2) + (t_0 * t_3)) + (t_2 * t_3)));
} else {
tmp = 2.0 * (t_3 * sqrt(((1.0 / t_3) * (t_2 + t_0))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = fmin(fmin(x, y), z)
t_1 = fmax(fmin(x, y), z)
t_2 = fmin(fmax(x, y), t_1)
t_3 = fmax(fmax(x, y), t_1)
if (t_2 <= (-1.5d+14)) then
tmp = 2.0d0 * ((-1.0d0) * (t_0 * sqrt((t_2 / t_0))))
else if (t_2 <= 6.4d-12) then
tmp = 2.0d0 * sqrt((((t_0 * t_2) + (t_0 * t_3)) + (t_2 * t_3)))
else
tmp = 2.0d0 * (t_3 * sqrt(((1.0d0 / t_3) * (t_2 + t_0))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = fmin(fmin(x, y), z);
double t_1 = fmax(fmin(x, y), z);
double t_2 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -1.5e+14) {
tmp = 2.0 * (-1.0 * (t_0 * Math.sqrt((t_2 / t_0))));
} else if (t_2 <= 6.4e-12) {
tmp = 2.0 * Math.sqrt((((t_0 * t_2) + (t_0 * t_3)) + (t_2 * t_3)));
} else {
tmp = 2.0 * (t_3 * Math.sqrt(((1.0 / t_3) * (t_2 + t_0))));
}
return tmp;
}
def code(x, y, z): t_0 = fmin(fmin(x, y), z) t_1 = fmax(fmin(x, y), z) t_2 = fmin(fmax(x, y), t_1) t_3 = fmax(fmax(x, y), t_1) tmp = 0 if t_2 <= -1.5e+14: tmp = 2.0 * (-1.0 * (t_0 * math.sqrt((t_2 / t_0)))) elif t_2 <= 6.4e-12: tmp = 2.0 * math.sqrt((((t_0 * t_2) + (t_0 * t_3)) + (t_2 * t_3))) else: tmp = 2.0 * (t_3 * math.sqrt(((1.0 / t_3) * (t_2 + t_0)))) return tmp
function code(x, y, z) t_0 = fmin(fmin(x, y), z) t_1 = fmax(fmin(x, y), z) t_2 = fmin(fmax(x, y), t_1) t_3 = fmax(fmax(x, y), t_1) tmp = 0.0 if (t_2 <= -1.5e+14) tmp = Float64(2.0 * Float64(-1.0 * Float64(t_0 * sqrt(Float64(t_2 / t_0))))); elseif (t_2 <= 6.4e-12) tmp = Float64(2.0 * sqrt(Float64(Float64(Float64(t_0 * t_2) + Float64(t_0 * t_3)) + Float64(t_2 * t_3)))); else tmp = Float64(2.0 * Float64(t_3 * sqrt(Float64(Float64(1.0 / t_3) * Float64(t_2 + t_0))))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = min(min(x, y), z); t_1 = max(min(x, y), z); t_2 = min(max(x, y), t_1); t_3 = max(max(x, y), t_1); tmp = 0.0; if (t_2 <= -1.5e+14) tmp = 2.0 * (-1.0 * (t_0 * sqrt((t_2 / t_0)))); elseif (t_2 <= 6.4e-12) tmp = 2.0 * sqrt((((t_0 * t_2) + (t_0 * t_3)) + (t_2 * t_3))); else tmp = 2.0 * (t_3 * sqrt(((1.0 / t_3) * (t_2 + t_0)))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, If[LessEqual[t$95$2, -1.5e+14], N[(2.0 * N[(-1.0 * N[(t$95$0 * N[Sqrt[N[(t$95$2 / t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 6.4e-12], N[(2.0 * N[Sqrt[N[(N[(N[(t$95$0 * t$95$2), $MachinePrecision] + N[(t$95$0 * t$95$3), $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$3 * N[Sqrt[N[(N[(1.0 / t$95$3), $MachinePrecision] * N[(t$95$2 + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_2 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
\mathbf{if}\;t\_2 \leq -1.5 \cdot 10^{+14}:\\
\;\;\;\;2 \cdot \left(-1 \cdot \left(t\_0 \cdot \sqrt{\frac{t\_2}{t\_0}}\right)\right)\\
\mathbf{elif}\;t\_2 \leq 6.4 \cdot 10^{-12}:\\
\;\;\;\;2 \cdot \sqrt{\left(t\_0 \cdot t\_2 + t\_0 \cdot t\_3\right) + t\_2 \cdot t\_3}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t\_3 \cdot \sqrt{\frac{1}{t\_3} \cdot \left(t\_2 + t\_0\right)}\right)\\
\end{array}
if y < -1.5e14Initial program 70.5%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6424.1%
Applied rewrites24.1%
Taylor expanded in x around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6415.5%
Applied rewrites15.5%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6415.4%
Applied rewrites15.4%
if -1.5e14 < y < 6.4000000000000002e-12Initial program 70.5%
if 6.4000000000000002e-12 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6431.2%
Applied rewrites31.2%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6431.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6431.2%
Applied rewrites31.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmin (fmin x y) z))
(t_1 (fmax (fmin x y) z))
(t_2 (fmin (fmax x y) t_1))
(t_3 (fmax (fmax x y) t_1)))
(if (<= t_2 -1.5e+14)
(* 2.0 (* -1.0 (* t_0 (sqrt (/ t_2 t_0)))))
(if (<= t_2 6.4e-12)
(* 2.0 (sqrt (fma t_3 t_0 (* (+ t_3 t_0) t_2))))
(* 2.0 (* t_3 (sqrt (* (/ 1.0 t_3) (+ t_2 t_0)))))))))double code(double x, double y, double z) {
double t_0 = fmin(fmin(x, y), z);
double t_1 = fmax(fmin(x, y), z);
double t_2 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -1.5e+14) {
tmp = 2.0 * (-1.0 * (t_0 * sqrt((t_2 / t_0))));
} else if (t_2 <= 6.4e-12) {
tmp = 2.0 * sqrt(fma(t_3, t_0, ((t_3 + t_0) * t_2)));
} else {
tmp = 2.0 * (t_3 * sqrt(((1.0 / t_3) * (t_2 + t_0))));
}
return tmp;
}
function code(x, y, z) t_0 = fmin(fmin(x, y), z) t_1 = fmax(fmin(x, y), z) t_2 = fmin(fmax(x, y), t_1) t_3 = fmax(fmax(x, y), t_1) tmp = 0.0 if (t_2 <= -1.5e+14) tmp = Float64(2.0 * Float64(-1.0 * Float64(t_0 * sqrt(Float64(t_2 / t_0))))); elseif (t_2 <= 6.4e-12) tmp = Float64(2.0 * sqrt(fma(t_3, t_0, Float64(Float64(t_3 + t_0) * t_2)))); else tmp = Float64(2.0 * Float64(t_3 * sqrt(Float64(Float64(1.0 / t_3) * Float64(t_2 + t_0))))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, If[LessEqual[t$95$2, -1.5e+14], N[(2.0 * N[(-1.0 * N[(t$95$0 * N[Sqrt[N[(t$95$2 / t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 6.4e-12], N[(2.0 * N[Sqrt[N[(t$95$3 * t$95$0 + N[(N[(t$95$3 + t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$3 * N[Sqrt[N[(N[(1.0 / t$95$3), $MachinePrecision] * N[(t$95$2 + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_2 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
\mathbf{if}\;t\_2 \leq -1.5 \cdot 10^{+14}:\\
\;\;\;\;2 \cdot \left(-1 \cdot \left(t\_0 \cdot \sqrt{\frac{t\_2}{t\_0}}\right)\right)\\
\mathbf{elif}\;t\_2 \leq 6.4 \cdot 10^{-12}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(t\_3, t\_0, \left(t\_3 + t\_0\right) \cdot t\_2\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t\_3 \cdot \sqrt{\frac{1}{t\_3} \cdot \left(t\_2 + t\_0\right)}\right)\\
\end{array}
if y < -1.5e14Initial program 70.5%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6424.1%
Applied rewrites24.1%
Taylor expanded in x around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6415.5%
Applied rewrites15.5%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6415.4%
Applied rewrites15.4%
if -1.5e14 < y < 6.4000000000000002e-12Initial program 70.5%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
add-flip-revN/A
+-commutativeN/A
lower-+.f6470.7%
Applied rewrites70.7%
if 6.4000000000000002e-12 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6431.2%
Applied rewrites31.2%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6431.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6431.2%
Applied rewrites31.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmin (fmin x y) z))
(t_1 (fmax (fmin x y) z))
(t_2 (fmin (fmax x y) t_1))
(t_3 (fmax (fmax x y) t_1)))
(if (<= t_2 -1.5e+14)
(* 2.0 (* -1.0 (* t_0 (sqrt (/ t_2 t_0)))))
(if (<= t_2 6.4e-12)
(* 2.0 (sqrt (fma t_3 t_0 (* (+ t_3 t_0) t_2))))
(* 2.0 (* t_3 (sqrt (/ (+ t_0 t_2) t_3))))))))double code(double x, double y, double z) {
double t_0 = fmin(fmin(x, y), z);
double t_1 = fmax(fmin(x, y), z);
double t_2 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -1.5e+14) {
tmp = 2.0 * (-1.0 * (t_0 * sqrt((t_2 / t_0))));
} else if (t_2 <= 6.4e-12) {
tmp = 2.0 * sqrt(fma(t_3, t_0, ((t_3 + t_0) * t_2)));
} else {
tmp = 2.0 * (t_3 * sqrt(((t_0 + t_2) / t_3)));
}
return tmp;
}
function code(x, y, z) t_0 = fmin(fmin(x, y), z) t_1 = fmax(fmin(x, y), z) t_2 = fmin(fmax(x, y), t_1) t_3 = fmax(fmax(x, y), t_1) tmp = 0.0 if (t_2 <= -1.5e+14) tmp = Float64(2.0 * Float64(-1.0 * Float64(t_0 * sqrt(Float64(t_2 / t_0))))); elseif (t_2 <= 6.4e-12) tmp = Float64(2.0 * sqrt(fma(t_3, t_0, Float64(Float64(t_3 + t_0) * t_2)))); else tmp = Float64(2.0 * Float64(t_3 * sqrt(Float64(Float64(t_0 + t_2) / t_3)))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, If[LessEqual[t$95$2, -1.5e+14], N[(2.0 * N[(-1.0 * N[(t$95$0 * N[Sqrt[N[(t$95$2 / t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 6.4e-12], N[(2.0 * N[Sqrt[N[(t$95$3 * t$95$0 + N[(N[(t$95$3 + t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$3 * N[Sqrt[N[(N[(t$95$0 + t$95$2), $MachinePrecision] / t$95$3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_2 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
\mathbf{if}\;t\_2 \leq -1.5 \cdot 10^{+14}:\\
\;\;\;\;2 \cdot \left(-1 \cdot \left(t\_0 \cdot \sqrt{\frac{t\_2}{t\_0}}\right)\right)\\
\mathbf{elif}\;t\_2 \leq 6.4 \cdot 10^{-12}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(t\_3, t\_0, \left(t\_3 + t\_0\right) \cdot t\_2\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t\_3 \cdot \sqrt{\frac{t\_0 + t\_2}{t\_3}}\right)\\
\end{array}
if y < -1.5e14Initial program 70.5%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6424.1%
Applied rewrites24.1%
Taylor expanded in x around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6415.5%
Applied rewrites15.5%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6415.4%
Applied rewrites15.4%
if -1.5e14 < y < 6.4000000000000002e-12Initial program 70.5%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
add-flip-revN/A
+-commutativeN/A
lower-+.f6470.7%
Applied rewrites70.7%
if 6.4000000000000002e-12 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6431.2%
Applied rewrites31.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmin (fmin x y) z))
(t_1 (fmax (fmin x y) z))
(t_2 (fmin (fmax x y) t_1))
(t_3 (+ t_0 t_2))
(t_4 (fmax (fmax x y) t_1)))
(if (<= t_2 -1.35e+16)
(* 2.0 (* -1.0 (* t_0 (sqrt (/ t_2 t_0)))))
(if (<= t_2 -4e-304)
(* 2.0 (sqrt (fma t_4 t_0 (* t_2 t_0))))
(if (<= t_2 2.15e-11)
(* 2.0 (sqrt (* t_4 t_3)))
(* 2.0 (* t_4 (sqrt (/ t_3 t_4)))))))))double code(double x, double y, double z) {
double t_0 = fmin(fmin(x, y), z);
double t_1 = fmax(fmin(x, y), z);
double t_2 = fmin(fmax(x, y), t_1);
double t_3 = t_0 + t_2;
double t_4 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -1.35e+16) {
tmp = 2.0 * (-1.0 * (t_0 * sqrt((t_2 / t_0))));
} else if (t_2 <= -4e-304) {
tmp = 2.0 * sqrt(fma(t_4, t_0, (t_2 * t_0)));
} else if (t_2 <= 2.15e-11) {
tmp = 2.0 * sqrt((t_4 * t_3));
} else {
tmp = 2.0 * (t_4 * sqrt((t_3 / t_4)));
}
return tmp;
}
function code(x, y, z) t_0 = fmin(fmin(x, y), z) t_1 = fmax(fmin(x, y), z) t_2 = fmin(fmax(x, y), t_1) t_3 = Float64(t_0 + t_2) t_4 = fmax(fmax(x, y), t_1) tmp = 0.0 if (t_2 <= -1.35e+16) tmp = Float64(2.0 * Float64(-1.0 * Float64(t_0 * sqrt(Float64(t_2 / t_0))))); elseif (t_2 <= -4e-304) tmp = Float64(2.0 * sqrt(fma(t_4, t_0, Float64(t_2 * t_0)))); elseif (t_2 <= 2.15e-11) tmp = Float64(2.0 * sqrt(Float64(t_4 * t_3))); else tmp = Float64(2.0 * Float64(t_4 * sqrt(Float64(t_3 / t_4)))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Max[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, If[LessEqual[t$95$2, -1.35e+16], N[(2.0 * N[(-1.0 * N[(t$95$0 * N[Sqrt[N[(t$95$2 / t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -4e-304], N[(2.0 * N[Sqrt[N[(t$95$4 * t$95$0 + N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2.15e-11], N[(2.0 * N[Sqrt[N[(t$95$4 * t$95$3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$4 * N[Sqrt[N[(t$95$3 / t$95$4), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_2 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
t_3 := t\_0 + t\_2\\
t_4 := \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
\mathbf{if}\;t\_2 \leq -1.35 \cdot 10^{+16}:\\
\;\;\;\;2 \cdot \left(-1 \cdot \left(t\_0 \cdot \sqrt{\frac{t\_2}{t\_0}}\right)\right)\\
\mathbf{elif}\;t\_2 \leq -4 \cdot 10^{-304}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(t\_4, t\_0, t\_2 \cdot t\_0\right)}\\
\mathbf{elif}\;t\_2 \leq 2.15 \cdot 10^{-11}:\\
\;\;\;\;2 \cdot \sqrt{t\_4 \cdot t\_3}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t\_4 \cdot \sqrt{\frac{t\_3}{t\_4}}\right)\\
\end{array}
if y < -1.35e16Initial program 70.5%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6424.1%
Applied rewrites24.1%
Taylor expanded in x around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6415.5%
Applied rewrites15.5%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6415.4%
Applied rewrites15.4%
if -1.35e16 < y < -3.9999999999999999e-304Initial program 70.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6446.8%
Applied rewrites46.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6447.6%
Applied rewrites47.6%
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-outN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6447.6%
Applied rewrites47.6%
if -3.9999999999999999e-304 < y < 2.15e-11Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6448.5%
Applied rewrites48.5%
if 2.15e-11 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6431.2%
Applied rewrites31.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmax (fmin x y) z))
(t_1 (fmax (fmax x y) t_0))
(t_2 (fmin (fmax x y) t_0))
(t_3 (fmin (fmin x y) z))
(t_4 (+ t_3 t_2)))
(if (<= t_2 -1.45e+19)
(* -2.0 (* t_2 (sqrt (/ (+ t_3 t_1) t_2))))
(if (<= t_2 -4e-304)
(* 2.0 (sqrt (fma t_1 t_3 (* t_2 t_3))))
(if (<= t_2 2.15e-11)
(* 2.0 (sqrt (* t_1 t_4)))
(* 2.0 (* t_1 (sqrt (/ t_4 t_1)))))))))double code(double x, double y, double z) {
double t_0 = fmax(fmin(x, y), z);
double t_1 = fmax(fmax(x, y), t_0);
double t_2 = fmin(fmax(x, y), t_0);
double t_3 = fmin(fmin(x, y), z);
double t_4 = t_3 + t_2;
double tmp;
if (t_2 <= -1.45e+19) {
tmp = -2.0 * (t_2 * sqrt(((t_3 + t_1) / t_2)));
} else if (t_2 <= -4e-304) {
tmp = 2.0 * sqrt(fma(t_1, t_3, (t_2 * t_3)));
} else if (t_2 <= 2.15e-11) {
tmp = 2.0 * sqrt((t_1 * t_4));
} else {
tmp = 2.0 * (t_1 * sqrt((t_4 / t_1)));
}
return tmp;
}
function code(x, y, z) t_0 = fmax(fmin(x, y), z) t_1 = fmax(fmax(x, y), t_0) t_2 = fmin(fmax(x, y), t_0) t_3 = fmin(fmin(x, y), z) t_4 = Float64(t_3 + t_2) tmp = 0.0 if (t_2 <= -1.45e+19) tmp = Float64(-2.0 * Float64(t_2 * sqrt(Float64(Float64(t_3 + t_1) / t_2)))); elseif (t_2 <= -4e-304) tmp = Float64(2.0 * sqrt(fma(t_1, t_3, Float64(t_2 * t_3)))); elseif (t_2 <= 2.15e-11) tmp = Float64(2.0 * sqrt(Float64(t_1 * t_4))); else tmp = Float64(2.0 * Float64(t_1 * sqrt(Float64(t_4 / t_1)))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Max[x, y], $MachinePrecision], t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Max[x, y], $MachinePrecision], t$95$0], $MachinePrecision]}, Block[{t$95$3 = N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 + t$95$2), $MachinePrecision]}, If[LessEqual[t$95$2, -1.45e+19], N[(-2.0 * N[(t$95$2 * N[Sqrt[N[(N[(t$95$3 + t$95$1), $MachinePrecision] / t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -4e-304], N[(2.0 * N[Sqrt[N[(t$95$1 * t$95$3 + N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2.15e-11], N[(2.0 * N[Sqrt[N[(t$95$1 * t$95$4), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$1 * N[Sqrt[N[(t$95$4 / t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_0\right)\\
t_2 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_0\right)\\
t_3 := \mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_4 := t\_3 + t\_2\\
\mathbf{if}\;t\_2 \leq -1.45 \cdot 10^{+19}:\\
\;\;\;\;-2 \cdot \left(t\_2 \cdot \sqrt{\frac{t\_3 + t\_1}{t\_2}}\right)\\
\mathbf{elif}\;t\_2 \leq -4 \cdot 10^{-304}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(t\_1, t\_3, t\_2 \cdot t\_3\right)}\\
\mathbf{elif}\;t\_2 \leq 2.15 \cdot 10^{-11}:\\
\;\;\;\;2 \cdot \sqrt{t\_1 \cdot t\_4}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t\_1 \cdot \sqrt{\frac{t\_4}{t\_1}}\right)\\
\end{array}
if y < -1.45e19Initial program 70.5%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
add-flip-revN/A
+-commutativeN/A
lower-+.f6470.7%
Applied rewrites70.7%
Taylor expanded in x around 0
Applied rewrites48.5%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6429.4%
Applied rewrites29.4%
if -1.45e19 < y < -3.9999999999999999e-304Initial program 70.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6446.8%
Applied rewrites46.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6447.6%
Applied rewrites47.6%
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-outN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6447.6%
Applied rewrites47.6%
if -3.9999999999999999e-304 < y < 2.15e-11Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6448.5%
Applied rewrites48.5%
if 2.15e-11 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6431.2%
Applied rewrites31.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmin (fmin x y) z))
(t_1 (fmax (fmin x y) z))
(t_2 (fmax (fmax x y) t_1))
(t_3 (fmin (fmax x y) t_1)))
(if (<= t_3 -1.45e+19)
(* -2.0 (* t_3 (sqrt (/ (+ t_0 t_2) t_3))))
(if (<= t_3 -4e-304)
(* 2.0 (sqrt (fma t_2 t_0 (* t_3 t_0))))
(if (<= t_3 21000000000000.0)
(* 2.0 (sqrt (* t_2 (+ t_0 t_3))))
(* 2.0 (* t_2 (sqrt (/ t_3 t_2)))))))))double code(double x, double y, double z) {
double t_0 = fmin(fmin(x, y), z);
double t_1 = fmax(fmin(x, y), z);
double t_2 = fmax(fmax(x, y), t_1);
double t_3 = fmin(fmax(x, y), t_1);
double tmp;
if (t_3 <= -1.45e+19) {
tmp = -2.0 * (t_3 * sqrt(((t_0 + t_2) / t_3)));
} else if (t_3 <= -4e-304) {
tmp = 2.0 * sqrt(fma(t_2, t_0, (t_3 * t_0)));
} else if (t_3 <= 21000000000000.0) {
tmp = 2.0 * sqrt((t_2 * (t_0 + t_3)));
} else {
tmp = 2.0 * (t_2 * sqrt((t_3 / t_2)));
}
return tmp;
}
function code(x, y, z) t_0 = fmin(fmin(x, y), z) t_1 = fmax(fmin(x, y), z) t_2 = fmax(fmax(x, y), t_1) t_3 = fmin(fmax(x, y), t_1) tmp = 0.0 if (t_3 <= -1.45e+19) tmp = Float64(-2.0 * Float64(t_3 * sqrt(Float64(Float64(t_0 + t_2) / t_3)))); elseif (t_3 <= -4e-304) tmp = Float64(2.0 * sqrt(fma(t_2, t_0, Float64(t_3 * t_0)))); elseif (t_3 <= 21000000000000.0) tmp = Float64(2.0 * sqrt(Float64(t_2 * Float64(t_0 + t_3)))); else tmp = Float64(2.0 * Float64(t_2 * sqrt(Float64(t_3 / t_2)))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Min[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, If[LessEqual[t$95$3, -1.45e+19], N[(-2.0 * N[(t$95$3 * N[Sqrt[N[(N[(t$95$0 + t$95$2), $MachinePrecision] / t$95$3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -4e-304], N[(2.0 * N[Sqrt[N[(t$95$2 * t$95$0 + N[(t$95$3 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 21000000000000.0], N[(2.0 * N[Sqrt[N[(t$95$2 * N[(t$95$0 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$2 * N[Sqrt[N[(t$95$3 / t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
t_3 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
\mathbf{if}\;t\_3 \leq -1.45 \cdot 10^{+19}:\\
\;\;\;\;-2 \cdot \left(t\_3 \cdot \sqrt{\frac{t\_0 + t\_2}{t\_3}}\right)\\
\mathbf{elif}\;t\_3 \leq -4 \cdot 10^{-304}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(t\_2, t\_0, t\_3 \cdot t\_0\right)}\\
\mathbf{elif}\;t\_3 \leq 21000000000000:\\
\;\;\;\;2 \cdot \sqrt{t\_2 \cdot \left(t\_0 + t\_3\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t\_2 \cdot \sqrt{\frac{t\_3}{t\_2}}\right)\\
\end{array}
if y < -1.45e19Initial program 70.5%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
add-flip-revN/A
+-commutativeN/A
lower-+.f6470.7%
Applied rewrites70.7%
Taylor expanded in x around 0
Applied rewrites48.5%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6429.4%
Applied rewrites29.4%
if -1.45e19 < y < -3.9999999999999999e-304Initial program 70.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6446.8%
Applied rewrites46.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6447.6%
Applied rewrites47.6%
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-outN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6447.6%
Applied rewrites47.6%
if -3.9999999999999999e-304 < y < 2.1e13Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6448.5%
Applied rewrites48.5%
if 2.1e13 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6431.2%
Applied rewrites31.2%
Taylor expanded in x around 0
Applied rewrites16.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmin (fmin x y) z))
(t_1 (fmax (fmin x y) z))
(t_2 (fmax (fmax x y) t_1))
(t_3 (fmin (fmax x y) t_1)))
(if (<= t_3 -4e-304)
(* 2.0 (sqrt (fma t_2 t_0 (* t_3 t_0))))
(if (<= t_3 21000000000000.0)
(* 2.0 (sqrt (* t_2 (+ t_0 t_3))))
(* 2.0 (* t_2 (sqrt (/ t_3 t_2))))))))double code(double x, double y, double z) {
double t_0 = fmin(fmin(x, y), z);
double t_1 = fmax(fmin(x, y), z);
double t_2 = fmax(fmax(x, y), t_1);
double t_3 = fmin(fmax(x, y), t_1);
double tmp;
if (t_3 <= -4e-304) {
tmp = 2.0 * sqrt(fma(t_2, t_0, (t_3 * t_0)));
} else if (t_3 <= 21000000000000.0) {
tmp = 2.0 * sqrt((t_2 * (t_0 + t_3)));
} else {
tmp = 2.0 * (t_2 * sqrt((t_3 / t_2)));
}
return tmp;
}
function code(x, y, z) t_0 = fmin(fmin(x, y), z) t_1 = fmax(fmin(x, y), z) t_2 = fmax(fmax(x, y), t_1) t_3 = fmin(fmax(x, y), t_1) tmp = 0.0 if (t_3 <= -4e-304) tmp = Float64(2.0 * sqrt(fma(t_2, t_0, Float64(t_3 * t_0)))); elseif (t_3 <= 21000000000000.0) tmp = Float64(2.0 * sqrt(Float64(t_2 * Float64(t_0 + t_3)))); else tmp = Float64(2.0 * Float64(t_2 * sqrt(Float64(t_3 / t_2)))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Min[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, If[LessEqual[t$95$3, -4e-304], N[(2.0 * N[Sqrt[N[(t$95$2 * t$95$0 + N[(t$95$3 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 21000000000000.0], N[(2.0 * N[Sqrt[N[(t$95$2 * N[(t$95$0 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$2 * N[Sqrt[N[(t$95$3 / t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
t_3 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
\mathbf{if}\;t\_3 \leq -4 \cdot 10^{-304}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(t\_2, t\_0, t\_3 \cdot t\_0\right)}\\
\mathbf{elif}\;t\_3 \leq 21000000000000:\\
\;\;\;\;2 \cdot \sqrt{t\_2 \cdot \left(t\_0 + t\_3\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t\_2 \cdot \sqrt{\frac{t\_3}{t\_2}}\right)\\
\end{array}
if y < -3.9999999999999999e-304Initial program 70.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6446.8%
Applied rewrites46.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6447.6%
Applied rewrites47.6%
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-outN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6447.6%
Applied rewrites47.6%
if -3.9999999999999999e-304 < y < 2.1e13Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6448.5%
Applied rewrites48.5%
if 2.1e13 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6431.2%
Applied rewrites31.2%
Taylor expanded in x around 0
Applied rewrites16.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmin (fmin x y) z))
(t_1 (fmax (fmin x y) z))
(t_2 (fmax (fmax x y) t_1))
(t_3 (fmin (fmax x y) t_1)))
(if (<= t_3 -4e-304)
(* 2.0 (sqrt (* t_0 (+ t_3 t_2))))
(if (<= t_3 21000000000000.0)
(* 2.0 (sqrt (* t_2 (+ t_0 t_3))))
(* 2.0 (* t_2 (sqrt (/ t_3 t_2))))))))double code(double x, double y, double z) {
double t_0 = fmin(fmin(x, y), z);
double t_1 = fmax(fmin(x, y), z);
double t_2 = fmax(fmax(x, y), t_1);
double t_3 = fmin(fmax(x, y), t_1);
double tmp;
if (t_3 <= -4e-304) {
tmp = 2.0 * sqrt((t_0 * (t_3 + t_2)));
} else if (t_3 <= 21000000000000.0) {
tmp = 2.0 * sqrt((t_2 * (t_0 + t_3)));
} else {
tmp = 2.0 * (t_2 * sqrt((t_3 / t_2)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = fmin(fmin(x, y), z)
t_1 = fmax(fmin(x, y), z)
t_2 = fmax(fmax(x, y), t_1)
t_3 = fmin(fmax(x, y), t_1)
if (t_3 <= (-4d-304)) then
tmp = 2.0d0 * sqrt((t_0 * (t_3 + t_2)))
else if (t_3 <= 21000000000000.0d0) then
tmp = 2.0d0 * sqrt((t_2 * (t_0 + t_3)))
else
tmp = 2.0d0 * (t_2 * sqrt((t_3 / t_2)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = fmin(fmin(x, y), z);
double t_1 = fmax(fmin(x, y), z);
double t_2 = fmax(fmax(x, y), t_1);
double t_3 = fmin(fmax(x, y), t_1);
double tmp;
if (t_3 <= -4e-304) {
tmp = 2.0 * Math.sqrt((t_0 * (t_3 + t_2)));
} else if (t_3 <= 21000000000000.0) {
tmp = 2.0 * Math.sqrt((t_2 * (t_0 + t_3)));
} else {
tmp = 2.0 * (t_2 * Math.sqrt((t_3 / t_2)));
}
return tmp;
}
def code(x, y, z): t_0 = fmin(fmin(x, y), z) t_1 = fmax(fmin(x, y), z) t_2 = fmax(fmax(x, y), t_1) t_3 = fmin(fmax(x, y), t_1) tmp = 0 if t_3 <= -4e-304: tmp = 2.0 * math.sqrt((t_0 * (t_3 + t_2))) elif t_3 <= 21000000000000.0: tmp = 2.0 * math.sqrt((t_2 * (t_0 + t_3))) else: tmp = 2.0 * (t_2 * math.sqrt((t_3 / t_2))) return tmp
function code(x, y, z) t_0 = fmin(fmin(x, y), z) t_1 = fmax(fmin(x, y), z) t_2 = fmax(fmax(x, y), t_1) t_3 = fmin(fmax(x, y), t_1) tmp = 0.0 if (t_3 <= -4e-304) tmp = Float64(2.0 * sqrt(Float64(t_0 * Float64(t_3 + t_2)))); elseif (t_3 <= 21000000000000.0) tmp = Float64(2.0 * sqrt(Float64(t_2 * Float64(t_0 + t_3)))); else tmp = Float64(2.0 * Float64(t_2 * sqrt(Float64(t_3 / t_2)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = min(min(x, y), z); t_1 = max(min(x, y), z); t_2 = max(max(x, y), t_1); t_3 = min(max(x, y), t_1); tmp = 0.0; if (t_3 <= -4e-304) tmp = 2.0 * sqrt((t_0 * (t_3 + t_2))); elseif (t_3 <= 21000000000000.0) tmp = 2.0 * sqrt((t_2 * (t_0 + t_3))); else tmp = 2.0 * (t_2 * sqrt((t_3 / t_2))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Min[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, If[LessEqual[t$95$3, -4e-304], N[(2.0 * N[Sqrt[N[(t$95$0 * N[(t$95$3 + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 21000000000000.0], N[(2.0 * N[Sqrt[N[(t$95$2 * N[(t$95$0 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$2 * N[Sqrt[N[(t$95$3 / t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
t_3 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
\mathbf{if}\;t\_3 \leq -4 \cdot 10^{-304}:\\
\;\;\;\;2 \cdot \sqrt{t\_0 \cdot \left(t\_3 + t\_2\right)}\\
\mathbf{elif}\;t\_3 \leq 21000000000000:\\
\;\;\;\;2 \cdot \sqrt{t\_2 \cdot \left(t\_0 + t\_3\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t\_2 \cdot \sqrt{\frac{t\_3}{t\_2}}\right)\\
\end{array}
if y < -3.9999999999999999e-304Initial program 70.5%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
add-flip-revN/A
+-commutativeN/A
lower-+.f6470.7%
Applied rewrites70.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6447.6%
Applied rewrites47.6%
if -3.9999999999999999e-304 < y < 2.1e13Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6448.5%
Applied rewrites48.5%
if 2.1e13 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6431.2%
Applied rewrites31.2%
Taylor expanded in x around 0
Applied rewrites16.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmin (fmin x y) z))
(t_1 (fmax (fmin x y) z))
(t_2 (fmax (fmax x y) t_1))
(t_3 (fmin (fmax x y) t_1)))
(if (<= t_3 -4e-304)
(* 2.0 (sqrt (* t_0 (+ t_3 t_2))))
(* 2.0 (sqrt (* t_2 (+ t_0 t_3)))))))double code(double x, double y, double z) {
double t_0 = fmin(fmin(x, y), z);
double t_1 = fmax(fmin(x, y), z);
double t_2 = fmax(fmax(x, y), t_1);
double t_3 = fmin(fmax(x, y), t_1);
double tmp;
if (t_3 <= -4e-304) {
tmp = 2.0 * sqrt((t_0 * (t_3 + t_2)));
} else {
tmp = 2.0 * sqrt((t_2 * (t_0 + t_3)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = fmin(fmin(x, y), z)
t_1 = fmax(fmin(x, y), z)
t_2 = fmax(fmax(x, y), t_1)
t_3 = fmin(fmax(x, y), t_1)
if (t_3 <= (-4d-304)) then
tmp = 2.0d0 * sqrt((t_0 * (t_3 + t_2)))
else
tmp = 2.0d0 * sqrt((t_2 * (t_0 + t_3)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = fmin(fmin(x, y), z);
double t_1 = fmax(fmin(x, y), z);
double t_2 = fmax(fmax(x, y), t_1);
double t_3 = fmin(fmax(x, y), t_1);
double tmp;
if (t_3 <= -4e-304) {
tmp = 2.0 * Math.sqrt((t_0 * (t_3 + t_2)));
} else {
tmp = 2.0 * Math.sqrt((t_2 * (t_0 + t_3)));
}
return tmp;
}
def code(x, y, z): t_0 = fmin(fmin(x, y), z) t_1 = fmax(fmin(x, y), z) t_2 = fmax(fmax(x, y), t_1) t_3 = fmin(fmax(x, y), t_1) tmp = 0 if t_3 <= -4e-304: tmp = 2.0 * math.sqrt((t_0 * (t_3 + t_2))) else: tmp = 2.0 * math.sqrt((t_2 * (t_0 + t_3))) return tmp
function code(x, y, z) t_0 = fmin(fmin(x, y), z) t_1 = fmax(fmin(x, y), z) t_2 = fmax(fmax(x, y), t_1) t_3 = fmin(fmax(x, y), t_1) tmp = 0.0 if (t_3 <= -4e-304) tmp = Float64(2.0 * sqrt(Float64(t_0 * Float64(t_3 + t_2)))); else tmp = Float64(2.0 * sqrt(Float64(t_2 * Float64(t_0 + t_3)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = min(min(x, y), z); t_1 = max(min(x, y), z); t_2 = max(max(x, y), t_1); t_3 = min(max(x, y), t_1); tmp = 0.0; if (t_3 <= -4e-304) tmp = 2.0 * sqrt((t_0 * (t_3 + t_2))); else tmp = 2.0 * sqrt((t_2 * (t_0 + t_3))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Min[N[Max[x, y], $MachinePrecision], t$95$1], $MachinePrecision]}, If[LessEqual[t$95$3, -4e-304], N[(2.0 * N[Sqrt[N[(t$95$0 * N[(t$95$3 + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(t$95$2 * N[(t$95$0 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
t_3 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_1\right)\\
\mathbf{if}\;t\_3 \leq -4 \cdot 10^{-304}:\\
\;\;\;\;2 \cdot \sqrt{t\_0 \cdot \left(t\_3 + t\_2\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{t\_2 \cdot \left(t\_0 + t\_3\right)}\\
\end{array}
if y < -3.9999999999999999e-304Initial program 70.5%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
add-flip-revN/A
+-commutativeN/A
lower-+.f6470.7%
Applied rewrites70.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6447.6%
Applied rewrites47.6%
if -3.9999999999999999e-304 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6448.5%
Applied rewrites48.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmax (fmin x y) z))
(t_1 (fmax (fmax x y) t_0))
(t_2 (fmin (fmax x y) t_0)))
(if (<= t_2 -4.1e-305)
(* 2.0 (sqrt (* (fmin (fmin x y) z) (+ t_2 t_1))))
(* 2.0 (sqrt (fabs (* t_2 t_1)))))))double code(double x, double y, double z) {
double t_0 = fmax(fmin(x, y), z);
double t_1 = fmax(fmax(x, y), t_0);
double t_2 = fmin(fmax(x, y), t_0);
double tmp;
if (t_2 <= -4.1e-305) {
tmp = 2.0 * sqrt((fmin(fmin(x, y), z) * (t_2 + t_1)));
} else {
tmp = 2.0 * sqrt(fabs((t_2 * t_1)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = fmax(fmin(x, y), z)
t_1 = fmax(fmax(x, y), t_0)
t_2 = fmin(fmax(x, y), t_0)
if (t_2 <= (-4.1d-305)) then
tmp = 2.0d0 * sqrt((fmin(fmin(x, y), z) * (t_2 + t_1)))
else
tmp = 2.0d0 * sqrt(abs((t_2 * t_1)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = fmax(fmin(x, y), z);
double t_1 = fmax(fmax(x, y), t_0);
double t_2 = fmin(fmax(x, y), t_0);
double tmp;
if (t_2 <= -4.1e-305) {
tmp = 2.0 * Math.sqrt((fmin(fmin(x, y), z) * (t_2 + t_1)));
} else {
tmp = 2.0 * Math.sqrt(Math.abs((t_2 * t_1)));
}
return tmp;
}
def code(x, y, z): t_0 = fmax(fmin(x, y), z) t_1 = fmax(fmax(x, y), t_0) t_2 = fmin(fmax(x, y), t_0) tmp = 0 if t_2 <= -4.1e-305: tmp = 2.0 * math.sqrt((fmin(fmin(x, y), z) * (t_2 + t_1))) else: tmp = 2.0 * math.sqrt(math.fabs((t_2 * t_1))) return tmp
function code(x, y, z) t_0 = fmax(fmin(x, y), z) t_1 = fmax(fmax(x, y), t_0) t_2 = fmin(fmax(x, y), t_0) tmp = 0.0 if (t_2 <= -4.1e-305) tmp = Float64(2.0 * sqrt(Float64(fmin(fmin(x, y), z) * Float64(t_2 + t_1)))); else tmp = Float64(2.0 * sqrt(abs(Float64(t_2 * t_1)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = max(min(x, y), z); t_1 = max(max(x, y), t_0); t_2 = min(max(x, y), t_0); tmp = 0.0; if (t_2 <= -4.1e-305) tmp = 2.0 * sqrt((min(min(x, y), z) * (t_2 + t_1))); else tmp = 2.0 * sqrt(abs((t_2 * t_1))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Max[x, y], $MachinePrecision], t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Max[x, y], $MachinePrecision], t$95$0], $MachinePrecision]}, If[LessEqual[t$95$2, -4.1e-305], N[(2.0 * N[Sqrt[N[(N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision] * N[(t$95$2 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[Abs[N[(t$95$2 * t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_0\right)\\
t_2 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_0\right)\\
\mathbf{if}\;t\_2 \leq -4.1 \cdot 10^{-305}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right) \cdot \left(t\_2 + t\_1\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{\left|t\_2 \cdot t\_1\right|}\\
\end{array}
if y < -4.1000000000000002e-305Initial program 70.5%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
add-flip-revN/A
+-commutativeN/A
lower-+.f6470.7%
Applied rewrites70.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6447.6%
Applied rewrites47.6%
if -4.1000000000000002e-305 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6448.5%
Applied rewrites48.5%
Taylor expanded in x around 0
Applied rewrites25.0%
rem-square-sqrtN/A
sqrt-unprodN/A
rem-sqrt-square-revN/A
lower-fabs.f6426.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6426.8%
Applied rewrites26.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmax (fmin x y) z)))
(*
2.0
(sqrt
(*
(fmin (fmax x y) t_0)
(+ (fmin (fmin x y) z) (fmax (fmax x y) t_0)))))))double code(double x, double y, double z) {
double t_0 = fmax(fmin(x, y), z);
return 2.0 * sqrt((fmin(fmax(x, y), t_0) * (fmin(fmin(x, y), z) + fmax(fmax(x, y), t_0))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
t_0 = fmax(fmin(x, y), z)
code = 2.0d0 * sqrt((fmin(fmax(x, y), t_0) * (fmin(fmin(x, y), z) + fmax(fmax(x, y), t_0))))
end function
public static double code(double x, double y, double z) {
double t_0 = fmax(fmin(x, y), z);
return 2.0 * Math.sqrt((fmin(fmax(x, y), t_0) * (fmin(fmin(x, y), z) + fmax(fmax(x, y), t_0))));
}
def code(x, y, z): t_0 = fmax(fmin(x, y), z) return 2.0 * math.sqrt((fmin(fmax(x, y), t_0) * (fmin(fmin(x, y), z) + fmax(fmax(x, y), t_0))))
function code(x, y, z) t_0 = fmax(fmin(x, y), z) return Float64(2.0 * sqrt(Float64(fmin(fmax(x, y), t_0) * Float64(fmin(fmin(x, y), z) + fmax(fmax(x, y), t_0))))) end
function tmp = code(x, y, z) t_0 = max(min(x, y), z); tmp = 2.0 * sqrt((min(max(x, y), t_0) * (min(min(x, y), z) + max(max(x, y), t_0)))); end
code[x_, y_, z_] := Block[{t$95$0 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, N[(2.0 * N[Sqrt[N[(N[Min[N[Max[x, y], $MachinePrecision], t$95$0], $MachinePrecision] * N[(N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision] + N[Max[N[Max[x, y], $MachinePrecision], t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
2 \cdot \sqrt{\mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_0\right) \cdot \left(\mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right) + \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_0\right)\right)}
\end{array}
Initial program 70.5%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6446.8%
Applied rewrites46.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmax (fmin x y) z)) (t_1 (fmin (fmax x y) t_0)))
(if (<= t_1 -5e-310)
(* 2.0 (sqrt (* (fmin (fmin x y) z) t_1)))
(* 2.0 (sqrt (* t_1 (fmax (fmax x y) t_0)))))))double code(double x, double y, double z) {
double t_0 = fmax(fmin(x, y), z);
double t_1 = fmin(fmax(x, y), t_0);
double tmp;
if (t_1 <= -5e-310) {
tmp = 2.0 * sqrt((fmin(fmin(x, y), z) * t_1));
} else {
tmp = 2.0 * sqrt((t_1 * fmax(fmax(x, y), t_0)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmax(fmin(x, y), z)
t_1 = fmin(fmax(x, y), t_0)
if (t_1 <= (-5d-310)) then
tmp = 2.0d0 * sqrt((fmin(fmin(x, y), z) * t_1))
else
tmp = 2.0d0 * sqrt((t_1 * fmax(fmax(x, y), t_0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = fmax(fmin(x, y), z);
double t_1 = fmin(fmax(x, y), t_0);
double tmp;
if (t_1 <= -5e-310) {
tmp = 2.0 * Math.sqrt((fmin(fmin(x, y), z) * t_1));
} else {
tmp = 2.0 * Math.sqrt((t_1 * fmax(fmax(x, y), t_0)));
}
return tmp;
}
def code(x, y, z): t_0 = fmax(fmin(x, y), z) t_1 = fmin(fmax(x, y), t_0) tmp = 0 if t_1 <= -5e-310: tmp = 2.0 * math.sqrt((fmin(fmin(x, y), z) * t_1)) else: tmp = 2.0 * math.sqrt((t_1 * fmax(fmax(x, y), t_0))) return tmp
function code(x, y, z) t_0 = fmax(fmin(x, y), z) t_1 = fmin(fmax(x, y), t_0) tmp = 0.0 if (t_1 <= -5e-310) tmp = Float64(2.0 * sqrt(Float64(fmin(fmin(x, y), z) * t_1))); else tmp = Float64(2.0 * sqrt(Float64(t_1 * fmax(fmax(x, y), t_0)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = max(min(x, y), z); t_1 = min(max(x, y), t_0); tmp = 0.0; if (t_1 <= -5e-310) tmp = 2.0 * sqrt((min(min(x, y), z) * t_1)); else tmp = 2.0 * sqrt((t_1 * max(max(x, y), t_0))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Max[x, y], $MachinePrecision], t$95$0], $MachinePrecision]}, If[LessEqual[t$95$1, -5e-310], N[(2.0 * N[Sqrt[N[(N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(t$95$1 * N[Max[N[Max[x, y], $MachinePrecision], t$95$0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_0\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{t\_1 \cdot \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_0\right)}\\
\end{array}
if y < -4.9999999999999847e-310Initial program 70.5%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6424.1%
Applied rewrites24.1%
if -4.9999999999999847e-310 < y Initial program 70.5%
Taylor expanded in x around 0
lower-*.f6425.0%
Applied rewrites25.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmax (fmin x y) z)) (t_1 (fmin (fmax x y) t_0)))
(if (<= t_1 -1.62e-304)
(* 2.0 (sqrt (* (fmin (fmin x y) z) t_1)))
(* 2.0 (sqrt (fabs (* t_1 (fmax (fmax x y) t_0))))))))double code(double x, double y, double z) {
double t_0 = fmax(fmin(x, y), z);
double t_1 = fmin(fmax(x, y), t_0);
double tmp;
if (t_1 <= -1.62e-304) {
tmp = 2.0 * sqrt((fmin(fmin(x, y), z) * t_1));
} else {
tmp = 2.0 * sqrt(fabs((t_1 * fmax(fmax(x, y), t_0))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmax(fmin(x, y), z)
t_1 = fmin(fmax(x, y), t_0)
if (t_1 <= (-1.62d-304)) then
tmp = 2.0d0 * sqrt((fmin(fmin(x, y), z) * t_1))
else
tmp = 2.0d0 * sqrt(abs((t_1 * fmax(fmax(x, y), t_0))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = fmax(fmin(x, y), z);
double t_1 = fmin(fmax(x, y), t_0);
double tmp;
if (t_1 <= -1.62e-304) {
tmp = 2.0 * Math.sqrt((fmin(fmin(x, y), z) * t_1));
} else {
tmp = 2.0 * Math.sqrt(Math.abs((t_1 * fmax(fmax(x, y), t_0))));
}
return tmp;
}
def code(x, y, z): t_0 = fmax(fmin(x, y), z) t_1 = fmin(fmax(x, y), t_0) tmp = 0 if t_1 <= -1.62e-304: tmp = 2.0 * math.sqrt((fmin(fmin(x, y), z) * t_1)) else: tmp = 2.0 * math.sqrt(math.fabs((t_1 * fmax(fmax(x, y), t_0)))) return tmp
function code(x, y, z) t_0 = fmax(fmin(x, y), z) t_1 = fmin(fmax(x, y), t_0) tmp = 0.0 if (t_1 <= -1.62e-304) tmp = Float64(2.0 * sqrt(Float64(fmin(fmin(x, y), z) * t_1))); else tmp = Float64(2.0 * sqrt(abs(Float64(t_1 * fmax(fmax(x, y), t_0))))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = max(min(x, y), z); t_1 = min(max(x, y), t_0); tmp = 0.0; if (t_1 <= -1.62e-304) tmp = 2.0 * sqrt((min(min(x, y), z) * t_1)); else tmp = 2.0 * sqrt(abs((t_1 * max(max(x, y), t_0)))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Max[N[Min[x, y], $MachinePrecision], z], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Max[x, y], $MachinePrecision], t$95$0], $MachinePrecision]}, If[LessEqual[t$95$1, -1.62e-304], N[(2.0 * N[Sqrt[N[(N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[Abs[N[(t$95$1 * N[Max[N[Max[x, y], $MachinePrecision], t$95$0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{min}\left(x, y\right), z\right)\\
t_1 := \mathsf{min}\left(\mathsf{max}\left(x, y\right), t\_0\right)\\
\mathbf{if}\;t\_1 \leq -1.62 \cdot 10^{-304}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{min}\left(\mathsf{min}\left(x, y\right), z\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{\left|t\_1 \cdot \mathsf{max}\left(\mathsf{max}\left(x, y\right), t\_0\right)\right|}\\
\end{array}
if y < -1.6199999999999999e-304Initial program 70.5%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6424.1%
Applied rewrites24.1%
if -1.6199999999999999e-304 < y Initial program 70.5%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6448.5%
Applied rewrites48.5%
Taylor expanded in x around 0
Applied rewrites25.0%
rem-square-sqrtN/A
sqrt-unprodN/A
rem-sqrt-square-revN/A
lower-fabs.f6426.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6426.8%
Applied rewrites26.8%
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (* (fmin x z) (fmin y (fmax x z))))))
double code(double x, double y, double z) {
return 2.0 * sqrt((fmin(x, z) * fmin(y, fmax(x, 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((fmin(x, z) * fmin(y, fmax(x, z))))
end function
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((fmin(x, z) * fmin(y, fmax(x, z))));
}
def code(x, y, z): return 2.0 * math.sqrt((fmin(x, z) * fmin(y, fmax(x, z))))
function code(x, y, z) return Float64(2.0 * sqrt(Float64(fmin(x, z) * fmin(y, fmax(x, z))))) end
function tmp = code(x, y, z) tmp = 2.0 * sqrt((min(x, z) * min(y, max(x, z)))); end
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[Min[x, z], $MachinePrecision] * N[Min[y, N[Max[x, z], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
2 \cdot \sqrt{\mathsf{min}\left(x, z\right) \cdot \mathsf{min}\left(y, \mathsf{max}\left(x, z\right)\right)}
Initial program 70.5%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6424.1%
Applied rewrites24.1%
herbie shell --seed 2025212
(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)))))