
(FPCore (x y z) :precision binary64 (* 2 (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 * 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 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* 2 (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 * 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
8743510234639941/171441377149802771351748007849600289689824769872885377191000062139256168179989779598911740610511337300415147666808503492029943245710770246975753241195177196862953084397187695766737193680997938270047266914448743599737311060278380280946648703137233006633139143642984674682566877306441990189395290689110016)
(* -2 (* t_0 (/ (sqrt (- (- t_3) t_2)) (sqrt (- t_0)))))
(* (* t_3 (/ (sqrt (+ t_0 t_2)) (sqrt t_3))) 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 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= 5.1e-287) {
tmp = -2.0 * (t_0 * (sqrt((-t_3 - t_2)) / sqrt(-t_0)));
} else {
tmp = (t_3 * (sqrt((t_0 + t_2)) / sqrt(t_3))) * 2.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 <= 5.1d-287) then
tmp = (-2.0d0) * (t_0 * (sqrt((-t_3 - t_2)) / sqrt(-t_0)))
else
tmp = (t_3 * (sqrt((t_0 + t_2)) / sqrt(t_3))) * 2.0d0
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 <= 5.1e-287) {
tmp = -2.0 * (t_0 * (Math.sqrt((-t_3 - t_2)) / Math.sqrt(-t_0)));
} else {
tmp = (t_3 * (Math.sqrt((t_0 + t_2)) / Math.sqrt(t_3))) * 2.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 <= 5.1e-287: tmp = -2.0 * (t_0 * (math.sqrt((-t_3 - t_2)) / math.sqrt(-t_0))) else: tmp = (t_3 * (math.sqrt((t_0 + t_2)) / math.sqrt(t_3))) * 2.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 <= 5.1e-287) tmp = Float64(-2.0 * Float64(t_0 * Float64(sqrt(Float64(Float64(-t_3) - t_2)) / sqrt(Float64(-t_0))))); else tmp = Float64(Float64(t_3 * Float64(sqrt(Float64(t_0 + t_2)) / sqrt(t_3))) * 2.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 <= 5.1e-287) tmp = -2.0 * (t_0 * (sqrt((-t_3 - t_2)) / sqrt(-t_0))); else tmp = (t_3 * (sqrt((t_0 + t_2)) / sqrt(t_3))) * 2.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, 8743510234639941/171441377149802771351748007849600289689824769872885377191000062139256168179989779598911740610511337300415147666808503492029943245710770246975753241195177196862953084397187695766737193680997938270047266914448743599737311060278380280946648703137233006633139143642984674682566877306441990189395290689110016], N[(-2 * N[(t$95$0 * N[(N[Sqrt[N[((-t$95$3) - t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[(-t$95$0)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$3 * N[(N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $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 \frac{8743510234639941}{171441377149802771351748007849600289689824769872885377191000062139256168179989779598911740610511337300415147666808503492029943245710770246975753241195177196862953084397187695766737193680997938270047266914448743599737311060278380280946648703137233006633139143642984674682566877306441990189395290689110016}:\\
\;\;\;\;-2 \cdot \left(t\_0 \cdot \frac{\sqrt{\left(-t\_3\right) - t\_2}}{\sqrt{-t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_3 \cdot \frac{\sqrt{t\_0 + t\_2}}{\sqrt{t\_3}}\right) \cdot 2\\
\end{array}
if y < 5.0999999999999998e-287Initial program 69.9%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6428.8%
Applied rewrites28.8%
lift-sqrt.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-unsound-sqrt.f64N/A
lower-neg.f6432.3%
Applied rewrites32.3%
if 5.0999999999999998e-287 < y Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.0%
Applied rewrites70.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6429.7%
Applied rewrites29.7%
lift-sqrt.f64N/A
lift-/.f64N/A
frac-2negN/A
distribute-frac-negN/A
distribute-neg-frac2N/A
sqrt-divN/A
remove-double-negN/A
lower-unsound-sqrt.f64N/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f6433.0%
Applied rewrites33.0%
(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 -23000000000000000)
(* -2 (* t_0 (sqrt (* (/ 1 t_0) (+ t_2 t_3)))))
(if (<= t_2 10500000000000000)
(* (sqrt (+ (* t_3 t_2) (* (+ t_3 t_2) t_0))) 2)
(* (* t_3 (sqrt (/ t_2 t_3))) 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 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -2.3e+16) {
tmp = -2.0 * (t_0 * sqrt(((1.0 / t_0) * (t_2 + t_3))));
} else if (t_2 <= 1.05e+16) {
tmp = sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0;
} else {
tmp = (t_3 * sqrt((t_2 / t_3))) * 2.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 <= (-2.3d+16)) then
tmp = (-2.0d0) * (t_0 * sqrt(((1.0d0 / t_0) * (t_2 + t_3))))
else if (t_2 <= 1.05d+16) then
tmp = sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0d0
else
tmp = (t_3 * sqrt((t_2 / t_3))) * 2.0d0
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 <= -2.3e+16) {
tmp = -2.0 * (t_0 * Math.sqrt(((1.0 / t_0) * (t_2 + t_3))));
} else if (t_2 <= 1.05e+16) {
tmp = Math.sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0;
} else {
tmp = (t_3 * Math.sqrt((t_2 / t_3))) * 2.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 <= -2.3e+16: tmp = -2.0 * (t_0 * math.sqrt(((1.0 / t_0) * (t_2 + t_3)))) elif t_2 <= 1.05e+16: tmp = math.sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0 else: tmp = (t_3 * math.sqrt((t_2 / t_3))) * 2.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 <= -2.3e+16) tmp = Float64(-2.0 * Float64(t_0 * sqrt(Float64(Float64(1.0 / t_0) * Float64(t_2 + t_3))))); elseif (t_2 <= 1.05e+16) tmp = Float64(sqrt(Float64(Float64(t_3 * t_2) + Float64(Float64(t_3 + t_2) * t_0))) * 2.0); else tmp = Float64(Float64(t_3 * sqrt(Float64(t_2 / t_3))) * 2.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 <= -2.3e+16) tmp = -2.0 * (t_0 * sqrt(((1.0 / t_0) * (t_2 + t_3)))); elseif (t_2 <= 1.05e+16) tmp = sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0; else tmp = (t_3 * sqrt((t_2 / t_3))) * 2.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, -23000000000000000], N[(-2 * N[(t$95$0 * N[Sqrt[N[(N[(1 / t$95$0), $MachinePrecision] * N[(t$95$2 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 10500000000000000], N[(N[Sqrt[N[(N[(t$95$3 * t$95$2), $MachinePrecision] + N[(N[(t$95$3 + t$95$2), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2), $MachinePrecision], N[(N[(t$95$3 * N[Sqrt[N[(t$95$2 / t$95$3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 2), $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 -23000000000000000:\\
\;\;\;\;-2 \cdot \left(t\_0 \cdot \sqrt{\frac{1}{t\_0} \cdot \left(t\_2 + t\_3\right)}\right)\\
\mathbf{elif}\;t\_2 \leq 10500000000000000:\\
\;\;\;\;\sqrt{t\_3 \cdot t\_2 + \left(t\_3 + t\_2\right) \cdot t\_0} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(t\_3 \cdot \sqrt{\frac{t\_2}{t\_3}}\right) \cdot 2\\
\end{array}
if y < -2.3e16Initial program 69.9%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6428.8%
Applied rewrites28.8%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
sub-flip-reverseN/A
sub-negateN/A
add-flipN/A
+-commutativeN/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
sub-negate-revN/A
lift-*.f64N/A
mul-1-negN/A
add-flipN/A
+-commutativeN/A
lower-+.f6428.8%
Applied rewrites28.8%
if -2.3e16 < y < 1.05e16Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.0%
Applied rewrites70.0%
if 1.05e16 < y Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.0%
Applied rewrites70.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6429.7%
Applied rewrites29.7%
Taylor expanded in x around 0
Applied rewrites15.5%
(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
-5060056332683/101201126653655309176247673359458653524778324882071059178450679013715169783997673445980191850718562247593538932158405955694904368692896738433506699970369254960758712138283180682233453871046608170619883839236372534281003741712346349309051677824579778170405028256179384776166707307615251266093163754323003131653853870546747392)
(* -2 (* t_0 (/ (sqrt (- t_2)) (sqrt (- t_0)))))
(* (* t_3 (/ (sqrt (+ t_0 t_2)) (sqrt t_3))) 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 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -5e-311) {
tmp = -2.0 * (t_0 * (sqrt(-t_2) / sqrt(-t_0)));
} else {
tmp = (t_3 * (sqrt((t_0 + t_2)) / sqrt(t_3))) * 2.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 <= (-5d-311)) then
tmp = (-2.0d0) * (t_0 * (sqrt(-t_2) / sqrt(-t_0)))
else
tmp = (t_3 * (sqrt((t_0 + t_2)) / sqrt(t_3))) * 2.0d0
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 <= -5e-311) {
tmp = -2.0 * (t_0 * (Math.sqrt(-t_2) / Math.sqrt(-t_0)));
} else {
tmp = (t_3 * (Math.sqrt((t_0 + t_2)) / Math.sqrt(t_3))) * 2.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 <= -5e-311: tmp = -2.0 * (t_0 * (math.sqrt(-t_2) / math.sqrt(-t_0))) else: tmp = (t_3 * (math.sqrt((t_0 + t_2)) / math.sqrt(t_3))) * 2.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 <= -5e-311) tmp = Float64(-2.0 * Float64(t_0 * Float64(sqrt(Float64(-t_2)) / sqrt(Float64(-t_0))))); else tmp = Float64(Float64(t_3 * Float64(sqrt(Float64(t_0 + t_2)) / sqrt(t_3))) * 2.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 <= -5e-311) tmp = -2.0 * (t_0 * (sqrt(-t_2) / sqrt(-t_0))); else tmp = (t_3 * (sqrt((t_0 + t_2)) / sqrt(t_3))) * 2.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, -5060056332683/101201126653655309176247673359458653524778324882071059178450679013715169783997673445980191850718562247593538932158405955694904368692896738433506699970369254960758712138283180682233453871046608170619883839236372534281003741712346349309051677824579778170405028256179384776166707307615251266093163754323003131653853870546747392], N[(-2 * N[(t$95$0 * N[(N[Sqrt[(-t$95$2)], $MachinePrecision] / N[Sqrt[(-t$95$0)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$3 * N[(N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $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 \frac{-5060056332683}{101201126653655309176247673359458653524778324882071059178450679013715169783997673445980191850718562247593538932158405955694904368692896738433506699970369254960758712138283180682233453871046608170619883839236372534281003741712346349309051677824579778170405028256179384776166707307615251266093163754323003131653853870546747392}:\\
\;\;\;\;-2 \cdot \left(t\_0 \cdot \frac{\sqrt{-t\_2}}{\sqrt{-t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_3 \cdot \frac{\sqrt{t\_0 + t\_2}}{\sqrt{t\_3}}\right) \cdot 2\\
\end{array}
if y < -5.0000000000002318e-311Initial program 69.9%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6428.8%
Applied rewrites28.8%
lift-sqrt.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-frac2N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-unsound-sqrt.f64N/A
lower-neg.f6432.3%
Applied rewrites32.3%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-neg.f6416.6%
Applied rewrites16.6%
if -5.0000000000002318e-311 < y Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.0%
Applied rewrites70.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6429.7%
Applied rewrites29.7%
lift-sqrt.f64N/A
lift-/.f64N/A
frac-2negN/A
distribute-frac-negN/A
distribute-neg-frac2N/A
sqrt-divN/A
remove-double-negN/A
lower-unsound-sqrt.f64N/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f6433.0%
Applied rewrites33.0%
(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 -23000000000000000)
(* (* (sqrt (/ t_0 t_2)) (- t_2)) 2)
(if (<= t_2 10500000000000000)
(* (sqrt (+ (* t_3 t_2) (* (+ t_3 t_2) t_0))) 2)
(* (* t_3 (sqrt (/ t_2 t_3))) 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 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -2.3e+16) {
tmp = (sqrt((t_0 / t_2)) * -t_2) * 2.0;
} else if (t_2 <= 1.05e+16) {
tmp = sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0;
} else {
tmp = (t_3 * sqrt((t_2 / t_3))) * 2.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 <= (-2.3d+16)) then
tmp = (sqrt((t_0 / t_2)) * -t_2) * 2.0d0
else if (t_2 <= 1.05d+16) then
tmp = sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0d0
else
tmp = (t_3 * sqrt((t_2 / t_3))) * 2.0d0
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 <= -2.3e+16) {
tmp = (Math.sqrt((t_0 / t_2)) * -t_2) * 2.0;
} else if (t_2 <= 1.05e+16) {
tmp = Math.sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0;
} else {
tmp = (t_3 * Math.sqrt((t_2 / t_3))) * 2.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 <= -2.3e+16: tmp = (math.sqrt((t_0 / t_2)) * -t_2) * 2.0 elif t_2 <= 1.05e+16: tmp = math.sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0 else: tmp = (t_3 * math.sqrt((t_2 / t_3))) * 2.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 <= -2.3e+16) tmp = Float64(Float64(sqrt(Float64(t_0 / t_2)) * Float64(-t_2)) * 2.0); elseif (t_2 <= 1.05e+16) tmp = Float64(sqrt(Float64(Float64(t_3 * t_2) + Float64(Float64(t_3 + t_2) * t_0))) * 2.0); else tmp = Float64(Float64(t_3 * sqrt(Float64(t_2 / t_3))) * 2.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 <= -2.3e+16) tmp = (sqrt((t_0 / t_2)) * -t_2) * 2.0; elseif (t_2 <= 1.05e+16) tmp = sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0; else tmp = (t_3 * sqrt((t_2 / t_3))) * 2.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, -23000000000000000], N[(N[(N[Sqrt[N[(t$95$0 / t$95$2), $MachinePrecision]], $MachinePrecision] * (-t$95$2)), $MachinePrecision] * 2), $MachinePrecision], If[LessEqual[t$95$2, 10500000000000000], N[(N[Sqrt[N[(N[(t$95$3 * t$95$2), $MachinePrecision] + N[(N[(t$95$3 + t$95$2), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2), $MachinePrecision], N[(N[(t$95$3 * N[Sqrt[N[(t$95$2 / t$95$3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 2), $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 -23000000000000000:\\
\;\;\;\;\left(\sqrt{\frac{t\_0}{t\_2}} \cdot \left(-t\_2\right)\right) \cdot 2\\
\mathbf{elif}\;t\_2 \leq 10500000000000000:\\
\;\;\;\;\sqrt{t\_3 \cdot t\_2 + \left(t\_3 + t\_2\right) \cdot t\_0} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(t\_3 \cdot \sqrt{\frac{t\_2}{t\_3}}\right) \cdot 2\\
\end{array}
if y < -2.3e16Initial program 69.9%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6424.8%
Applied rewrites24.8%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6415.2%
Applied rewrites15.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6415.2%
Applied rewrites15.2%
if -2.3e16 < y < 1.05e16Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.0%
Applied rewrites70.0%
if 1.05e16 < y Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.0%
Applied rewrites70.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6429.7%
Applied rewrites29.7%
Taylor expanded in x around 0
Applied rewrites15.5%
(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 -23000000000000000)
(* -2 (* t_0 (sqrt (/ t_2 t_0))))
(if (<= t_2 10500000000000000)
(* (sqrt (+ (* t_3 t_2) (* (+ t_3 t_2) t_0))) 2)
(* (* t_3 (sqrt (/ t_2 t_3))) 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 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -2.3e+16) {
tmp = -2.0 * (t_0 * sqrt((t_2 / t_0)));
} else if (t_2 <= 1.05e+16) {
tmp = sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0;
} else {
tmp = (t_3 * sqrt((t_2 / t_3))) * 2.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 <= (-2.3d+16)) then
tmp = (-2.0d0) * (t_0 * sqrt((t_2 / t_0)))
else if (t_2 <= 1.05d+16) then
tmp = sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0d0
else
tmp = (t_3 * sqrt((t_2 / t_3))) * 2.0d0
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 <= -2.3e+16) {
tmp = -2.0 * (t_0 * Math.sqrt((t_2 / t_0)));
} else if (t_2 <= 1.05e+16) {
tmp = Math.sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0;
} else {
tmp = (t_3 * Math.sqrt((t_2 / t_3))) * 2.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 <= -2.3e+16: tmp = -2.0 * (t_0 * math.sqrt((t_2 / t_0))) elif t_2 <= 1.05e+16: tmp = math.sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0 else: tmp = (t_3 * math.sqrt((t_2 / t_3))) * 2.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 <= -2.3e+16) tmp = Float64(-2.0 * Float64(t_0 * sqrt(Float64(t_2 / t_0)))); elseif (t_2 <= 1.05e+16) tmp = Float64(sqrt(Float64(Float64(t_3 * t_2) + Float64(Float64(t_3 + t_2) * t_0))) * 2.0); else tmp = Float64(Float64(t_3 * sqrt(Float64(t_2 / t_3))) * 2.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 <= -2.3e+16) tmp = -2.0 * (t_0 * sqrt((t_2 / t_0))); elseif (t_2 <= 1.05e+16) tmp = sqrt(((t_3 * t_2) + ((t_3 + t_2) * t_0))) * 2.0; else tmp = (t_3 * sqrt((t_2 / t_3))) * 2.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, -23000000000000000], N[(-2 * N[(t$95$0 * N[Sqrt[N[(t$95$2 / t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 10500000000000000], N[(N[Sqrt[N[(N[(t$95$3 * t$95$2), $MachinePrecision] + N[(N[(t$95$3 + t$95$2), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2), $MachinePrecision], N[(N[(t$95$3 * N[Sqrt[N[(t$95$2 / t$95$3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 2), $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 -23000000000000000:\\
\;\;\;\;-2 \cdot \left(t\_0 \cdot \sqrt{\frac{t\_2}{t\_0}}\right)\\
\mathbf{elif}\;t\_2 \leq 10500000000000000:\\
\;\;\;\;\sqrt{t\_3 \cdot t\_2 + \left(t\_3 + t\_2\right) \cdot t\_0} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(t\_3 \cdot \sqrt{\frac{t\_2}{t\_3}}\right) \cdot 2\\
\end{array}
if y < -2.3e16Initial program 69.9%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6428.8%
Applied rewrites28.8%
Taylor expanded in y around inf
lower-/.f6415.1%
Applied rewrites15.1%
if -2.3e16 < y < 1.05e16Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.0%
Applied rewrites70.0%
if 1.05e16 < y Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.0%
Applied rewrites70.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6429.7%
Applied rewrites29.7%
Taylor expanded in x around 0
Applied rewrites15.5%
(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 -26500000000000000)
(* -2 (* t_0 (sqrt (/ t_2 t_0))))
(if (<=
t_2
-3269984763141685/653996952628336987883560210607911261328982429019490727199554680401825592727622145076415026132626866532955732981904996841544888480036812770751011814861973559810459458912611754481266760562888863640011851938052153014134639969934006809031100094365055109531933378765047739725368031717079125173169291264)
(* (sqrt (* t_0 (+ t_2 t_3))) 2)
(if (<= t_2 1500000000000000000)
(* 2 (sqrt (* t_3 (+ t_0 t_2))))
(* (* t_3 (sqrt (/ t_2 t_3))) 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 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -2.65e+16) {
tmp = -2.0 * (t_0 * sqrt((t_2 / t_0)));
} else if (t_2 <= -5e-282) {
tmp = sqrt((t_0 * (t_2 + t_3))) * 2.0;
} else if (t_2 <= 1.5e+18) {
tmp = 2.0 * sqrt((t_3 * (t_0 + t_2)));
} else {
tmp = (t_3 * sqrt((t_2 / t_3))) * 2.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 <= (-2.65d+16)) then
tmp = (-2.0d0) * (t_0 * sqrt((t_2 / t_0)))
else if (t_2 <= (-5d-282)) then
tmp = sqrt((t_0 * (t_2 + t_3))) * 2.0d0
else if (t_2 <= 1.5d+18) then
tmp = 2.0d0 * sqrt((t_3 * (t_0 + t_2)))
else
tmp = (t_3 * sqrt((t_2 / t_3))) * 2.0d0
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 <= -2.65e+16) {
tmp = -2.0 * (t_0 * Math.sqrt((t_2 / t_0)));
} else if (t_2 <= -5e-282) {
tmp = Math.sqrt((t_0 * (t_2 + t_3))) * 2.0;
} else if (t_2 <= 1.5e+18) {
tmp = 2.0 * Math.sqrt((t_3 * (t_0 + t_2)));
} else {
tmp = (t_3 * Math.sqrt((t_2 / t_3))) * 2.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 <= -2.65e+16: tmp = -2.0 * (t_0 * math.sqrt((t_2 / t_0))) elif t_2 <= -5e-282: tmp = math.sqrt((t_0 * (t_2 + t_3))) * 2.0 elif t_2 <= 1.5e+18: tmp = 2.0 * math.sqrt((t_3 * (t_0 + t_2))) else: tmp = (t_3 * math.sqrt((t_2 / t_3))) * 2.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 <= -2.65e+16) tmp = Float64(-2.0 * Float64(t_0 * sqrt(Float64(t_2 / t_0)))); elseif (t_2 <= -5e-282) tmp = Float64(sqrt(Float64(t_0 * Float64(t_2 + t_3))) * 2.0); elseif (t_2 <= 1.5e+18) tmp = Float64(2.0 * sqrt(Float64(t_3 * Float64(t_0 + t_2)))); else tmp = Float64(Float64(t_3 * sqrt(Float64(t_2 / t_3))) * 2.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 <= -2.65e+16) tmp = -2.0 * (t_0 * sqrt((t_2 / t_0))); elseif (t_2 <= -5e-282) tmp = sqrt((t_0 * (t_2 + t_3))) * 2.0; elseif (t_2 <= 1.5e+18) tmp = 2.0 * sqrt((t_3 * (t_0 + t_2))); else tmp = (t_3 * sqrt((t_2 / t_3))) * 2.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, -26500000000000000], N[(-2 * N[(t$95$0 * N[Sqrt[N[(t$95$2 / t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -3269984763141685/653996952628336987883560210607911261328982429019490727199554680401825592727622145076415026132626866532955732981904996841544888480036812770751011814861973559810459458912611754481266760562888863640011851938052153014134639969934006809031100094365055109531933378765047739725368031717079125173169291264], N[(N[Sqrt[N[(t$95$0 * N[(t$95$2 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2), $MachinePrecision], If[LessEqual[t$95$2, 1500000000000000000], N[(2 * N[Sqrt[N[(t$95$3 * N[(t$95$0 + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$3 * N[Sqrt[N[(t$95$2 / t$95$3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 2), $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 -26500000000000000:\\
\;\;\;\;-2 \cdot \left(t\_0 \cdot \sqrt{\frac{t\_2}{t\_0}}\right)\\
\mathbf{elif}\;t\_2 \leq \frac{-3269984763141685}{653996952628336987883560210607911261328982429019490727199554680401825592727622145076415026132626866532955732981904996841544888480036812770751011814861973559810459458912611754481266760562888863640011851938052153014134639969934006809031100094365055109531933378765047739725368031717079125173169291264}:\\
\;\;\;\;\sqrt{t\_0 \cdot \left(t\_2 + t\_3\right)} \cdot 2\\
\mathbf{elif}\;t\_2 \leq 1500000000000000000:\\
\;\;\;\;2 \cdot \sqrt{t\_3 \cdot \left(t\_0 + t\_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(t\_3 \cdot \sqrt{\frac{t\_2}{t\_3}}\right) \cdot 2\\
\end{array}
if y < -2.65e16Initial program 69.9%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6428.8%
Applied rewrites28.8%
Taylor expanded in y around inf
lower-/.f6415.1%
Applied rewrites15.1%
if -2.65e16 < y < -5.0000000000000001e-282Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.0%
Applied rewrites70.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6447.6%
Applied rewrites47.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6447.0%
Applied rewrites47.0%
if -5.0000000000000001e-282 < y < 1.5e18Initial program 69.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6447.2%
Applied rewrites47.2%
if 1.5e18 < y Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.0%
Applied rewrites70.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-+.f6429.7%
Applied rewrites29.7%
Taylor expanded in x around 0
Applied rewrites15.5%
(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 -26500000000000000)
(* -2 (* t_0 (sqrt (/ t_2 t_0))))
(if (<=
t_2
-3269984763141685/653996952628336987883560210607911261328982429019490727199554680401825592727622145076415026132626866532955732981904996841544888480036812770751011814861973559810459458912611754481266760562888863640011851938052153014134639969934006809031100094365055109531933378765047739725368031717079125173169291264)
(* (sqrt (* t_0 (+ t_2 t_3))) 2)
(* 2 (sqrt (* t_3 (+ t_0 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 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -2.65e+16) {
tmp = -2.0 * (t_0 * sqrt((t_2 / t_0)));
} else if (t_2 <= -5e-282) {
tmp = sqrt((t_0 * (t_2 + t_3))) * 2.0;
} else {
tmp = 2.0 * sqrt((t_3 * (t_0 + 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 = fmin(fmax(x, y), t_1)
t_3 = fmax(fmax(x, y), t_1)
if (t_2 <= (-2.65d+16)) then
tmp = (-2.0d0) * (t_0 * sqrt((t_2 / t_0)))
else if (t_2 <= (-5d-282)) then
tmp = sqrt((t_0 * (t_2 + t_3))) * 2.0d0
else
tmp = 2.0d0 * sqrt((t_3 * (t_0 + 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 = fmin(fmax(x, y), t_1);
double t_3 = fmax(fmax(x, y), t_1);
double tmp;
if (t_2 <= -2.65e+16) {
tmp = -2.0 * (t_0 * Math.sqrt((t_2 / t_0)));
} else if (t_2 <= -5e-282) {
tmp = Math.sqrt((t_0 * (t_2 + t_3))) * 2.0;
} else {
tmp = 2.0 * Math.sqrt((t_3 * (t_0 + 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 = fmin(fmax(x, y), t_1) t_3 = fmax(fmax(x, y), t_1) tmp = 0 if t_2 <= -2.65e+16: tmp = -2.0 * (t_0 * math.sqrt((t_2 / t_0))) elif t_2 <= -5e-282: tmp = math.sqrt((t_0 * (t_2 + t_3))) * 2.0 else: tmp = 2.0 * math.sqrt((t_3 * (t_0 + 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 = fmin(fmax(x, y), t_1) t_3 = fmax(fmax(x, y), t_1) tmp = 0.0 if (t_2 <= -2.65e+16) tmp = Float64(-2.0 * Float64(t_0 * sqrt(Float64(t_2 / t_0)))); elseif (t_2 <= -5e-282) tmp = Float64(sqrt(Float64(t_0 * Float64(t_2 + t_3))) * 2.0); else tmp = Float64(2.0 * sqrt(Float64(t_3 * Float64(t_0 + 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 = min(max(x, y), t_1); t_3 = max(max(x, y), t_1); tmp = 0.0; if (t_2 <= -2.65e+16) tmp = -2.0 * (t_0 * sqrt((t_2 / t_0))); elseif (t_2 <= -5e-282) tmp = sqrt((t_0 * (t_2 + t_3))) * 2.0; else tmp = 2.0 * sqrt((t_3 * (t_0 + 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[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, -26500000000000000], N[(-2 * N[(t$95$0 * N[Sqrt[N[(t$95$2 / t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -3269984763141685/653996952628336987883560210607911261328982429019490727199554680401825592727622145076415026132626866532955732981904996841544888480036812770751011814861973559810459458912611754481266760562888863640011851938052153014134639969934006809031100094365055109531933378765047739725368031717079125173169291264], N[(N[Sqrt[N[(t$95$0 * N[(t$95$2 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2), $MachinePrecision], N[(2 * N[Sqrt[N[(t$95$3 * N[(t$95$0 + 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{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 -26500000000000000:\\
\;\;\;\;-2 \cdot \left(t\_0 \cdot \sqrt{\frac{t\_2}{t\_0}}\right)\\
\mathbf{elif}\;t\_2 \leq \frac{-3269984763141685}{653996952628336987883560210607911261328982429019490727199554680401825592727622145076415026132626866532955732981904996841544888480036812770751011814861973559810459458912611754481266760562888863640011851938052153014134639969934006809031100094365055109531933378765047739725368031717079125173169291264}:\\
\;\;\;\;\sqrt{t\_0 \cdot \left(t\_2 + t\_3\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{t\_3 \cdot \left(t\_0 + t\_2\right)}\\
\end{array}
if y < -2.65e16Initial program 69.9%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6428.8%
Applied rewrites28.8%
Taylor expanded in y around inf
lower-/.f6415.1%
Applied rewrites15.1%
if -2.65e16 < y < -5.0000000000000001e-282Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.0%
Applied rewrites70.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6447.6%
Applied rewrites47.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6447.0%
Applied rewrites47.0%
if -5.0000000000000001e-282 < y Initial program 69.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6447.2%
Applied rewrites47.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
-3269984763141685/653996952628336987883560210607911261328982429019490727199554680401825592727622145076415026132626866532955732981904996841544888480036812770751011814861973559810459458912611754481266760562888863640011851938052153014134639969934006809031100094365055109531933378765047739725368031717079125173169291264)
(* (sqrt (* t_0 (+ t_3 t_2))) 2)
(* 2 (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 <= -5e-282) {
tmp = sqrt((t_0 * (t_3 + t_2))) * 2.0;
} 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 <= (-5d-282)) then
tmp = sqrt((t_0 * (t_3 + t_2))) * 2.0d0
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 <= -5e-282) {
tmp = Math.sqrt((t_0 * (t_3 + t_2))) * 2.0;
} 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 <= -5e-282: tmp = math.sqrt((t_0 * (t_3 + t_2))) * 2.0 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 <= -5e-282) tmp = Float64(sqrt(Float64(t_0 * Float64(t_3 + t_2))) * 2.0); 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 <= -5e-282) tmp = sqrt((t_0 * (t_3 + t_2))) * 2.0; 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, -3269984763141685/653996952628336987883560210607911261328982429019490727199554680401825592727622145076415026132626866532955732981904996841544888480036812770751011814861973559810459458912611754481266760562888863640011851938052153014134639969934006809031100094365055109531933378765047739725368031717079125173169291264], N[(N[Sqrt[N[(t$95$0 * N[(t$95$3 + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2), $MachinePrecision], N[(2 * 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 \frac{-3269984763141685}{653996952628336987883560210607911261328982429019490727199554680401825592727622145076415026132626866532955732981904996841544888480036812770751011814861973559810459458912611754481266760562888863640011851938052153014134639969934006809031100094365055109531933378765047739725368031717079125173169291264}:\\
\;\;\;\;\sqrt{t\_0 \cdot \left(t\_3 + t\_2\right)} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{t\_2 \cdot \left(t\_0 + t\_3\right)}\\
\end{array}
if y < -5.0000000000000001e-282Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6470.0%
Applied rewrites70.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6447.6%
Applied rewrites47.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6447.0%
Applied rewrites47.0%
if -5.0000000000000001e-282 < y Initial program 69.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f6447.2%
Applied rewrites47.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fmax (fmin x y) z)))
(*
2
(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 * 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 69.9%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f6447.6%
Applied rewrites47.6%
(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
-269773742959189/40874809539271061742722513162994453833061401813718170449972167525114099545476384067275939133289179158309733311369062302596555530002300798171938238428873347488153716182038234655079172535180553977500740746128259563383414998120875425564443755897815944345745836172815483732835501982317445323323080704)
(* 2 (sqrt (* (fmin (fmin x y) z) t_1)))
(* 2 (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 <= -6.6e-282) {
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 <= (-6.6d-282)) 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 <= -6.6e-282) {
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 <= -6.6e-282: 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 <= -6.6e-282) 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 <= -6.6e-282) 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, -269773742959189/40874809539271061742722513162994453833061401813718170449972167525114099545476384067275939133289179158309733311369062302596555530002300798171938238428873347488153716182038234655079172535180553977500740746128259563383414998120875425564443755897815944345745836172815483732835501982317445323323080704], N[(2 * N[Sqrt[N[(N[Min[N[Min[x, y], $MachinePrecision], z], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2 * 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 \frac{-269773742959189}{40874809539271061742722513162994453833061401813718170449972167525114099545476384067275939133289179158309733311369062302596555530002300798171938238428873347488153716182038234655079172535180553977500740746128259563383414998120875425564443755897815944345745836172815483732835501982317445323323080704}:\\
\;\;\;\;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 < -6.5999999999999998e-282Initial program 69.9%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6424.8%
Applied rewrites24.8%
if -6.5999999999999998e-282 < y Initial program 69.9%
Taylor expanded in x around 0
lower-*.f6425.1%
Applied rewrites25.1%
(FPCore (x y z) :precision binary64 (* 2 (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 * 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 69.9%
Taylor expanded in z around 0
lower-sqrt.f64N/A
lower-*.f6424.8%
Applied rewrites24.8%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:descartes from diagrams-contrib-1.3.0.5"
:precision binary64
(* 2 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))