
(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;
}
real(8) function code(a, b, c, f)
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}
Sampling outcomes in binary64 precision:
Herbie found 10 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;
}
real(8) function code(a, b, c, f)
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 (* A (* C -4.0)))
(t_1 (hypot B_m (sqrt t_0)))
(t_2 (fma B_m B_m t_0)))
(if (<= C -1.45e-305)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- A (hypot B_m A)))))
(if (<= C 650.0)
(*
(/ t_1 (/ t_1 (sqrt (* F (* 2.0 (- (+ C A) (hypot B_m (- A C))))))))
(/ -1.0 t_1))
(/
(-
(sqrt
(*
(* F t_2)
(*
2.0
(+
A
(+
A
(/
(* -0.5 (- (+ (pow A 2.0) (pow B_m 2.0)) (pow (- A) 2.0)))
C)))))))
t_2)))))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 = A * (C * -4.0);
double t_1 = hypot(B_m, sqrt(t_0));
double t_2 = fma(B_m, B_m, t_0);
double tmp;
if (C <= -1.45e-305) {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (A - hypot(B_m, A))));
} else if (C <= 650.0) {
tmp = (t_1 / (t_1 / sqrt((F * (2.0 * ((C + A) - hypot(B_m, (A - C)))))))) * (-1.0 / t_1);
} else {
tmp = -sqrt(((F * t_2) * (2.0 * (A + (A + ((-0.5 * ((pow(A, 2.0) + pow(B_m, 2.0)) - pow(-A, 2.0))) / C)))))) / t_2;
}
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 = Float64(A * Float64(C * -4.0)) t_1 = hypot(B_m, sqrt(t_0)) t_2 = fma(B_m, B_m, t_0) tmp = 0.0 if (C <= -1.45e-305) tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(A - hypot(B_m, A))))); elseif (C <= 650.0) tmp = Float64(Float64(t_1 / Float64(t_1 / sqrt(Float64(F * Float64(2.0 * Float64(Float64(C + A) - hypot(B_m, Float64(A - C)))))))) * Float64(-1.0 / t_1)); else tmp = Float64(Float64(-sqrt(Float64(Float64(F * t_2) * Float64(2.0 * Float64(A + Float64(A + Float64(Float64(-0.5 * Float64(Float64((A ^ 2.0) + (B_m ^ 2.0)) - (Float64(-A) ^ 2.0))) / C))))))) / t_2); 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[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[B$95$m ^ 2 + N[Sqrt[t$95$0], $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$2 = N[(B$95$m * B$95$m + t$95$0), $MachinePrecision]}, If[LessEqual[C, -1.45e-305], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[C, 650.0], N[(N[(t$95$1 / N[(t$95$1 / N[Sqrt[N[(F * N[(2.0 * N[(N[(C + A), $MachinePrecision] - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(N[(F * t$95$2), $MachinePrecision] * N[(2.0 * N[(A + N[(A + N[(N[(-0.5 * N[(N[(N[Power[A, 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision] - N[Power[(-A), 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $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 := A \cdot \left(C \cdot -4\right)\\
t_1 := \mathsf{hypot}\left(B_m, \sqrt{t_0}\right)\\
t_2 := \mathsf{fma}\left(B_m, B_m, t_0\right)\\
\mathbf{if}\;C \leq -1.45 \cdot 10^{-305}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\mathbf{elif}\;C \leq 650:\\
\;\;\;\;\frac{t_1}{\frac{t_1}{\sqrt{F \cdot \left(2 \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)}}} \cdot \frac{-1}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot t_2\right) \cdot \left(2 \cdot \left(A + \left(A + \frac{-0.5 \cdot \left(\left({A}^{2} + {B_m}^{2}\right) - {\left(-A\right)}^{2}\right)}{C}\right)\right)\right)}}{t_2}\\
\end{array}
\end{array}
if C < -1.44999999999999994e-305Initial program 14.8%
Simplified17.9%
Taylor expanded in C around 0 8.6%
associate-*r*8.6%
mul-1-neg8.6%
+-commutative8.6%
unpow28.6%
unpow28.6%
hypot-def15.1%
Simplified15.1%
if -1.44999999999999994e-305 < C < 650Initial program 20.4%
Simplified29.0%
neg-mul-129.0%
add-sqr-sqrt28.7%
times-frac28.7%
fma-udef28.7%
add-sqr-sqrt26.8%
hypot-def26.8%
Applied egg-rr43.3%
*-commutative43.3%
associate-/l*47.7%
Simplified47.7%
if 650 < C Initial program 3.0%
Simplified8.5%
Taylor expanded in C around inf 43.1%
associate-*r/43.1%
mul-1-neg43.1%
Simplified43.1%
Final simplification30.3%
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 (* A (* C -4.0)))
(t_1 (hypot B_m (sqrt t_0)))
(t_2 (fma B_m B_m t_0)))
(if (<= C 3.8e-305)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- A (hypot B_m A)))))
(if (<= C 3000.0)
(/
(/
(- t_1)
(/ t_1 (sqrt (* F (* 2.0 (- (+ C A) (hypot B_m (- A C))))))))
t_1)
(/
(-
(sqrt
(*
(* F t_2)
(*
2.0
(+
A
(+
A
(/
(* -0.5 (- (+ (pow A 2.0) (pow B_m 2.0)) (pow (- A) 2.0)))
C)))))))
t_2)))))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 = A * (C * -4.0);
double t_1 = hypot(B_m, sqrt(t_0));
double t_2 = fma(B_m, B_m, t_0);
double tmp;
if (C <= 3.8e-305) {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (A - hypot(B_m, A))));
} else if (C <= 3000.0) {
tmp = (-t_1 / (t_1 / sqrt((F * (2.0 * ((C + A) - hypot(B_m, (A - C)))))))) / t_1;
} else {
tmp = -sqrt(((F * t_2) * (2.0 * (A + (A + ((-0.5 * ((pow(A, 2.0) + pow(B_m, 2.0)) - pow(-A, 2.0))) / C)))))) / t_2;
}
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 = Float64(A * Float64(C * -4.0)) t_1 = hypot(B_m, sqrt(t_0)) t_2 = fma(B_m, B_m, t_0) tmp = 0.0 if (C <= 3.8e-305) tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(A - hypot(B_m, A))))); elseif (C <= 3000.0) tmp = Float64(Float64(Float64(-t_1) / Float64(t_1 / sqrt(Float64(F * Float64(2.0 * Float64(Float64(C + A) - hypot(B_m, Float64(A - C)))))))) / t_1); else tmp = Float64(Float64(-sqrt(Float64(Float64(F * t_2) * Float64(2.0 * Float64(A + Float64(A + Float64(Float64(-0.5 * Float64(Float64((A ^ 2.0) + (B_m ^ 2.0)) - (Float64(-A) ^ 2.0))) / C))))))) / t_2); 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[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[B$95$m ^ 2 + N[Sqrt[t$95$0], $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$2 = N[(B$95$m * B$95$m + t$95$0), $MachinePrecision]}, If[LessEqual[C, 3.8e-305], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[C, 3000.0], N[(N[((-t$95$1) / N[(t$95$1 / N[Sqrt[N[(F * N[(2.0 * N[(N[(C + A), $MachinePrecision] - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[((-N[Sqrt[N[(N[(F * t$95$2), $MachinePrecision] * N[(2.0 * N[(A + N[(A + N[(N[(-0.5 * N[(N[(N[Power[A, 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision] - N[Power[(-A), 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $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 := A \cdot \left(C \cdot -4\right)\\
t_1 := \mathsf{hypot}\left(B_m, \sqrt{t_0}\right)\\
t_2 := \mathsf{fma}\left(B_m, B_m, t_0\right)\\
\mathbf{if}\;C \leq 3.8 \cdot 10^{-305}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\mathbf{elif}\;C \leq 3000:\\
\;\;\;\;\frac{\frac{-t_1}{\frac{t_1}{\sqrt{F \cdot \left(2 \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)}}}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot t_2\right) \cdot \left(2 \cdot \left(A + \left(A + \frac{-0.5 \cdot \left(\left({A}^{2} + {B_m}^{2}\right) - {\left(-A\right)}^{2}\right)}{C}\right)\right)\right)}}{t_2}\\
\end{array}
\end{array}
if C < 3.8e-305Initial program 14.6%
Simplified17.7%
Taylor expanded in C around 0 9.3%
associate-*r*9.3%
mul-1-neg9.3%
+-commutative9.3%
unpow29.3%
unpow29.3%
hypot-def15.6%
Simplified15.6%
if 3.8e-305 < C < 3e3Initial program 20.9%
Simplified29.8%
neg-mul-129.8%
add-sqr-sqrt29.5%
times-frac29.5%
fma-udef29.6%
add-sqr-sqrt27.6%
hypot-def27.6%
Applied egg-rr43.1%
associate-*l/43.1%
mul-1-neg43.1%
associate-/l*47.6%
Simplified47.6%
if 3e3 < C Initial program 3.0%
Simplified8.5%
Taylor expanded in C around inf 43.1%
associate-*r/43.1%
mul-1-neg43.1%
Simplified43.1%
Final simplification30.3%
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 B_m B_m (* A (* C -4.0)))))
(if (<= B_m 25000000000000.0)
(/ (- (sqrt (* (* F t_0) (* 2.0 (+ A A))))) t_0)
(if (<= B_m 1.55e+88)
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (* -0.5 (/ (pow B_m 2.0) C))))))
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- A (hypot B_m A)))))))))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(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (B_m <= 25000000000000.0) {
tmp = -sqrt(((F * t_0) * (2.0 * (A + A)))) / t_0;
} else if (B_m <= 1.55e+88) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (-0.5 * (pow(B_m, 2.0) / C))));
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (A - hypot(B_m, A))));
}
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(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (B_m <= 25000000000000.0) tmp = Float64(Float64(-sqrt(Float64(Float64(F * t_0) * Float64(2.0 * Float64(A + A))))) / t_0); elseif (B_m <= 1.55e+88) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / C)))))); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(A - hypot(B_m, A))))); 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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 25000000000000.0], N[((-N[Sqrt[N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B$95$m, 1.55e+88], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $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 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B_m \leq 25000000000000:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot t_0\right) \cdot \left(2 \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B_m \leq 1.55 \cdot 10^{+88}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\end{array}
\end{array}
if B < 2.5e13Initial program 13.4%
Simplified22.4%
Taylor expanded in C around inf 18.6%
if 2.5e13 < B < 1.5500000000000001e88Initial program 31.8%
Simplified32.2%
Taylor expanded in A around 0 37.1%
associate-*r*37.1%
mul-1-neg37.1%
unpow237.1%
unpow237.1%
hypot-def42.8%
Simplified42.8%
Taylor expanded in C around inf 26.0%
if 1.5500000000000001e88 < B Initial program 3.2%
Simplified0.7%
Taylor expanded in C around 0 10.5%
associate-*r*10.5%
mul-1-neg10.5%
+-commutative10.5%
unpow210.5%
unpow210.5%
hypot-def51.9%
Simplified51.9%
Final simplification23.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 B_m B_m (* A (* C -4.0)))))
(if (<= B_m 54000000000000.0)
(/ (- (sqrt (* t_0 (* F (* A 4.0))))) t_0)
(if (<= B_m 2.4e+89)
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (* -0.5 (/ (pow B_m 2.0) C))))))
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- A (hypot B_m A)))))))))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(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (B_m <= 54000000000000.0) {
tmp = -sqrt((t_0 * (F * (A * 4.0)))) / t_0;
} else if (B_m <= 2.4e+89) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (-0.5 * (pow(B_m, 2.0) / C))));
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (A - hypot(B_m, A))));
}
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(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (B_m <= 54000000000000.0) tmp = Float64(Float64(-sqrt(Float64(t_0 * Float64(F * Float64(A * 4.0))))) / t_0); elseif (B_m <= 2.4e+89) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / C)))))); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(A - hypot(B_m, A))))); 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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 54000000000000.0], N[((-N[Sqrt[N[(t$95$0 * N[(F * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B$95$m, 2.4e+89], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $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 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B_m \leq 54000000000000:\\
\;\;\;\;\frac{-\sqrt{t_0 \cdot \left(F \cdot \left(A \cdot 4\right)\right)}}{t_0}\\
\mathbf{elif}\;B_m \leq 2.4 \cdot 10^{+89}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\end{array}
\end{array}
if B < 5.4e13Initial program 13.4%
Simplified22.4%
Taylor expanded in C around inf 18.6%
expm1-log1p-u17.8%
expm1-udef10.2%
associate-*l*9.9%
count-29.9%
Applied egg-rr9.9%
expm1-def16.6%
expm1-log1p17.4%
associate-*r*17.4%
metadata-eval17.4%
Simplified17.4%
if 5.4e13 < B < 2.40000000000000004e89Initial program 31.8%
Simplified32.2%
Taylor expanded in A around 0 37.1%
associate-*r*37.1%
mul-1-neg37.1%
unpow237.1%
unpow237.1%
hypot-def42.8%
Simplified42.8%
Taylor expanded in C around inf 26.0%
if 2.40000000000000004e89 < B Initial program 3.2%
Simplified0.7%
Taylor expanded in C around 0 10.5%
associate-*r*10.5%
mul-1-neg10.5%
+-commutative10.5%
unpow210.5%
unpow210.5%
hypot-def51.9%
Simplified51.9%
Final simplification22.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
(if (<= B_m 8e-68)
(/
(- (sqrt (* -8.0 (* A (* C (* F (+ A A)))))))
(fma A (* C -4.0) (pow B_m 2.0)))
(if (<= B_m 4.6e+88)
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (* -0.5 (/ (pow B_m 2.0) C))))))
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- A (hypot B_m A))))))))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 <= 8e-68) {
tmp = -sqrt((-8.0 * (A * (C * (F * (A + A)))))) / fma(A, (C * -4.0), pow(B_m, 2.0));
} else if (B_m <= 4.6e+88) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (-0.5 * (pow(B_m, 2.0) / C))));
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (A - hypot(B_m, A))));
}
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 <= 8e-68) tmp = Float64(Float64(-sqrt(Float64(-8.0 * Float64(A * Float64(C * Float64(F * Float64(A + A))))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))); elseif (B_m <= 4.6e+88) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / C)))))); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(A - hypot(B_m, A))))); 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_] := If[LessEqual[B$95$m, 8e-68], N[((-N[Sqrt[N[(-8.0 * N[(A * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 4.6e+88], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $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}
\mathbf{if}\;B_m \leq 8 \cdot 10^{-68}:\\
\;\;\;\;\frac{-\sqrt{-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\
\mathbf{elif}\;B_m \leq 4.6 \cdot 10^{+88}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\end{array}
\end{array}
if B < 8.00000000000000053e-68Initial program 12.5%
Simplified14.3%
Taylor expanded in C around inf 17.2%
if 8.00000000000000053e-68 < B < 4.6000000000000003e88Initial program 31.2%
Simplified38.0%
Taylor expanded in A around 0 34.9%
associate-*r*34.9%
mul-1-neg34.9%
unpow234.9%
unpow234.9%
hypot-def41.7%
Simplified41.7%
Taylor expanded in C around inf 21.0%
if 4.6000000000000003e88 < B Initial program 3.2%
Simplified0.7%
Taylor expanded in C around 0 10.5%
associate-*r*10.5%
mul-1-neg10.5%
+-commutative10.5%
unpow210.5%
unpow210.5%
hypot-def51.9%
Simplified51.9%
Final simplification22.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
(if (<= B_m 2.05e-70)
(/
(- (sqrt (* (* 2.0 (+ A A)) (* (* A -4.0) (* C F)))))
(fma B_m B_m (* A (* C -4.0))))
(if (<= B_m 1.12e+89)
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (* -0.5 (/ (pow B_m 2.0) C))))))
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- A (hypot B_m A))))))))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 <= 2.05e-70) {
tmp = -sqrt(((2.0 * (A + A)) * ((A * -4.0) * (C * F)))) / fma(B_m, B_m, (A * (C * -4.0)));
} else if (B_m <= 1.12e+89) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (-0.5 * (pow(B_m, 2.0) / C))));
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (A - hypot(B_m, A))));
}
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 <= 2.05e-70) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(A + A)) * Float64(Float64(A * -4.0) * Float64(C * F))))) / fma(B_m, B_m, Float64(A * Float64(C * -4.0)))); elseif (B_m <= 1.12e+89) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / C)))))); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(A - hypot(B_m, A))))); 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_] := If[LessEqual[B$95$m, 2.05e-70], N[((-N[Sqrt[N[(N[(2.0 * N[(A + A), $MachinePrecision]), $MachinePrecision] * N[(N[(A * -4.0), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 1.12e+89], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $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}
\mathbf{if}\;B_m \leq 2.05 \cdot 10^{-70}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(A + A\right)\right) \cdot \left(\left(A \cdot -4\right) \cdot \left(C \cdot F\right)\right)}}{\mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;B_m \leq 1.12 \cdot 10^{+89}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\end{array}
\end{array}
if B < 2.04999999999999989e-70Initial program 12.5%
Simplified20.5%
Taylor expanded in C around inf 18.0%
Taylor expanded in B around 0 15.8%
associate-*r*15.8%
*-commutative15.8%
Simplified15.8%
if 2.04999999999999989e-70 < B < 1.11999999999999995e89Initial program 31.2%
Simplified38.0%
Taylor expanded in A around 0 34.9%
associate-*r*34.9%
mul-1-neg34.9%
unpow234.9%
unpow234.9%
hypot-def41.7%
Simplified41.7%
Taylor expanded in C around inf 21.0%
if 1.11999999999999995e89 < B Initial program 3.2%
Simplified0.7%
Taylor expanded in C around 0 10.5%
associate-*r*10.5%
mul-1-neg10.5%
+-commutative10.5%
unpow210.5%
unpow210.5%
hypot-def51.9%
Simplified51.9%
Final simplification21.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
(if (<= B_m 1.85e-90)
(/
(- (sqrt (* (* 2.0 (+ A A)) (* (* A -4.0) (* C F)))))
(fma B_m B_m (* A (* C -4.0))))
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- A (hypot B_m A)))))))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 <= 1.85e-90) {
tmp = -sqrt(((2.0 * (A + A)) * ((A * -4.0) * (C * F)))) / fma(B_m, B_m, (A * (C * -4.0)));
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (A - hypot(B_m, A))));
}
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 <= 1.85e-90) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(A + A)) * Float64(Float64(A * -4.0) * Float64(C * F))))) / fma(B_m, B_m, Float64(A * Float64(C * -4.0)))); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(A - hypot(B_m, A))))); 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_] := If[LessEqual[B$95$m, 1.85e-90], N[((-N[Sqrt[N[(N[(2.0 * N[(A + A), $MachinePrecision]), $MachinePrecision] * N[(N[(A * -4.0), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $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}
\mathbf{if}\;B_m \leq 1.85 \cdot 10^{-90}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(A + A\right)\right) \cdot \left(\left(A \cdot -4\right) \cdot \left(C \cdot F\right)\right)}}{\mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\end{array}
\end{array}
if B < 1.85000000000000009e-90Initial program 12.2%
Simplified19.8%
Taylor expanded in C around inf 17.7%
Taylor expanded in B around 0 15.5%
associate-*r*15.5%
*-commutative15.5%
Simplified15.5%
if 1.85000000000000009e-90 < B Initial program 16.8%
Simplified18.5%
Taylor expanded in C around 0 20.1%
associate-*r*20.1%
mul-1-neg20.1%
+-commutative20.1%
unpow220.1%
unpow220.1%
hypot-def41.3%
Simplified41.3%
Final simplification22.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 25000000000000.0)
(/
(- (sqrt (* (* 2.0 (+ A A)) (* (* A -4.0) (* C F)))))
(fma B_m B_m (* A (* C -4.0))))
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* B_m (- F))))))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 <= 25000000000000.0) {
tmp = -sqrt(((2.0 * (A + A)) * ((A * -4.0) * (C * F)))) / fma(B_m, B_m, (A * (C * -4.0)));
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((B_m * -F));
}
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 <= 25000000000000.0) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(A + A)) * Float64(Float64(A * -4.0) * Float64(C * F))))) / fma(B_m, B_m, Float64(A * Float64(C * -4.0)))); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(B_m * Float64(-F)))); 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_] := If[LessEqual[B$95$m, 25000000000000.0], N[((-N[Sqrt[N[(N[(2.0 * N[(A + A), $MachinePrecision]), $MachinePrecision] * N[(N[(A * -4.0), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(B$95$m * (-F)), $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 25000000000000:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(A + A\right)\right) \cdot \left(\left(A \cdot -4\right) \cdot \left(C \cdot F\right)\right)}}{\mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{B_m \cdot \left(-F\right)}\\
\end{array}
\end{array}
if B < 2.5e13Initial program 13.4%
Simplified22.4%
Taylor expanded in C around inf 18.6%
Taylor expanded in B around 0 15.1%
associate-*r*15.1%
*-commutative15.1%
Simplified15.1%
if 2.5e13 < B Initial program 13.4%
Simplified12.0%
Taylor expanded in A around 0 20.3%
associate-*r*20.3%
mul-1-neg20.3%
unpow220.3%
unpow220.3%
hypot-def42.8%
Simplified42.8%
Taylor expanded in C around 0 37.7%
mul-1-neg37.7%
Simplified37.7%
Final simplification20.1%
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 (<= A -4.5e+75) (* -2.0 (* (sqrt (* F A)) (/ 1.0 B_m))) (* (/ (- (sqrt 2.0)) B_m) (sqrt (* B_m (- F))))))
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 (A <= -4.5e+75) {
tmp = -2.0 * (sqrt((F * A)) * (1.0 / B_m));
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((B_m * -F));
}
return tmp;
}
B_m = abs(B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
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 (a <= (-4.5d+75)) then
tmp = (-2.0d0) * (sqrt((f * a)) * (1.0d0 / b_m))
else
tmp = (-sqrt(2.0d0) / b_m) * sqrt((b_m * -f))
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 (A <= -4.5e+75) {
tmp = -2.0 * (Math.sqrt((F * A)) * (1.0 / B_m));
} else {
tmp = (-Math.sqrt(2.0) / B_m) * Math.sqrt((B_m * -F));
}
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 A <= -4.5e+75: tmp = -2.0 * (math.sqrt((F * A)) * (1.0 / B_m)) else: tmp = (-math.sqrt(2.0) / B_m) * math.sqrt((B_m * -F)) 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 (A <= -4.5e+75) tmp = Float64(-2.0 * Float64(sqrt(Float64(F * A)) * Float64(1.0 / B_m))); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(B_m * Float64(-F)))); 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 (A <= -4.5e+75)
tmp = -2.0 * (sqrt((F * A)) * (1.0 / B_m));
else
tmp = (-sqrt(2.0) / B_m) * sqrt((B_m * -F));
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[A, -4.5e+75], N[(-2.0 * N[(N[Sqrt[N[(F * A), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(B$95$m * (-F)), $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}\;A \leq -4.5 \cdot 10^{+75}:\\
\;\;\;\;-2 \cdot \left(\sqrt{F \cdot A} \cdot \frac{1}{B_m}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{B_m \cdot \left(-F\right)}\\
\end{array}
\end{array}
if A < -4.5000000000000004e75Initial program 13.1%
Simplified30.9%
Taylor expanded in C around inf 32.7%
Taylor expanded in B around inf 9.1%
if -4.5000000000000004e75 < A Initial program 13.5%
Simplified15.2%
Taylor expanded in A around 0 9.9%
associate-*r*9.9%
mul-1-neg9.9%
unpow29.9%
unpow29.9%
hypot-def16.3%
Simplified16.3%
Taylor expanded in C around 0 12.8%
mul-1-neg12.8%
Simplified12.8%
Final simplification12.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 (* -2.0 (* (sqrt (* F A)) (/ 1.0 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) {
return -2.0 * (sqrt((F * A)) * (1.0 / B_m));
}
B_m = abs(B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-2.0d0) * (sqrt((f * a)) * (1.0d0 / b_m))
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 -2.0 * (Math.sqrt((F * A)) * (1.0 / B_m));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return -2.0 * (math.sqrt((F * A)) * (1.0 / B_m))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(-2.0 * Float64(sqrt(Float64(F * A)) * Float64(1.0 / B_m))) 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 = -2.0 * (sqrt((F * A)) * (1.0 / B_m));
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[(-2.0 * N[(N[Sqrt[N[(F * A), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
-2 \cdot \left(\sqrt{F \cdot A} \cdot \frac{1}{B_m}\right)
\end{array}
Initial program 13.4%
Simplified21.3%
Taylor expanded in C around inf 15.2%
Taylor expanded in B around inf 3.3%
Final simplification3.3%
herbie shell --seed 2023332
(FPCore (A B C F)
:name "ABCF->ab-angle b"
: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))))