
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / 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(a, b, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) + sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) + Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) + math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) + sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) + sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / 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(a, b, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) + sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) + Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) + math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) + sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) + sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (sqrt (* F 2.0))))
(if (<= A -3.2e-35)
(* t_0 (* -1.0 (sqrt (* (pow A -1.0) -0.5))))
(if (<= A 4.4e-209)
(* t_0 (* -1.0 (* (pow B_m -1.0) (sqrt (+ C (hypot B_m C))))))
(if (<= A 1.95e-28)
(/
(*
(sqrt (* (* 2.0 F) (fma (* C -4.0) A (* B_m B_m))))
(- (sqrt (+ (+ (hypot (- A C) B_m) A) C))))
(- (pow B_m 2.0) (* (* 4.0 A) C)))
(* 0.25 (sqrt (* (/ F A) -16.0))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = sqrt((F * 2.0));
double tmp;
if (A <= -3.2e-35) {
tmp = t_0 * (-1.0 * sqrt((pow(A, -1.0) * -0.5)));
} else if (A <= 4.4e-209) {
tmp = t_0 * (-1.0 * (pow(B_m, -1.0) * sqrt((C + hypot(B_m, C)))));
} else if (A <= 1.95e-28) {
tmp = (sqrt(((2.0 * F) * fma((C * -4.0), A, (B_m * B_m)))) * -sqrt(((hypot((A - C), B_m) + A) + C))) / (pow(B_m, 2.0) - ((4.0 * A) * C));
} else {
tmp = 0.25 * sqrt(((F / A) * -16.0));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = sqrt(Float64(F * 2.0)) tmp = 0.0 if (A <= -3.2e-35) tmp = Float64(t_0 * Float64(-1.0 * sqrt(Float64((A ^ -1.0) * -0.5)))); elseif (A <= 4.4e-209) tmp = Float64(t_0 * Float64(-1.0 * Float64((B_m ^ -1.0) * sqrt(Float64(C + hypot(B_m, C)))))); elseif (A <= 1.95e-28) tmp = Float64(Float64(sqrt(Float64(Float64(2.0 * F) * fma(Float64(C * -4.0), A, Float64(B_m * B_m)))) * Float64(-sqrt(Float64(Float64(hypot(Float64(A - C), B_m) + A) + C)))) / Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))); else tmp = Float64(0.25 * sqrt(Float64(Float64(F / A) * -16.0))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[A, -3.2e-35], N[(t$95$0 * N[(-1.0 * N[Sqrt[N[(N[Power[A, -1.0], $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 4.4e-209], N[(t$95$0 * N[(-1.0 * N[(N[Power[B$95$m, -1.0], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 1.95e-28], N[(N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * N[(N[(C * -4.0), $MachinePrecision] * A + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(N[(N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision] + A), $MachinePrecision] + C), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[Sqrt[N[(N[(F / A), $MachinePrecision] * -16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \sqrt{F \cdot 2}\\
\mathbf{if}\;A \leq -3.2 \cdot 10^{-35}:\\
\;\;\;\;t\_0 \cdot \left(-1 \cdot \sqrt{{A}^{-1} \cdot -0.5}\right)\\
\mathbf{elif}\;A \leq 4.4 \cdot 10^{-209}:\\
\;\;\;\;t\_0 \cdot \left(-1 \cdot \left({B\_m}^{-1} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right)\right)\\
\mathbf{elif}\;A \leq 1.95 \cdot 10^{-28}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot F\right) \cdot \mathsf{fma}\left(C \cdot -4, A, B\_m \cdot B\_m\right)} \cdot \left(-\sqrt{\left(\mathsf{hypot}\left(A - C, B\_m\right) + A\right) + C}\right)}{{B\_m}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \sqrt{\frac{F}{A} \cdot -16}\\
\end{array}
\end{array}
if A < -3.1999999999999998e-35Initial program 7.2%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites12.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites17.0%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites17.0%
Taylor expanded in A around -inf
sqrt-unprodN/A
metadata-evalN/A
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6453.9
Applied rewrites53.9%
if -3.1999999999999998e-35 < A < 4.40000000000000019e-209Initial program 31.5%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites48.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites55.6%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites55.6%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
pow2N/A
unpow2N/A
lower-hypot.f6464.8
Applied rewrites64.8%
if 4.40000000000000019e-209 < A < 1.94999999999999999e-28Initial program 34.9%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites61.6%
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6461.6
Applied rewrites61.6%
if 1.94999999999999999e-28 < A Initial program 12.9%
lift-sqrt.f64N/A
pow1/2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
Applied rewrites17.7%
Applied rewrites17.7%
Taylor expanded in C around inf
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6463.5
Applied rewrites63.5%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma -4.0 (* C A) (* B_m B_m)))
(t_1 (sqrt t_0))
(t_2 (- t_0))
(t_3 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_4
(/
(-
(sqrt
(*
(* 2.0 (* t_3 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0)))))))
t_3))
(t_5 (sqrt (* F 2.0))))
(if (<= t_4 -1e+107)
(* t_5 (/ (* t_1 (sqrt (+ C C))) t_2))
(if (<= t_4 -2e-203)
(* t_5 (/ (* t_1 (sqrt (+ (+ B_m A) C))) t_2))
(if (<= t_4 0.0)
(* t_5 (/ (* t_1 (sqrt (+ (+ C (* -0.5 (/ (* B_m B_m) A))) C))) t_2))
(if (<= t_4 INFINITY)
(* 0.25 (sqrt (* (/ F A) -16.0)))
(* t_5 (* -1.0 (/ 1.0 (sqrt B_m))))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma(-4.0, (C * A), (B_m * B_m));
double t_1 = sqrt(t_0);
double t_2 = -t_0;
double t_3 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_4 = -sqrt(((2.0 * (t_3 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / t_3;
double t_5 = sqrt((F * 2.0));
double tmp;
if (t_4 <= -1e+107) {
tmp = t_5 * ((t_1 * sqrt((C + C))) / t_2);
} else if (t_4 <= -2e-203) {
tmp = t_5 * ((t_1 * sqrt(((B_m + A) + C))) / t_2);
} else if (t_4 <= 0.0) {
tmp = t_5 * ((t_1 * sqrt(((C + (-0.5 * ((B_m * B_m) / A))) + C))) / t_2);
} else if (t_4 <= ((double) INFINITY)) {
tmp = 0.25 * sqrt(((F / A) * -16.0));
} else {
tmp = t_5 * (-1.0 * (1.0 / sqrt(B_m)));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(-4.0, Float64(C * A), Float64(B_m * B_m)) t_1 = sqrt(t_0) t_2 = Float64(-t_0) t_3 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_4 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_3 * F)) * Float64(Float64(A + C) + sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0))))))) / t_3) t_5 = sqrt(Float64(F * 2.0)) tmp = 0.0 if (t_4 <= -1e+107) tmp = Float64(t_5 * Float64(Float64(t_1 * sqrt(Float64(C + C))) / t_2)); elseif (t_4 <= -2e-203) tmp = Float64(t_5 * Float64(Float64(t_1 * sqrt(Float64(Float64(B_m + A) + C))) / t_2)); elseif (t_4 <= 0.0) tmp = Float64(t_5 * Float64(Float64(t_1 * sqrt(Float64(Float64(C + Float64(-0.5 * Float64(Float64(B_m * B_m) / A))) + C))) / t_2)); elseif (t_4 <= Inf) tmp = Float64(0.25 * sqrt(Float64(Float64(F / A) * -16.0))); else tmp = Float64(t_5 * Float64(-1.0 * Float64(1.0 / sqrt(B_m)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, Block[{t$95$2 = (-t$95$0)}, Block[{t$95$3 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$3 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$4, -1e+107], N[(t$95$5 * N[(N[(t$95$1 * N[Sqrt[N[(C + C), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -2e-203], N[(t$95$5 * N[(N[(t$95$1 * N[Sqrt[N[(N[(B$95$m + A), $MachinePrecision] + C), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.0], N[(t$95$5 * N[(N[(t$95$1 * N[Sqrt[N[(N[(C + N[(-0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + C), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(0.25 * N[Sqrt[N[(N[(F / A), $MachinePrecision] * -16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$5 * N[(-1.0 * N[(1.0 / N[Sqrt[B$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4, C \cdot A, B\_m \cdot B\_m\right)\\
t_1 := \sqrt{t\_0}\\
t_2 := -t\_0\\
t_3 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_4 := \frac{-\sqrt{\left(2 \cdot \left(t\_3 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)}}{t\_3}\\
t_5 := \sqrt{F \cdot 2}\\
\mathbf{if}\;t\_4 \leq -1 \cdot 10^{+107}:\\
\;\;\;\;t\_5 \cdot \frac{t\_1 \cdot \sqrt{C + C}}{t\_2}\\
\mathbf{elif}\;t\_4 \leq -2 \cdot 10^{-203}:\\
\;\;\;\;t\_5 \cdot \frac{t\_1 \cdot \sqrt{\left(B\_m + A\right) + C}}{t\_2}\\
\mathbf{elif}\;t\_4 \leq 0:\\
\;\;\;\;t\_5 \cdot \frac{t\_1 \cdot \sqrt{\left(C + -0.5 \cdot \frac{B\_m \cdot B\_m}{A}\right) + C}}{t\_2}\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;0.25 \cdot \sqrt{\frac{F}{A} \cdot -16}\\
\mathbf{else}:\\
\;\;\;\;t\_5 \cdot \left(-1 \cdot \frac{1}{\sqrt{B\_m}}\right)\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -9.9999999999999997e106Initial program 15.5%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites48.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites71.9%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites71.9%
Taylor expanded in A around -inf
Applied rewrites65.5%
if -9.9999999999999997e106 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -2.0000000000000001e-203Initial program 97.4%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites97.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites98.0%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites98.0%
Taylor expanded in B around inf
Applied rewrites65.6%
if -2.0000000000000001e-203 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -0.0Initial program 5.0%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites13.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites25.1%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites25.1%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6454.0
Applied rewrites54.0%
if -0.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < +inf.0Initial program 40.4%
lift-sqrt.f64N/A
pow1/2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
Applied rewrites56.8%
Applied rewrites56.7%
Taylor expanded in C around inf
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6479.3
Applied rewrites79.3%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) Initial program 0.0%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites0.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites0.3%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites0.3%
Taylor expanded in B around inf
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6446.9
Applied rewrites46.9%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (sqrt (* F 2.0))) (t_1 (fma (* A C) -4.0 (* B_m B_m))))
(if (<= A -3.2e-35)
(* t_0 (* -1.0 (sqrt (* (pow A -1.0) -0.5))))
(if (<= A 4.4e-209)
(* t_0 (* -1.0 (* (pow B_m -1.0) (sqrt (+ C (hypot B_m C))))))
(if (<= A 1.95e-28)
(*
(sqrt (+ (+ (hypot (- A C) B_m) A) C))
(/ (sqrt (* (* t_1 2.0) F)) (- t_1)))
(* 0.25 (sqrt (* (/ F A) -16.0))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = sqrt((F * 2.0));
double t_1 = fma((A * C), -4.0, (B_m * B_m));
double tmp;
if (A <= -3.2e-35) {
tmp = t_0 * (-1.0 * sqrt((pow(A, -1.0) * -0.5)));
} else if (A <= 4.4e-209) {
tmp = t_0 * (-1.0 * (pow(B_m, -1.0) * sqrt((C + hypot(B_m, C)))));
} else if (A <= 1.95e-28) {
tmp = sqrt(((hypot((A - C), B_m) + A) + C)) * (sqrt(((t_1 * 2.0) * F)) / -t_1);
} else {
tmp = 0.25 * sqrt(((F / A) * -16.0));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = sqrt(Float64(F * 2.0)) t_1 = fma(Float64(A * C), -4.0, Float64(B_m * B_m)) tmp = 0.0 if (A <= -3.2e-35) tmp = Float64(t_0 * Float64(-1.0 * sqrt(Float64((A ^ -1.0) * -0.5)))); elseif (A <= 4.4e-209) tmp = Float64(t_0 * Float64(-1.0 * Float64((B_m ^ -1.0) * sqrt(Float64(C + hypot(B_m, C)))))); elseif (A <= 1.95e-28) tmp = Float64(sqrt(Float64(Float64(hypot(Float64(A - C), B_m) + A) + C)) * Float64(sqrt(Float64(Float64(t_1 * 2.0) * F)) / Float64(-t_1))); else tmp = Float64(0.25 * sqrt(Float64(Float64(F / A) * -16.0))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(A * C), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[A, -3.2e-35], N[(t$95$0 * N[(-1.0 * N[Sqrt[N[(N[Power[A, -1.0], $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 4.4e-209], N[(t$95$0 * N[(-1.0 * N[(N[Power[B$95$m, -1.0], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 1.95e-28], N[(N[Sqrt[N[(N[(N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision] + A), $MachinePrecision] + C), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(N[(t$95$1 * 2.0), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[Sqrt[N[(N[(F / A), $MachinePrecision] * -16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \sqrt{F \cdot 2}\\
t_1 := \mathsf{fma}\left(A \cdot C, -4, B\_m \cdot B\_m\right)\\
\mathbf{if}\;A \leq -3.2 \cdot 10^{-35}:\\
\;\;\;\;t\_0 \cdot \left(-1 \cdot \sqrt{{A}^{-1} \cdot -0.5}\right)\\
\mathbf{elif}\;A \leq 4.4 \cdot 10^{-209}:\\
\;\;\;\;t\_0 \cdot \left(-1 \cdot \left({B\_m}^{-1} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right)\right)\\
\mathbf{elif}\;A \leq 1.95 \cdot 10^{-28}:\\
\;\;\;\;\sqrt{\left(\mathsf{hypot}\left(A - C, B\_m\right) + A\right) + C} \cdot \frac{\sqrt{\left(t\_1 \cdot 2\right) \cdot F}}{-t\_1}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \sqrt{\frac{F}{A} \cdot -16}\\
\end{array}
\end{array}
if A < -3.1999999999999998e-35Initial program 7.2%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites12.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites17.0%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites17.0%
Taylor expanded in A around -inf
sqrt-unprodN/A
metadata-evalN/A
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6453.9
Applied rewrites53.9%
if -3.1999999999999998e-35 < A < 4.40000000000000019e-209Initial program 31.5%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites48.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites55.6%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites55.6%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
pow2N/A
unpow2N/A
lower-hypot.f6464.8
Applied rewrites64.8%
if 4.40000000000000019e-209 < A < 1.94999999999999999e-28Initial program 34.9%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites61.6%
Applied rewrites61.6%
if 1.94999999999999999e-28 < A Initial program 12.9%
lift-sqrt.f64N/A
pow1/2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
Applied rewrites17.7%
Applied rewrites17.7%
Taylor expanded in C around inf
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6463.5
Applied rewrites63.5%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (sqrt (* F 2.0))) (t_1 (fma (* A C) -4.0 (* B_m B_m))))
(if (<= B_m 9.5e-60)
(* t_0 (* -1.0 (sqrt (* (pow A -1.0) -0.5))))
(if (<= B_m 1.62e+153)
(*
t_0
(* (sqrt t_1) (/ (- (sqrt (+ (+ (hypot (- A C) B_m) A) C))) t_1)))
(* t_0 (* -1.0 (* (pow B_m -1.0) (sqrt (+ A (hypot A B_m))))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = sqrt((F * 2.0));
double t_1 = fma((A * C), -4.0, (B_m * B_m));
double tmp;
if (B_m <= 9.5e-60) {
tmp = t_0 * (-1.0 * sqrt((pow(A, -1.0) * -0.5)));
} else if (B_m <= 1.62e+153) {
tmp = t_0 * (sqrt(t_1) * (-sqrt(((hypot((A - C), B_m) + A) + C)) / t_1));
} else {
tmp = t_0 * (-1.0 * (pow(B_m, -1.0) * sqrt((A + hypot(A, B_m)))));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = sqrt(Float64(F * 2.0)) t_1 = fma(Float64(A * C), -4.0, Float64(B_m * B_m)) tmp = 0.0 if (B_m <= 9.5e-60) tmp = Float64(t_0 * Float64(-1.0 * sqrt(Float64((A ^ -1.0) * -0.5)))); elseif (B_m <= 1.62e+153) tmp = Float64(t_0 * Float64(sqrt(t_1) * Float64(Float64(-sqrt(Float64(Float64(hypot(Float64(A - C), B_m) + A) + C))) / t_1))); else tmp = Float64(t_0 * Float64(-1.0 * Float64((B_m ^ -1.0) * sqrt(Float64(A + hypot(A, B_m)))))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(A * C), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 9.5e-60], N[(t$95$0 * N[(-1.0 * N[Sqrt[N[(N[Power[A, -1.0], $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 1.62e+153], N[(t$95$0 * N[(N[Sqrt[t$95$1], $MachinePrecision] * N[((-N[Sqrt[N[(N[(N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision] + A), $MachinePrecision] + C), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(-1.0 * N[(N[Power[B$95$m, -1.0], $MachinePrecision] * N[Sqrt[N[(A + N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \sqrt{F \cdot 2}\\
t_1 := \mathsf{fma}\left(A \cdot C, -4, B\_m \cdot B\_m\right)\\
\mathbf{if}\;B\_m \leq 9.5 \cdot 10^{-60}:\\
\;\;\;\;t\_0 \cdot \left(-1 \cdot \sqrt{{A}^{-1} \cdot -0.5}\right)\\
\mathbf{elif}\;B\_m \leq 1.62 \cdot 10^{+153}:\\
\;\;\;\;t\_0 \cdot \left(\sqrt{t\_1} \cdot \frac{-\sqrt{\left(\mathsf{hypot}\left(A - C, B\_m\right) + A\right) + C}}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(-1 \cdot \left({B\_m}^{-1} \cdot \sqrt{A + \mathsf{hypot}\left(A, B\_m\right)}\right)\right)\\
\end{array}
\end{array}
if B < 9.49999999999999958e-60Initial program 20.8%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites36.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites28.7%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites28.7%
Taylor expanded in A around -inf
sqrt-unprodN/A
metadata-evalN/A
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6448.0
Applied rewrites48.0%
if 9.49999999999999958e-60 < B < 1.62e153Initial program 29.8%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites46.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites54.9%
if 1.62e153 < B Initial program 0.1%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites0.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites0.3%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites0.3%
Taylor expanded in C around 0
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
unpow2N/A
pow2N/A
lower-hypot.f6477.2
Applied rewrites77.2%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (sqrt (* F 2.0))) (t_1 (fma (* A C) -4.0 (* B_m B_m))))
(if (<= B_m 9.5e-60)
(* t_0 (* -1.0 (sqrt (* (pow A -1.0) -0.5))))
(if (<= B_m 1.26e+154)
(*
t_0
(* (sqrt t_1) (/ (- (sqrt (+ (+ (hypot (- A C) B_m) A) C))) t_1)))
(* t_0 (* -1.0 (/ 1.0 (sqrt B_m))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = sqrt((F * 2.0));
double t_1 = fma((A * C), -4.0, (B_m * B_m));
double tmp;
if (B_m <= 9.5e-60) {
tmp = t_0 * (-1.0 * sqrt((pow(A, -1.0) * -0.5)));
} else if (B_m <= 1.26e+154) {
tmp = t_0 * (sqrt(t_1) * (-sqrt(((hypot((A - C), B_m) + A) + C)) / t_1));
} else {
tmp = t_0 * (-1.0 * (1.0 / sqrt(B_m)));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = sqrt(Float64(F * 2.0)) t_1 = fma(Float64(A * C), -4.0, Float64(B_m * B_m)) tmp = 0.0 if (B_m <= 9.5e-60) tmp = Float64(t_0 * Float64(-1.0 * sqrt(Float64((A ^ -1.0) * -0.5)))); elseif (B_m <= 1.26e+154) tmp = Float64(t_0 * Float64(sqrt(t_1) * Float64(Float64(-sqrt(Float64(Float64(hypot(Float64(A - C), B_m) + A) + C))) / t_1))); else tmp = Float64(t_0 * Float64(-1.0 * Float64(1.0 / sqrt(B_m)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(A * C), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 9.5e-60], N[(t$95$0 * N[(-1.0 * N[Sqrt[N[(N[Power[A, -1.0], $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 1.26e+154], N[(t$95$0 * N[(N[Sqrt[t$95$1], $MachinePrecision] * N[((-N[Sqrt[N[(N[(N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision] + A), $MachinePrecision] + C), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(-1.0 * N[(1.0 / N[Sqrt[B$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \sqrt{F \cdot 2}\\
t_1 := \mathsf{fma}\left(A \cdot C, -4, B\_m \cdot B\_m\right)\\
\mathbf{if}\;B\_m \leq 9.5 \cdot 10^{-60}:\\
\;\;\;\;t\_0 \cdot \left(-1 \cdot \sqrt{{A}^{-1} \cdot -0.5}\right)\\
\mathbf{elif}\;B\_m \leq 1.26 \cdot 10^{+154}:\\
\;\;\;\;t\_0 \cdot \left(\sqrt{t\_1} \cdot \frac{-\sqrt{\left(\mathsf{hypot}\left(A - C, B\_m\right) + A\right) + C}}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(-1 \cdot \frac{1}{\sqrt{B\_m}}\right)\\
\end{array}
\end{array}
if B < 9.49999999999999958e-60Initial program 20.8%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites36.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites28.7%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites28.7%
Taylor expanded in A around -inf
sqrt-unprodN/A
metadata-evalN/A
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6448.0
Applied rewrites48.0%
if 9.49999999999999958e-60 < B < 1.26e154Initial program 29.7%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites46.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites54.9%
if 1.26e154 < B Initial program 0.0%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites0.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites0.0%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites0.0%
Taylor expanded in B around inf
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6476.4
Applied rewrites76.4%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (sqrt (* F 2.0))) (t_1 (fma (* A C) -4.0 (* B_m B_m))))
(if (<= A -3.2e-35)
(* t_0 (* -1.0 (sqrt (* (pow A -1.0) -0.5))))
(if (<= A 8.2e-284)
(* t_0 (* -1.0 (/ 1.0 (sqrt B_m))))
(if (<= A 1.95e-28)
(*
(sqrt (+ (+ (hypot (- A C) B_m) A) C))
(/ (sqrt (* (* t_1 2.0) F)) (- t_1)))
(* 0.25 (sqrt (* (/ F A) -16.0))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = sqrt((F * 2.0));
double t_1 = fma((A * C), -4.0, (B_m * B_m));
double tmp;
if (A <= -3.2e-35) {
tmp = t_0 * (-1.0 * sqrt((pow(A, -1.0) * -0.5)));
} else if (A <= 8.2e-284) {
tmp = t_0 * (-1.0 * (1.0 / sqrt(B_m)));
} else if (A <= 1.95e-28) {
tmp = sqrt(((hypot((A - C), B_m) + A) + C)) * (sqrt(((t_1 * 2.0) * F)) / -t_1);
} else {
tmp = 0.25 * sqrt(((F / A) * -16.0));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = sqrt(Float64(F * 2.0)) t_1 = fma(Float64(A * C), -4.0, Float64(B_m * B_m)) tmp = 0.0 if (A <= -3.2e-35) tmp = Float64(t_0 * Float64(-1.0 * sqrt(Float64((A ^ -1.0) * -0.5)))); elseif (A <= 8.2e-284) tmp = Float64(t_0 * Float64(-1.0 * Float64(1.0 / sqrt(B_m)))); elseif (A <= 1.95e-28) tmp = Float64(sqrt(Float64(Float64(hypot(Float64(A - C), B_m) + A) + C)) * Float64(sqrt(Float64(Float64(t_1 * 2.0) * F)) / Float64(-t_1))); else tmp = Float64(0.25 * sqrt(Float64(Float64(F / A) * -16.0))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(A * C), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[A, -3.2e-35], N[(t$95$0 * N[(-1.0 * N[Sqrt[N[(N[Power[A, -1.0], $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 8.2e-284], N[(t$95$0 * N[(-1.0 * N[(1.0 / N[Sqrt[B$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 1.95e-28], N[(N[Sqrt[N[(N[(N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision] + A), $MachinePrecision] + C), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(N[(t$95$1 * 2.0), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[Sqrt[N[(N[(F / A), $MachinePrecision] * -16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \sqrt{F \cdot 2}\\
t_1 := \mathsf{fma}\left(A \cdot C, -4, B\_m \cdot B\_m\right)\\
\mathbf{if}\;A \leq -3.2 \cdot 10^{-35}:\\
\;\;\;\;t\_0 \cdot \left(-1 \cdot \sqrt{{A}^{-1} \cdot -0.5}\right)\\
\mathbf{elif}\;A \leq 8.2 \cdot 10^{-284}:\\
\;\;\;\;t\_0 \cdot \left(-1 \cdot \frac{1}{\sqrt{B\_m}}\right)\\
\mathbf{elif}\;A \leq 1.95 \cdot 10^{-28}:\\
\;\;\;\;\sqrt{\left(\mathsf{hypot}\left(A - C, B\_m\right) + A\right) + C} \cdot \frac{\sqrt{\left(t\_1 \cdot 2\right) \cdot F}}{-t\_1}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \sqrt{\frac{F}{A} \cdot -16}\\
\end{array}
\end{array}
if A < -3.1999999999999998e-35Initial program 7.2%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites12.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites17.0%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites17.0%
Taylor expanded in A around -inf
sqrt-unprodN/A
metadata-evalN/A
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6453.9
Applied rewrites53.9%
if -3.1999999999999998e-35 < A < 8.19999999999999997e-284Initial program 31.1%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites47.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites59.1%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites59.1%
Taylor expanded in B around inf
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6453.5
Applied rewrites53.5%
if 8.19999999999999997e-284 < A < 1.94999999999999999e-28Initial program 34.4%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites59.3%
Applied rewrites59.3%
if 1.94999999999999999e-28 < A Initial program 12.9%
lift-sqrt.f64N/A
pow1/2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
Applied rewrites17.7%
Applied rewrites17.7%
Taylor expanded in C around inf
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6463.5
Applied rewrites63.5%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (sqrt (* F 2.0))))
(if (<= B_m 5.6e+43)
(* t_0 (* -1.0 (sqrt (* (pow A -1.0) -0.5))))
(* t_0 (* -1.0 (/ 1.0 (sqrt B_m)))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = sqrt((F * 2.0));
double tmp;
if (B_m <= 5.6e+43) {
tmp = t_0 * (-1.0 * sqrt((pow(A, -1.0) * -0.5)));
} else {
tmp = t_0 * (-1.0 * (1.0 / sqrt(B_m)));
}
return tmp;
}
B_m = private
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_m, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((f * 2.0d0))
if (b_m <= 5.6d+43) then
tmp = t_0 * ((-1.0d0) * sqrt(((a ** (-1.0d0)) * (-0.5d0))))
else
tmp = t_0 * ((-1.0d0) * (1.0d0 / sqrt(b_m)))
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double t_0 = Math.sqrt((F * 2.0));
double tmp;
if (B_m <= 5.6e+43) {
tmp = t_0 * (-1.0 * Math.sqrt((Math.pow(A, -1.0) * -0.5)));
} else {
tmp = t_0 * (-1.0 * (1.0 / Math.sqrt(B_m)));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): t_0 = math.sqrt((F * 2.0)) tmp = 0 if B_m <= 5.6e+43: tmp = t_0 * (-1.0 * math.sqrt((math.pow(A, -1.0) * -0.5))) else: tmp = t_0 * (-1.0 * (1.0 / math.sqrt(B_m))) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = sqrt(Float64(F * 2.0)) tmp = 0.0 if (B_m <= 5.6e+43) tmp = Float64(t_0 * Float64(-1.0 * sqrt(Float64((A ^ -1.0) * -0.5)))); else tmp = Float64(t_0 * Float64(-1.0 * Float64(1.0 / sqrt(B_m)))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
t_0 = sqrt((F * 2.0));
tmp = 0.0;
if (B_m <= 5.6e+43)
tmp = t_0 * (-1.0 * sqrt(((A ^ -1.0) * -0.5)));
else
tmp = t_0 * (-1.0 * (1.0 / sqrt(B_m)));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[B$95$m, 5.6e+43], N[(t$95$0 * N[(-1.0 * N[Sqrt[N[(N[Power[A, -1.0], $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(-1.0 * N[(1.0 / N[Sqrt[B$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \sqrt{F \cdot 2}\\
\mathbf{if}\;B\_m \leq 5.6 \cdot 10^{+43}:\\
\;\;\;\;t\_0 \cdot \left(-1 \cdot \sqrt{{A}^{-1} \cdot -0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(-1 \cdot \frac{1}{\sqrt{B\_m}}\right)\\
\end{array}
\end{array}
if B < 5.60000000000000038e43Initial program 24.5%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites40.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites34.2%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites34.2%
Taylor expanded in A around -inf
sqrt-unprodN/A
metadata-evalN/A
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6445.8
Applied rewrites45.8%
if 5.60000000000000038e43 < B Initial program 10.8%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites17.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites25.5%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites25.5%
Taylor expanded in B around inf
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6463.9
Applied rewrites63.9%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma -4.0 (* C A) (* B_m B_m))) (t_1 (sqrt (* F 2.0))))
(if (<= B_m 1.8e-57)
(* t_1 (/ (* (sqrt t_0) (sqrt (+ C C))) (- t_0)))
(* t_1 (* -1.0 (/ 1.0 (sqrt B_m)))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma(-4.0, (C * A), (B_m * B_m));
double t_1 = sqrt((F * 2.0));
double tmp;
if (B_m <= 1.8e-57) {
tmp = t_1 * ((sqrt(t_0) * sqrt((C + C))) / -t_0);
} else {
tmp = t_1 * (-1.0 * (1.0 / sqrt(B_m)));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(-4.0, Float64(C * A), Float64(B_m * B_m)) t_1 = sqrt(Float64(F * 2.0)) tmp = 0.0 if (B_m <= 1.8e-57) tmp = Float64(t_1 * Float64(Float64(sqrt(t_0) * sqrt(Float64(C + C))) / Float64(-t_0))); else tmp = Float64(t_1 * Float64(-1.0 * Float64(1.0 / sqrt(B_m)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[B$95$m, 1.8e-57], N[(t$95$1 * N[(N[(N[Sqrt[t$95$0], $MachinePrecision] * N[Sqrt[N[(C + C), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / (-t$95$0)), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(-1.0 * N[(1.0 / N[Sqrt[B$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4, C \cdot A, B\_m \cdot B\_m\right)\\
t_1 := \sqrt{F \cdot 2}\\
\mathbf{if}\;B\_m \leq 1.8 \cdot 10^{-57}:\\
\;\;\;\;t\_1 \cdot \frac{\sqrt{t\_0} \cdot \sqrt{C + C}}{-t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(-1 \cdot \frac{1}{\sqrt{B\_m}}\right)\\
\end{array}
\end{array}
if B < 1.8000000000000001e-57Initial program 20.7%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites36.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites28.7%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites28.7%
Taylor expanded in A around -inf
Applied rewrites37.8%
if 1.8000000000000001e-57 < B Initial program 17.2%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites26.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites31.7%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites31.7%
Taylor expanded in B around inf
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6453.0
Applied rewrites53.0%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (if (<= B_m 5.5e-61) (* 0.25 (sqrt (* (/ F A) -16.0))) (* (sqrt (* F 2.0)) (* -1.0 (/ 1.0 (sqrt B_m))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 5.5e-61) {
tmp = 0.25 * sqrt(((F / A) * -16.0));
} else {
tmp = sqrt((F * 2.0)) * (-1.0 * (1.0 / sqrt(B_m)));
}
return tmp;
}
B_m = private
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_m, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (b_m <= 5.5d-61) then
tmp = 0.25d0 * sqrt(((f / a) * (-16.0d0)))
else
tmp = sqrt((f * 2.0d0)) * ((-1.0d0) * (1.0d0 / sqrt(b_m)))
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 5.5e-61) {
tmp = 0.25 * Math.sqrt(((F / A) * -16.0));
} else {
tmp = Math.sqrt((F * 2.0)) * (-1.0 * (1.0 / Math.sqrt(B_m)));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if B_m <= 5.5e-61: tmp = 0.25 * math.sqrt(((F / A) * -16.0)) else: tmp = math.sqrt((F * 2.0)) * (-1.0 * (1.0 / math.sqrt(B_m))) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 5.5e-61) tmp = Float64(0.25 * sqrt(Float64(Float64(F / A) * -16.0))); else tmp = Float64(sqrt(Float64(F * 2.0)) * Float64(-1.0 * Float64(1.0 / sqrt(B_m)))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (B_m <= 5.5e-61)
tmp = 0.25 * sqrt(((F / A) * -16.0));
else
tmp = sqrt((F * 2.0)) * (-1.0 * (1.0 / sqrt(B_m)));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 5.5e-61], N[(0.25 * N[Sqrt[N[(N[(F / A), $MachinePrecision] * -16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision] * N[(-1.0 * N[(1.0 / N[Sqrt[B$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 5.5 \cdot 10^{-61}:\\
\;\;\;\;0.25 \cdot \sqrt{\frac{F}{A} \cdot -16}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot 2} \cdot \left(-1 \cdot \frac{1}{\sqrt{B\_m}}\right)\\
\end{array}
\end{array}
if B < 5.4999999999999997e-61Initial program 20.8%
lift-sqrt.f64N/A
pow1/2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
Applied rewrites29.6%
Applied rewrites25.7%
Taylor expanded in C around inf
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6435.4
Applied rewrites35.4%
if 5.4999999999999997e-61 < B Initial program 17.2%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites26.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites31.7%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
Applied rewrites31.7%
Taylor expanded in B around inf
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6452.7
Applied rewrites52.7%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (if (<= B_m 4.4e-60) (* 0.25 (sqrt (* (/ F A) -16.0))) (* -1.0 (sqrt (* (/ F B_m) 2.0)))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 4.4e-60) {
tmp = 0.25 * sqrt(((F / A) * -16.0));
} else {
tmp = -1.0 * sqrt(((F / B_m) * 2.0));
}
return tmp;
}
B_m = private
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_m, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (b_m <= 4.4d-60) then
tmp = 0.25d0 * sqrt(((f / a) * (-16.0d0)))
else
tmp = (-1.0d0) * sqrt(((f / b_m) * 2.0d0))
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 4.4e-60) {
tmp = 0.25 * Math.sqrt(((F / A) * -16.0));
} else {
tmp = -1.0 * Math.sqrt(((F / B_m) * 2.0));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if B_m <= 4.4e-60: tmp = 0.25 * math.sqrt(((F / A) * -16.0)) else: tmp = -1.0 * math.sqrt(((F / B_m) * 2.0)) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 4.4e-60) tmp = Float64(0.25 * sqrt(Float64(Float64(F / A) * -16.0))); else tmp = Float64(-1.0 * sqrt(Float64(Float64(F / B_m) * 2.0))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (B_m <= 4.4e-60)
tmp = 0.25 * sqrt(((F / A) * -16.0));
else
tmp = -1.0 * sqrt(((F / B_m) * 2.0));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 4.4e-60], N[(0.25 * N[Sqrt[N[(N[(F / A), $MachinePrecision] * -16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[Sqrt[N[(N[(F / B$95$m), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 4.4 \cdot 10^{-60}:\\
\;\;\;\;0.25 \cdot \sqrt{\frac{F}{A} \cdot -16}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \sqrt{\frac{F}{B\_m} \cdot 2}\\
\end{array}
\end{array}
if B < 4.3999999999999998e-60Initial program 20.8%
lift-sqrt.f64N/A
pow1/2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
Applied rewrites29.6%
Applied rewrites25.7%
Taylor expanded in C around inf
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6435.5
Applied rewrites35.5%
if 4.3999999999999998e-60 < B Initial program 17.2%
lift-sqrt.f64N/A
pow1/2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
Applied rewrites20.0%
Applied rewrites18.8%
Taylor expanded in B around inf
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6439.8
Applied rewrites39.8%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (* -1.0 (sqrt (* (/ F B_m) 2.0))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return -1.0 * sqrt(((F / B_m) * 2.0));
}
B_m = private
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b_m, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-1.0d0) * sqrt(((f / b_m) * 2.0d0))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return -1.0 * Math.sqrt(((F / B_m) * 2.0));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return -1.0 * math.sqrt(((F / B_m) * 2.0))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(-1.0 * sqrt(Float64(Float64(F / B_m) * 2.0))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = -1.0 * sqrt(((F / B_m) * 2.0));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(-1.0 * N[Sqrt[N[(N[(F / B$95$m), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
-1 \cdot \sqrt{\frac{F}{B\_m} \cdot 2}
\end{array}
Initial program 18.6%
lift-sqrt.f64N/A
pow1/2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
Applied rewrites23.9%
Applied rewrites21.6%
Taylor expanded in B around inf
lower-*.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6426.9
Applied rewrites26.9%
herbie shell --seed 2025106
(FPCore (A B C F)
:name "ABCF->ab-angle a"
:precision binary64
(/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))