
(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 25 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 (* (* 4.0 A) C))
(t_1 (+ A (+ C (hypot B_m (- A C)))))
(t_2 (fma B_m B_m (* A (* C -4.0))))
(t_3 (- t_2))
(t_4 (* F t_2))
(t_5 (sqrt (* 2.0 t_4)))
(t_6 (+ (* -0.5 (/ (pow B_m 2.0) A)) (* 2.0 C)))
(t_7
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) t_6))
(- t_0 (pow B_m 2.0))))
(t_8 (/ (sqrt (* t_4 (* 2.0 t_1))) t_3)))
(if (<= (pow B_m 2.0) 2e-262)
t_7
(if (<= (pow B_m 2.0) 5e-193)
(* (sqrt (* F (/ t_1 (fma -4.0 (* A C) (pow B_m 2.0))))) (- (sqrt 2.0)))
(if (<= (pow B_m 2.0) 1e-155)
(* (/ (sqrt (+ (+ A C) (hypot (- A C) B_m))) t_2) (- t_5))
(if (<= (pow B_m 2.0) 4e-31)
(* t_5 (/ (sqrt t_6) t_3))
(if (<= (pow B_m 2.0) 2e+39)
t_8
(if (<= (pow B_m 2.0) 5e+80)
(/
(*
(sqrt (* 2.0 C))
(sqrt (* 2.0 (* F (fma B_m B_m (* -4.0 (* A C)))))))
t_3)
(if (<= (pow B_m 2.0) 1e+106)
t_8
(if (<= (pow B_m 2.0) 2e+151)
t_7
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(- (pow (/ B_m (sqrt 2.0)) -1.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 = (4.0 * A) * C;
double t_1 = A + (C + hypot(B_m, (A - C)));
double t_2 = fma(B_m, B_m, (A * (C * -4.0)));
double t_3 = -t_2;
double t_4 = F * t_2;
double t_5 = sqrt((2.0 * t_4));
double t_6 = (-0.5 * (pow(B_m, 2.0) / A)) + (2.0 * C);
double t_7 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * t_6)) / (t_0 - pow(B_m, 2.0));
double t_8 = sqrt((t_4 * (2.0 * t_1))) / t_3;
double tmp;
if (pow(B_m, 2.0) <= 2e-262) {
tmp = t_7;
} else if (pow(B_m, 2.0) <= 5e-193) {
tmp = sqrt((F * (t_1 / fma(-4.0, (A * C), pow(B_m, 2.0))))) * -sqrt(2.0);
} else if (pow(B_m, 2.0) <= 1e-155) {
tmp = (sqrt(((A + C) + hypot((A - C), B_m))) / t_2) * -t_5;
} else if (pow(B_m, 2.0) <= 4e-31) {
tmp = t_5 * (sqrt(t_6) / t_3);
} else if (pow(B_m, 2.0) <= 2e+39) {
tmp = t_8;
} else if (pow(B_m, 2.0) <= 5e+80) {
tmp = (sqrt((2.0 * C)) * sqrt((2.0 * (F * fma(B_m, B_m, (-4.0 * (A * C))))))) / t_3;
} else if (pow(B_m, 2.0) <= 1e+106) {
tmp = t_8;
} else if (pow(B_m, 2.0) <= 2e+151) {
tmp = t_7;
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * -pow((B_m / sqrt(2.0)), -1.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 = Float64(Float64(4.0 * A) * C) t_1 = Float64(A + Float64(C + hypot(B_m, Float64(A - C)))) t_2 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_3 = Float64(-t_2) t_4 = Float64(F * t_2) t_5 = sqrt(Float64(2.0 * t_4)) t_6 = Float64(Float64(-0.5 * Float64((B_m ^ 2.0) / A)) + Float64(2.0 * C)) t_7 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * t_6)) / Float64(t_0 - (B_m ^ 2.0))) t_8 = Float64(sqrt(Float64(t_4 * Float64(2.0 * t_1))) / t_3) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-262) tmp = t_7; elseif ((B_m ^ 2.0) <= 5e-193) tmp = Float64(sqrt(Float64(F * Float64(t_1 / fma(-4.0, Float64(A * C), (B_m ^ 2.0))))) * Float64(-sqrt(2.0))); elseif ((B_m ^ 2.0) <= 1e-155) tmp = Float64(Float64(sqrt(Float64(Float64(A + C) + hypot(Float64(A - C), B_m))) / t_2) * Float64(-t_5)); elseif ((B_m ^ 2.0) <= 4e-31) tmp = Float64(t_5 * Float64(sqrt(t_6) / t_3)); elseif ((B_m ^ 2.0) <= 2e+39) tmp = t_8; elseif ((B_m ^ 2.0) <= 5e+80) tmp = Float64(Float64(sqrt(Float64(2.0 * C)) * sqrt(Float64(2.0 * Float64(F * fma(B_m, B_m, Float64(-4.0 * Float64(A * C))))))) / t_3); elseif ((B_m ^ 2.0) <= 1e+106) tmp = t_8; elseif ((B_m ^ 2.0) <= 2e+151) tmp = t_7; else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(-(Float64(B_m / sqrt(2.0)) ^ -1.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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(A + N[(C + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = (-t$95$2)}, Block[{t$95$4 = N[(F * t$95$2), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(2.0 * t$95$4), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[(N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$7 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * t$95$6), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$8 = N[(N[Sqrt[N[(t$95$4 * N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-262], t$95$7, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-193], N[(N[Sqrt[N[(F * N[(t$95$1 / N[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-155], N[(N[(N[Sqrt[N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision] * (-t$95$5)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e-31], N[(t$95$5 * N[(N[Sqrt[t$95$6], $MachinePrecision] / t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+39], t$95$8, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+80], N[(N[(N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 * N[(F * N[(B$95$m * B$95$m + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+106], t$95$8, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+151], t$95$7, N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * (-N[Power[N[(B$95$m / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], -1.0], $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 := \left(4 \cdot A\right) \cdot C\\
t_1 := A + \left(C + \mathsf{hypot}\left(B\_m, A - C\right)\right)\\
t_2 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_3 := -t\_2\\
t_4 := F \cdot t\_2\\
t_5 := \sqrt{2 \cdot t\_4}\\
t_6 := -0.5 \cdot \frac{{B\_m}^{2}}{A} + 2 \cdot C\\
t_7 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot t\_6}}{t\_0 - {B\_m}^{2}}\\
t_8 := \frac{\sqrt{t\_4 \cdot \left(2 \cdot t\_1\right)}}{t\_3}\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;t\_7\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-193}:\\
\;\;\;\;\sqrt{F \cdot \frac{t\_1}{\mathsf{fma}\left(-4, A \cdot C, {B\_m}^{2}\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-155}:\\
\;\;\;\;\frac{\sqrt{\left(A + C\right) + \mathsf{hypot}\left(A - C, B\_m\right)}}{t\_2} \cdot \left(-t\_5\right)\\
\mathbf{elif}\;{B\_m}^{2} \leq 4 \cdot 10^{-31}:\\
\;\;\;\;t\_5 \cdot \frac{\sqrt{t\_6}}{t\_3}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+39}:\\
\;\;\;\;t\_8\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+80}:\\
\;\;\;\;\frac{\sqrt{2 \cdot C} \cdot \sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B\_m, B\_m, -4 \cdot \left(A \cdot C\right)\right)\right)}}{t\_3}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+106}:\\
\;\;\;\;t\_8\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+151}:\\
\;\;\;\;t\_7\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \left(-{\left(\frac{B\_m}{\sqrt{2}}\right)}^{-1}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e-262 or 1.00000000000000009e106 < (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000003e151Initial program 21.1%
Taylor expanded in A around -inf 25.8%
if 2.00000000000000002e-262 < (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000005e-193Initial program 17.5%
Taylor expanded in F around 0 23.2%
mul-1-neg23.2%
*-commutative23.2%
distribute-rgt-neg-in23.2%
associate-/l*40.0%
cancel-sign-sub-inv40.0%
metadata-eval40.0%
+-commutative40.0%
Simplified42.3%
if 5.0000000000000005e-193 < (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000001e-155Initial program 23.1%
Simplified42.0%
associate-*r*42.0%
associate-+r+42.0%
hypot-undefine23.1%
unpow223.1%
unpow223.1%
+-commutative23.1%
sqrt-prod22.6%
*-commutative22.6%
associate-*r*22.6%
associate-+l+22.6%
Applied egg-rr69.7%
associate-/l*69.9%
associate-*l*69.9%
associate-*r*69.9%
associate-+r+69.9%
Applied egg-rr69.9%
associate-*r*69.9%
distribute-frac-neg269.9%
Simplified69.9%
if 1.00000000000000001e-155 < (pow.f64 B #s(literal 2 binary64)) < 4e-31Initial program 41.9%
Simplified43.2%
associate-*r*43.2%
associate-+r+42.1%
hypot-undefine41.9%
unpow241.9%
unpow241.9%
+-commutative41.9%
sqrt-prod41.8%
*-commutative41.8%
associate-*r*41.8%
associate-+l+42.8%
Applied egg-rr57.0%
associate-/l*56.9%
associate-*l*56.9%
associate-*r*56.9%
associate-+r+55.9%
Applied egg-rr55.9%
associate-*r*55.9%
distribute-frac-neg255.9%
Simplified55.9%
Taylor expanded in A around -inf 46.1%
if 4e-31 < (pow.f64 B #s(literal 2 binary64)) < 1.99999999999999988e39 or 4.99999999999999961e80 < (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000009e106Initial program 56.1%
Simplified61.4%
if 1.99999999999999988e39 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999961e80Initial program 14.8%
Simplified18.9%
associate-*r*18.9%
associate-+r+15.3%
hypot-undefine14.8%
unpow214.8%
unpow214.8%
+-commutative14.8%
sqrt-prod14.8%
*-commutative14.8%
associate-*r*14.8%
associate-+l+14.8%
Applied egg-rr33.1%
Taylor expanded in A around -inf 2.1%
if 2.00000000000000003e151 < (pow.f64 B #s(literal 2 binary64)) Initial program 10.3%
Taylor expanded in A around 0 14.6%
mul-1-neg14.6%
*-commutative14.6%
distribute-rgt-neg-in14.6%
unpow214.6%
unpow214.6%
hypot-define25.7%
Simplified25.7%
*-commutative25.7%
sqrt-prod39.6%
Applied egg-rr39.6%
clear-num39.7%
inv-pow39.7%
Applied egg-rr39.7%
Final simplification37.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 B_m B_m (* A (* C -4.0))))
(t_1 (* (* 4.0 A) C))
(t_2 (* 2.0 (* (- (pow B_m 2.0) t_1) F)))
(t_3 (- t_1 (pow B_m 2.0)))
(t_4
(/
(sqrt (* t_2 (+ (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0))))))
t_3)))
(if (<= t_4 -2e-159)
(*
(* (sqrt F) (sqrt (* 2.0 t_0)))
(/ (sqrt (+ (+ A C) (hypot (- A C) B_m))) (- t_0)))
(if (<= t_4 0.0)
(/ (sqrt (* t_2 (+ (* -0.5 (/ (pow B_m 2.0) A)) (* 2.0 C)))) t_3)
(if (<= t_4 INFINITY)
(* (sqrt (* 2.0 (* F t_0))) (/ (- (sqrt (* 2.0 C))) t_0))
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(/ (sqrt 2.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) {
double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = (4.0 * A) * C;
double t_2 = 2.0 * ((pow(B_m, 2.0) - t_1) * F);
double t_3 = t_1 - pow(B_m, 2.0);
double t_4 = sqrt((t_2 * ((A + C) + sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / t_3;
double tmp;
if (t_4 <= -2e-159) {
tmp = (sqrt(F) * sqrt((2.0 * t_0))) * (sqrt(((A + C) + hypot((A - C), B_m))) / -t_0);
} else if (t_4 <= 0.0) {
tmp = sqrt((t_2 * ((-0.5 * (pow(B_m, 2.0) / A)) + (2.0 * C)))) / t_3;
} else if (t_4 <= ((double) INFINITY)) {
tmp = sqrt((2.0 * (F * t_0))) * (-sqrt((2.0 * C)) / t_0);
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * (sqrt(2.0) / -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(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = Float64(Float64(4.0 * A) * C) t_2 = Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_1) * F)) t_3 = Float64(t_1 - (B_m ^ 2.0)) t_4 = Float64(sqrt(Float64(t_2 * Float64(Float64(A + C) + sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0)))))) / t_3) tmp = 0.0 if (t_4 <= -2e-159) tmp = Float64(Float64(sqrt(F) * sqrt(Float64(2.0 * t_0))) * Float64(sqrt(Float64(Float64(A + C) + hypot(Float64(A - C), B_m))) / Float64(-t_0))); elseif (t_4 <= 0.0) tmp = Float64(sqrt(Float64(t_2 * Float64(Float64(-0.5 * Float64((B_m ^ 2.0) / A)) + Float64(2.0 * C)))) / t_3); elseif (t_4 <= Inf) tmp = Float64(sqrt(Float64(2.0 * Float64(F * t_0))) * Float64(Float64(-sqrt(Float64(2.0 * C))) / t_0)); else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(sqrt(2.0) / Float64(-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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$1), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(t$95$2 * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision]}, If[LessEqual[t$95$4, -2e-159], N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.0], N[(N[Sqrt[N[(t$95$2 * N[(N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(N[Sqrt[N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $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)\\
t_1 := \left(4 \cdot A\right) \cdot C\\
t_2 := 2 \cdot \left(\left({B\_m}^{2} - t\_1\right) \cdot F\right)\\
t_3 := t\_1 - {B\_m}^{2}\\
t_4 := \frac{\sqrt{t\_2 \cdot \left(\left(A + C\right) + \sqrt{{B\_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_3}\\
\mathbf{if}\;t\_4 \leq -2 \cdot 10^{-159}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{2 \cdot t\_0}\right) \cdot \frac{\sqrt{\left(A + C\right) + \mathsf{hypot}\left(A - C, B\_m\right)}}{-t\_0}\\
\mathbf{elif}\;t\_4 \leq 0:\\
\;\;\;\;\frac{\sqrt{t\_2 \cdot \left(-0.5 \cdot \frac{{B\_m}^{2}}{A} + 2 \cdot C\right)}}{t\_3}\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;\sqrt{2 \cdot \left(F \cdot t\_0\right)} \cdot \frac{-\sqrt{2 \cdot C}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \frac{\sqrt{2}}{-B\_m}\\
\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))) < -1.99999999999999998e-159Initial program 39.4%
Simplified47.4%
associate-*r*47.4%
associate-+r+46.7%
hypot-undefine39.4%
unpow239.4%
unpow239.4%
+-commutative39.4%
sqrt-prod44.7%
*-commutative44.7%
associate-*r*44.7%
associate-+l+44.7%
Applied egg-rr60.1%
associate-/l*60.1%
associate-*l*60.1%
associate-*r*60.1%
associate-+r+59.1%
Applied egg-rr59.1%
associate-*r*59.1%
distribute-frac-neg259.1%
Simplified59.1%
pow1/259.1%
associate-*l*59.1%
unpow-prod-down76.9%
pow1/276.9%
Applied egg-rr76.9%
unpow1/276.9%
Simplified76.9%
if -1.99999999999999998e-159 < (/.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 11.4%
Taylor expanded in A around -inf 22.6%
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 55.5%
Simplified66.2%
associate-*r*66.2%
associate-+r+66.2%
hypot-undefine55.5%
unpow255.5%
unpow255.5%
+-commutative55.5%
sqrt-prod55.4%
*-commutative55.4%
associate-*r*55.4%
associate-+l+55.4%
Applied egg-rr81.8%
associate-/l*81.9%
associate-*l*81.9%
associate-*r*81.9%
associate-+r+81.9%
Applied egg-rr81.9%
associate-*r*81.9%
distribute-frac-neg281.9%
Simplified81.9%
Taylor expanded in A around -inf 51.0%
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%
Taylor expanded in A around 0 2.0%
mul-1-neg2.0%
*-commutative2.0%
distribute-rgt-neg-in2.0%
unpow22.0%
unpow22.0%
hypot-define12.3%
Simplified12.3%
*-commutative12.3%
sqrt-prod21.6%
Applied egg-rr21.6%
Final simplification43.6%
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 (hypot (- A C) B_m))
(t_1 (fma B_m B_m (* A (* C -4.0))))
(t_2 (* (* 4.0 A) C))
(t_3 (- t_2 (pow B_m 2.0)))
(t_4 (* 2.0 (* (- (pow B_m 2.0) t_2) F)))
(t_5 (/ (sqrt (* t_4 (* 2.0 C))) t_3))
(t_6 (/ (sqrt (+ (+ A C) t_0)) t_1)))
(if (<= (pow B_m 2.0) 2e-262)
(/ (sqrt (* t_4 (+ (* -0.5 (/ (pow B_m 2.0) A)) (* 2.0 C)))) t_3)
(if (<= (pow B_m 2.0) 5e-193)
(*
(sqrt
(*
F
(/
(+ A (+ C (hypot B_m (- A C))))
(fma -4.0 (* A C) (pow B_m 2.0)))))
(- (sqrt 2.0)))
(if (<= (pow B_m 2.0) 1e-155)
(* t_6 (- (sqrt (* 2.0 (* F t_1)))))
(if (<= (pow B_m 2.0) 5e-79)
t_5
(if (<= (pow B_m 2.0) 2e+56)
(/
(*
(sqrt (* 2.0 (* F (fma B_m B_m (* -4.0 (* A C))))))
(sqrt (+ A (+ C t_0))))
(- t_1))
(if (<= (pow B_m 2.0) 5e+80)
t_5
(if (<= (pow B_m 2.0) 4e+163)
(* t_6 (* (* B_m (sqrt 2.0)) (- (sqrt F))))
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(- (pow (/ B_m (sqrt 2.0)) -1.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 = hypot((A - C), B_m);
double t_1 = fma(B_m, B_m, (A * (C * -4.0)));
double t_2 = (4.0 * A) * C;
double t_3 = t_2 - pow(B_m, 2.0);
double t_4 = 2.0 * ((pow(B_m, 2.0) - t_2) * F);
double t_5 = sqrt((t_4 * (2.0 * C))) / t_3;
double t_6 = sqrt(((A + C) + t_0)) / t_1;
double tmp;
if (pow(B_m, 2.0) <= 2e-262) {
tmp = sqrt((t_4 * ((-0.5 * (pow(B_m, 2.0) / A)) + (2.0 * C)))) / t_3;
} else if (pow(B_m, 2.0) <= 5e-193) {
tmp = sqrt((F * ((A + (C + hypot(B_m, (A - C)))) / fma(-4.0, (A * C), pow(B_m, 2.0))))) * -sqrt(2.0);
} else if (pow(B_m, 2.0) <= 1e-155) {
tmp = t_6 * -sqrt((2.0 * (F * t_1)));
} else if (pow(B_m, 2.0) <= 5e-79) {
tmp = t_5;
} else if (pow(B_m, 2.0) <= 2e+56) {
tmp = (sqrt((2.0 * (F * fma(B_m, B_m, (-4.0 * (A * C)))))) * sqrt((A + (C + t_0)))) / -t_1;
} else if (pow(B_m, 2.0) <= 5e+80) {
tmp = t_5;
} else if (pow(B_m, 2.0) <= 4e+163) {
tmp = t_6 * ((B_m * sqrt(2.0)) * -sqrt(F));
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * -pow((B_m / sqrt(2.0)), -1.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 = hypot(Float64(A - C), B_m) t_1 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_2 = Float64(Float64(4.0 * A) * C) t_3 = Float64(t_2 - (B_m ^ 2.0)) t_4 = Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_2) * F)) t_5 = Float64(sqrt(Float64(t_4 * Float64(2.0 * C))) / t_3) t_6 = Float64(sqrt(Float64(Float64(A + C) + t_0)) / t_1) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-262) tmp = Float64(sqrt(Float64(t_4 * Float64(Float64(-0.5 * Float64((B_m ^ 2.0) / A)) + Float64(2.0 * C)))) / t_3); elseif ((B_m ^ 2.0) <= 5e-193) tmp = Float64(sqrt(Float64(F * Float64(Float64(A + Float64(C + hypot(B_m, Float64(A - C)))) / fma(-4.0, Float64(A * C), (B_m ^ 2.0))))) * Float64(-sqrt(2.0))); elseif ((B_m ^ 2.0) <= 1e-155) tmp = Float64(t_6 * Float64(-sqrt(Float64(2.0 * Float64(F * t_1))))); elseif ((B_m ^ 2.0) <= 5e-79) tmp = t_5; elseif ((B_m ^ 2.0) <= 2e+56) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(F * fma(B_m, B_m, Float64(-4.0 * Float64(A * C)))))) * sqrt(Float64(A + Float64(C + t_0)))) / Float64(-t_1)); elseif ((B_m ^ 2.0) <= 5e+80) tmp = t_5; elseif ((B_m ^ 2.0) <= 4e+163) tmp = Float64(t_6 * Float64(Float64(B_m * sqrt(2.0)) * Float64(-sqrt(F)))); else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(-(Float64(B_m / sqrt(2.0)) ^ -1.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[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]}, Block[{t$95$1 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$2), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Sqrt[N[(t$95$4 * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision]}, Block[{t$95$6 = N[(N[Sqrt[N[(N[(A + C), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-262], N[(N[Sqrt[N[(t$95$4 * N[(N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-193], N[(N[Sqrt[N[(F * N[(N[(A + N[(C + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-155], N[(t$95$6 * (-N[Sqrt[N[(2.0 * N[(F * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-79], t$95$5, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+56], N[(N[(N[Sqrt[N[(2.0 * N[(F * N[(B$95$m * B$95$m + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(A + N[(C + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+80], t$95$5, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e+163], N[(t$95$6 * N[(N[(B$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * (-N[Power[N[(B$95$m / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], -1.0], $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{hypot}\left(A - C, B\_m\right)\\
t_1 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := \left(4 \cdot A\right) \cdot C\\
t_3 := t\_2 - {B\_m}^{2}\\
t_4 := 2 \cdot \left(\left({B\_m}^{2} - t\_2\right) \cdot F\right)\\
t_5 := \frac{\sqrt{t\_4 \cdot \left(2 \cdot C\right)}}{t\_3}\\
t_6 := \frac{\sqrt{\left(A + C\right) + t\_0}}{t\_1}\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;\frac{\sqrt{t\_4 \cdot \left(-0.5 \cdot \frac{{B\_m}^{2}}{A} + 2 \cdot C\right)}}{t\_3}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-193}:\\
\;\;\;\;\sqrt{F \cdot \frac{A + \left(C + \mathsf{hypot}\left(B\_m, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B\_m}^{2}\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-155}:\\
\;\;\;\;t\_6 \cdot \left(-\sqrt{2 \cdot \left(F \cdot t\_1\right)}\right)\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-79}:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+56}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B\_m, B\_m, -4 \cdot \left(A \cdot C\right)\right)\right)} \cdot \sqrt{A + \left(C + t\_0\right)}}{-t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+80}:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;{B\_m}^{2} \leq 4 \cdot 10^{+163}:\\
\;\;\;\;t\_6 \cdot \left(\left(B\_m \cdot \sqrt{2}\right) \cdot \left(-\sqrt{F}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \left(-{\left(\frac{B\_m}{\sqrt{2}}\right)}^{-1}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e-262Initial program 21.0%
Taylor expanded in A around -inf 27.4%
if 2.00000000000000002e-262 < (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000005e-193Initial program 17.5%
Taylor expanded in F around 0 23.2%
mul-1-neg23.2%
*-commutative23.2%
distribute-rgt-neg-in23.2%
associate-/l*40.0%
cancel-sign-sub-inv40.0%
metadata-eval40.0%
+-commutative40.0%
Simplified42.3%
if 5.0000000000000005e-193 < (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000001e-155Initial program 23.1%
Simplified42.0%
associate-*r*42.0%
associate-+r+42.0%
hypot-undefine23.1%
unpow223.1%
unpow223.1%
+-commutative23.1%
sqrt-prod22.6%
*-commutative22.6%
associate-*r*22.6%
associate-+l+22.6%
Applied egg-rr69.7%
associate-/l*69.9%
associate-*l*69.9%
associate-*r*69.9%
associate-+r+69.9%
Applied egg-rr69.9%
associate-*r*69.9%
distribute-frac-neg269.9%
Simplified69.9%
if 1.00000000000000001e-155 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999999e-79 or 2.00000000000000018e56 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999961e80Initial program 31.9%
Taylor expanded in A around -inf 37.5%
if 4.99999999999999999e-79 < (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000018e56Initial program 47.1%
Simplified48.7%
associate-*r*48.7%
associate-+r+47.3%
hypot-undefine47.1%
unpow247.1%
unpow247.1%
+-commutative47.1%
sqrt-prod46.9%
*-commutative46.9%
associate-*r*46.9%
associate-+l+47.1%
Applied egg-rr55.5%
if 4.99999999999999961e80 < (pow.f64 B #s(literal 2 binary64)) < 3.9999999999999998e163Initial program 38.3%
Simplified44.0%
associate-*r*44.0%
associate-+r+43.8%
hypot-undefine38.3%
unpow238.3%
unpow238.3%
+-commutative38.3%
sqrt-prod38.2%
*-commutative38.2%
associate-*r*38.2%
associate-+l+38.3%
Applied egg-rr48.3%
associate-/l*48.2%
associate-*l*48.2%
associate-*r*48.2%
associate-+r+48.2%
Applied egg-rr48.2%
associate-*r*48.2%
distribute-frac-neg248.2%
Simplified48.2%
Taylor expanded in B around inf 13.1%
if 3.9999999999999998e163 < (pow.f64 B #s(literal 2 binary64)) Initial program 10.4%
Taylor expanded in A around 0 14.9%
mul-1-neg14.9%
*-commutative14.9%
distribute-rgt-neg-in14.9%
unpow214.9%
unpow214.9%
hypot-define26.3%
Simplified26.3%
*-commutative26.3%
sqrt-prod40.5%
Applied egg-rr40.5%
clear-num40.6%
inv-pow40.6%
Applied egg-rr40.6%
Final simplification36.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))))
(t_1 (* (* 4.0 A) C))
(t_2 (- t_1 (pow B_m 2.0)))
(t_3 (* 2.0 (* (- (pow B_m 2.0) t_1) F)))
(t_4 (/ (sqrt (+ (+ A C) (hypot (- A C) B_m))) t_0))
(t_5 (* t_4 (- (sqrt (* 2.0 (* F t_0))))))
(t_6 (/ (sqrt (* t_3 (* 2.0 C))) t_2)))
(if (<= (pow B_m 2.0) 2e-262)
(/ (sqrt (* t_3 (+ (* -0.5 (/ (pow B_m 2.0) A)) (* 2.0 C)))) t_2)
(if (<= (pow B_m 2.0) 5e-193)
(*
(sqrt
(*
F
(/
(+ A (+ C (hypot B_m (- A C))))
(fma -4.0 (* A C) (pow B_m 2.0)))))
(- (sqrt 2.0)))
(if (<= (pow B_m 2.0) 1e-155)
t_5
(if (<= (pow B_m 2.0) 5e-79)
t_6
(if (<= (pow B_m 2.0) 2e+56)
t_5
(if (<= (pow B_m 2.0) 5e+80)
t_6
(if (<= (pow B_m 2.0) 4e+163)
(* t_4 (* (* B_m (sqrt 2.0)) (- (sqrt F))))
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(- (pow (/ B_m (sqrt 2.0)) -1.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 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = (4.0 * A) * C;
double t_2 = t_1 - pow(B_m, 2.0);
double t_3 = 2.0 * ((pow(B_m, 2.0) - t_1) * F);
double t_4 = sqrt(((A + C) + hypot((A - C), B_m))) / t_0;
double t_5 = t_4 * -sqrt((2.0 * (F * t_0)));
double t_6 = sqrt((t_3 * (2.0 * C))) / t_2;
double tmp;
if (pow(B_m, 2.0) <= 2e-262) {
tmp = sqrt((t_3 * ((-0.5 * (pow(B_m, 2.0) / A)) + (2.0 * C)))) / t_2;
} else if (pow(B_m, 2.0) <= 5e-193) {
tmp = sqrt((F * ((A + (C + hypot(B_m, (A - C)))) / fma(-4.0, (A * C), pow(B_m, 2.0))))) * -sqrt(2.0);
} else if (pow(B_m, 2.0) <= 1e-155) {
tmp = t_5;
} else if (pow(B_m, 2.0) <= 5e-79) {
tmp = t_6;
} else if (pow(B_m, 2.0) <= 2e+56) {
tmp = t_5;
} else if (pow(B_m, 2.0) <= 5e+80) {
tmp = t_6;
} else if (pow(B_m, 2.0) <= 4e+163) {
tmp = t_4 * ((B_m * sqrt(2.0)) * -sqrt(F));
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * -pow((B_m / sqrt(2.0)), -1.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 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = Float64(Float64(4.0 * A) * C) t_2 = Float64(t_1 - (B_m ^ 2.0)) t_3 = Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_1) * F)) t_4 = Float64(sqrt(Float64(Float64(A + C) + hypot(Float64(A - C), B_m))) / t_0) t_5 = Float64(t_4 * Float64(-sqrt(Float64(2.0 * Float64(F * t_0))))) t_6 = Float64(sqrt(Float64(t_3 * Float64(2.0 * C))) / t_2) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-262) tmp = Float64(sqrt(Float64(t_3 * Float64(Float64(-0.5 * Float64((B_m ^ 2.0) / A)) + Float64(2.0 * C)))) / t_2); elseif ((B_m ^ 2.0) <= 5e-193) tmp = Float64(sqrt(Float64(F * Float64(Float64(A + Float64(C + hypot(B_m, Float64(A - C)))) / fma(-4.0, Float64(A * C), (B_m ^ 2.0))))) * Float64(-sqrt(2.0))); elseif ((B_m ^ 2.0) <= 1e-155) tmp = t_5; elseif ((B_m ^ 2.0) <= 5e-79) tmp = t_6; elseif ((B_m ^ 2.0) <= 2e+56) tmp = t_5; elseif ((B_m ^ 2.0) <= 5e+80) tmp = t_6; elseif ((B_m ^ 2.0) <= 4e+163) tmp = Float64(t_4 * Float64(Float64(B_m * sqrt(2.0)) * Float64(-sqrt(F)))); else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(-(Float64(B_m / sqrt(2.0)) ^ -1.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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$1), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 * (-N[Sqrt[N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]}, Block[{t$95$6 = N[(N[Sqrt[N[(t$95$3 * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-262], N[(N[Sqrt[N[(t$95$3 * N[(N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-193], N[(N[Sqrt[N[(F * N[(N[(A + N[(C + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-155], t$95$5, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-79], t$95$6, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+56], t$95$5, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+80], t$95$6, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e+163], N[(t$95$4 * N[(N[(B$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * (-N[Power[N[(B$95$m / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], -1.0], $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)\\
t_1 := \left(4 \cdot A\right) \cdot C\\
t_2 := t\_1 - {B\_m}^{2}\\
t_3 := 2 \cdot \left(\left({B\_m}^{2} - t\_1\right) \cdot F\right)\\
t_4 := \frac{\sqrt{\left(A + C\right) + \mathsf{hypot}\left(A - C, B\_m\right)}}{t\_0}\\
t_5 := t\_4 \cdot \left(-\sqrt{2 \cdot \left(F \cdot t\_0\right)}\right)\\
t_6 := \frac{\sqrt{t\_3 \cdot \left(2 \cdot C\right)}}{t\_2}\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;\frac{\sqrt{t\_3 \cdot \left(-0.5 \cdot \frac{{B\_m}^{2}}{A} + 2 \cdot C\right)}}{t\_2}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-193}:\\
\;\;\;\;\sqrt{F \cdot \frac{A + \left(C + \mathsf{hypot}\left(B\_m, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B\_m}^{2}\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-155}:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-79}:\\
\;\;\;\;t\_6\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+56}:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+80}:\\
\;\;\;\;t\_6\\
\mathbf{elif}\;{B\_m}^{2} \leq 4 \cdot 10^{+163}:\\
\;\;\;\;t\_4 \cdot \left(\left(B\_m \cdot \sqrt{2}\right) \cdot \left(-\sqrt{F}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \left(-{\left(\frac{B\_m}{\sqrt{2}}\right)}^{-1}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e-262Initial program 21.0%
Taylor expanded in A around -inf 27.4%
if 2.00000000000000002e-262 < (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000005e-193Initial program 17.5%
Taylor expanded in F around 0 23.2%
mul-1-neg23.2%
*-commutative23.2%
distribute-rgt-neg-in23.2%
associate-/l*40.0%
cancel-sign-sub-inv40.0%
metadata-eval40.0%
+-commutative40.0%
Simplified42.3%
if 5.0000000000000005e-193 < (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000001e-155 or 4.99999999999999999e-79 < (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000018e56Initial program 40.6%
Simplified46.9%
associate-*r*46.9%
associate-+r+45.9%
hypot-undefine40.6%
unpow240.6%
unpow240.6%
+-commutative40.6%
sqrt-prod40.4%
*-commutative40.4%
associate-*r*40.4%
associate-+l+40.5%
Applied egg-rr59.3%
associate-/l*59.3%
associate-*l*59.3%
associate-*r*59.3%
associate-+r+58.3%
Applied egg-rr58.3%
associate-*r*58.3%
distribute-frac-neg258.3%
Simplified58.3%
if 1.00000000000000001e-155 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999999e-79 or 2.00000000000000018e56 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999961e80Initial program 31.9%
Taylor expanded in A around -inf 37.5%
if 4.99999999999999961e80 < (pow.f64 B #s(literal 2 binary64)) < 3.9999999999999998e163Initial program 38.3%
Simplified44.0%
associate-*r*44.0%
associate-+r+43.8%
hypot-undefine38.3%
unpow238.3%
unpow238.3%
+-commutative38.3%
sqrt-prod38.2%
*-commutative38.2%
associate-*r*38.2%
associate-+l+38.3%
Applied egg-rr48.3%
associate-/l*48.2%
associate-*l*48.2%
associate-*r*48.2%
associate-+r+48.2%
Applied egg-rr48.2%
associate-*r*48.2%
distribute-frac-neg248.2%
Simplified48.2%
Taylor expanded in B around inf 13.1%
if 3.9999999999999998e163 < (pow.f64 B #s(literal 2 binary64)) Initial program 10.4%
Taylor expanded in A around 0 14.9%
mul-1-neg14.9%
*-commutative14.9%
distribute-rgt-neg-in14.9%
unpow214.9%
unpow214.9%
hypot-define26.3%
Simplified26.3%
*-commutative26.3%
sqrt-prod40.5%
Applied egg-rr40.5%
clear-num40.6%
inv-pow40.6%
Applied egg-rr40.6%
Final simplification36.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
(let* ((t_0 (* (* 4.0 A) C))
(t_1 (sqrt (* 2.0 C)))
(t_2 (fma B_m B_m (* A (* C -4.0))))
(t_3 (* F t_2))
(t_4 (- t_2))
(t_5 (/ (sqrt (* t_3 (* 2.0 (+ A (+ C (hypot B_m (- A C))))))) t_4)))
(if (<= (pow B_m 2.0) 2e-262)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 C)))
(- t_0 (pow B_m 2.0)))
(if (<= (pow B_m 2.0) 1e-175)
(* (* (sqrt F) (* B_m (sqrt 2.0))) (/ (- (sqrt B_m)) t_2))
(if (<= (pow B_m 2.0) 5e-30)
(/ (* t_1 (sqrt (* 2.0 (* F (fma B_m B_m (* -4.0 (* A C))))))) t_4)
(if (<= (pow B_m 2.0) 100000000.0)
t_5
(if (<= (pow B_m 2.0) 5e+80)
(* (sqrt (* 2.0 t_3)) (/ (- t_1) t_2))
(if (<= (pow B_m 2.0) 2e+96)
t_5
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(/ (sqrt 2.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) {
double t_0 = (4.0 * A) * C;
double t_1 = sqrt((2.0 * C));
double t_2 = fma(B_m, B_m, (A * (C * -4.0)));
double t_3 = F * t_2;
double t_4 = -t_2;
double t_5 = sqrt((t_3 * (2.0 * (A + (C + hypot(B_m, (A - C))))))) / t_4;
double tmp;
if (pow(B_m, 2.0) <= 2e-262) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 1e-175) {
tmp = (sqrt(F) * (B_m * sqrt(2.0))) * (-sqrt(B_m) / t_2);
} else if (pow(B_m, 2.0) <= 5e-30) {
tmp = (t_1 * sqrt((2.0 * (F * fma(B_m, B_m, (-4.0 * (A * C))))))) / t_4;
} else if (pow(B_m, 2.0) <= 100000000.0) {
tmp = t_5;
} else if (pow(B_m, 2.0) <= 5e+80) {
tmp = sqrt((2.0 * t_3)) * (-t_1 / t_2);
} else if (pow(B_m, 2.0) <= 2e+96) {
tmp = t_5;
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * (sqrt(2.0) / -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 = Float64(Float64(4.0 * A) * C) t_1 = sqrt(Float64(2.0 * C)) t_2 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_3 = Float64(F * t_2) t_4 = Float64(-t_2) t_5 = Float64(sqrt(Float64(t_3 * Float64(2.0 * Float64(A + Float64(C + hypot(B_m, Float64(A - C))))))) / t_4) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-262) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * C))) / Float64(t_0 - (B_m ^ 2.0))); elseif ((B_m ^ 2.0) <= 1e-175) tmp = Float64(Float64(sqrt(F) * Float64(B_m * sqrt(2.0))) * Float64(Float64(-sqrt(B_m)) / t_2)); elseif ((B_m ^ 2.0) <= 5e-30) tmp = Float64(Float64(t_1 * sqrt(Float64(2.0 * Float64(F * fma(B_m, B_m, Float64(-4.0 * Float64(A * C))))))) / t_4); elseif ((B_m ^ 2.0) <= 100000000.0) tmp = t_5; elseif ((B_m ^ 2.0) <= 5e+80) tmp = Float64(sqrt(Float64(2.0 * t_3)) * Float64(Float64(-t_1) / t_2)); elseif ((B_m ^ 2.0) <= 2e+96) tmp = t_5; else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(sqrt(2.0) / Float64(-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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(F * t$95$2), $MachinePrecision]}, Block[{t$95$4 = (-t$95$2)}, Block[{t$95$5 = N[(N[Sqrt[N[(t$95$3 * N[(2.0 * N[(A + N[(C + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-262], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-175], N[(N[(N[Sqrt[F], $MachinePrecision] * N[(B$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((-N[Sqrt[B$95$m], $MachinePrecision]) / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-30], N[(N[(t$95$1 * N[Sqrt[N[(2.0 * N[(F * N[(B$95$m * B$95$m + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$4), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 100000000.0], t$95$5, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+80], N[(N[Sqrt[N[(2.0 * t$95$3), $MachinePrecision]], $MachinePrecision] * N[((-t$95$1) / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+96], t$95$5, N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $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 := \left(4 \cdot A\right) \cdot C\\
t_1 := \sqrt{2 \cdot C}\\
t_2 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_3 := F \cdot t\_2\\
t_4 := -t\_2\\
t_5 := \frac{\sqrt{t\_3 \cdot \left(2 \cdot \left(A + \left(C + \mathsf{hypot}\left(B\_m, A - C\right)\right)\right)\right)}}{t\_4}\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-175}:\\
\;\;\;\;\left(\sqrt{F} \cdot \left(B\_m \cdot \sqrt{2}\right)\right) \cdot \frac{-\sqrt{B\_m}}{t\_2}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-30}:\\
\;\;\;\;\frac{t\_1 \cdot \sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B\_m, B\_m, -4 \cdot \left(A \cdot C\right)\right)\right)}}{t\_4}\\
\mathbf{elif}\;{B\_m}^{2} \leq 100000000:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+80}:\\
\;\;\;\;\sqrt{2 \cdot t\_3} \cdot \frac{-t\_1}{t\_2}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+96}:\\
\;\;\;\;t\_5\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e-262Initial program 21.0%
Taylor expanded in A around -inf 26.6%
if 2.00000000000000002e-262 < (pow.f64 B #s(literal 2 binary64)) < 1e-175Initial program 19.8%
Simplified19.9%
associate-*r*19.9%
associate-+r+19.8%
hypot-undefine19.8%
unpow219.8%
unpow219.8%
+-commutative19.8%
sqrt-prod22.4%
*-commutative22.4%
associate-*r*22.4%
associate-+l+22.4%
Applied egg-rr37.3%
associate-/l*37.5%
associate-*l*37.5%
associate-*r*37.5%
associate-+r+37.5%
Applied egg-rr37.5%
associate-*r*37.5%
distribute-frac-neg237.5%
Simplified37.5%
Taylor expanded in B around inf 18.2%
Taylor expanded in B around inf 16.0%
if 1e-175 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999972e-30Initial program 35.4%
Simplified44.1%
associate-*r*44.1%
associate-+r+42.7%
hypot-undefine35.4%
unpow235.4%
unpow235.4%
+-commutative35.4%
sqrt-prod35.3%
*-commutative35.3%
associate-*r*35.3%
associate-+l+36.1%
Applied egg-rr57.1%
Taylor expanded in A around -inf 46.0%
if 4.99999999999999972e-30 < (pow.f64 B #s(literal 2 binary64)) < 1e8 or 4.99999999999999961e80 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e96Initial program 65.7%
Simplified71.8%
if 1e8 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999961e80Initial program 23.0%
Simplified26.7%
associate-*r*26.7%
associate-+r+23.4%
hypot-undefine23.0%
unpow223.0%
unpow223.0%
+-commutative23.0%
sqrt-prod23.0%
*-commutative23.0%
associate-*r*23.0%
associate-+l+23.1%
Applied egg-rr34.8%
associate-/l*34.8%
associate-*l*34.8%
associate-*r*34.8%
associate-+r+30.4%
Applied egg-rr30.4%
associate-*r*30.4%
distribute-frac-neg230.4%
Simplified30.4%
Taylor expanded in A around -inf 8.9%
if 2.0000000000000001e96 < (pow.f64 B #s(literal 2 binary64)) Initial program 13.2%
Taylor expanded in A around 0 13.0%
mul-1-neg13.0%
*-commutative13.0%
distribute-rgt-neg-in13.0%
unpow213.0%
unpow213.0%
hypot-define22.7%
Simplified22.7%
*-commutative22.7%
sqrt-prod34.8%
Applied egg-rr34.8%
Final simplification32.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 (* (* 4.0 A) C))
(t_1 (sqrt (* 2.0 C)))
(t_2 (fma B_m B_m (* A (* C -4.0))))
(t_3 (- t_2)))
(if (<= (pow B_m 2.0) 2e-262)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 C)))
(- t_0 (pow B_m 2.0)))
(if (<= (pow B_m 2.0) 1e-175)
(* (* (sqrt F) (* B_m (sqrt 2.0))) (/ (- (sqrt B_m)) t_2))
(if (<= (pow B_m 2.0) 5e-30)
(/ (* t_1 (sqrt (* 2.0 (* F (fma B_m B_m (* -4.0 (* A C))))))) t_3)
(if (<= (pow B_m 2.0) 100000000.0)
(/ (sqrt (* F (* t_2 (* 2.0 (+ (+ A C) (hypot (- A C) B_m)))))) t_3)
(if (<= (pow B_m 2.0) 5e+80)
(* (sqrt (* 2.0 (* F t_2))) (/ (- t_1) t_2))
(if (<= (pow B_m 2.0) 2e+96)
(*
(sqrt
(/
(* F (+ (+ A C) (hypot B_m (- A C))))
(fma B_m B_m (* C (* A -4.0)))))
(- (sqrt 2.0)))
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(/ (sqrt 2.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) {
double t_0 = (4.0 * A) * C;
double t_1 = sqrt((2.0 * C));
double t_2 = fma(B_m, B_m, (A * (C * -4.0)));
double t_3 = -t_2;
double tmp;
if (pow(B_m, 2.0) <= 2e-262) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 1e-175) {
tmp = (sqrt(F) * (B_m * sqrt(2.0))) * (-sqrt(B_m) / t_2);
} else if (pow(B_m, 2.0) <= 5e-30) {
tmp = (t_1 * sqrt((2.0 * (F * fma(B_m, B_m, (-4.0 * (A * C))))))) / t_3;
} else if (pow(B_m, 2.0) <= 100000000.0) {
tmp = sqrt((F * (t_2 * (2.0 * ((A + C) + hypot((A - C), B_m)))))) / t_3;
} else if (pow(B_m, 2.0) <= 5e+80) {
tmp = sqrt((2.0 * (F * t_2))) * (-t_1 / t_2);
} else if (pow(B_m, 2.0) <= 2e+96) {
tmp = sqrt(((F * ((A + C) + hypot(B_m, (A - C)))) / fma(B_m, B_m, (C * (A * -4.0))))) * -sqrt(2.0);
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * (sqrt(2.0) / -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 = Float64(Float64(4.0 * A) * C) t_1 = sqrt(Float64(2.0 * C)) t_2 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_3 = Float64(-t_2) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-262) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * C))) / Float64(t_0 - (B_m ^ 2.0))); elseif ((B_m ^ 2.0) <= 1e-175) tmp = Float64(Float64(sqrt(F) * Float64(B_m * sqrt(2.0))) * Float64(Float64(-sqrt(B_m)) / t_2)); elseif ((B_m ^ 2.0) <= 5e-30) tmp = Float64(Float64(t_1 * sqrt(Float64(2.0 * Float64(F * fma(B_m, B_m, Float64(-4.0 * Float64(A * C))))))) / t_3); elseif ((B_m ^ 2.0) <= 100000000.0) tmp = Float64(sqrt(Float64(F * Float64(t_2 * Float64(2.0 * Float64(Float64(A + C) + hypot(Float64(A - C), B_m)))))) / t_3); elseif ((B_m ^ 2.0) <= 5e+80) tmp = Float64(sqrt(Float64(2.0 * Float64(F * t_2))) * Float64(Float64(-t_1) / t_2)); elseif ((B_m ^ 2.0) <= 2e+96) tmp = Float64(sqrt(Float64(Float64(F * Float64(Float64(A + C) + hypot(B_m, Float64(A - C)))) / fma(B_m, B_m, Float64(C * Float64(A * -4.0))))) * Float64(-sqrt(2.0))); else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(sqrt(2.0) / Float64(-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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = (-t$95$2)}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-262], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-175], N[(N[(N[Sqrt[F], $MachinePrecision] * N[(B$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((-N[Sqrt[B$95$m], $MachinePrecision]) / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-30], N[(N[(t$95$1 * N[Sqrt[N[(2.0 * N[(F * N[(B$95$m * B$95$m + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 100000000.0], N[(N[Sqrt[N[(F * N[(t$95$2 * N[(2.0 * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+80], N[(N[Sqrt[N[(2.0 * N[(F * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-t$95$1) / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+96], N[(N[Sqrt[N[(N[(F * N[(N[(A + C), $MachinePrecision] + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(B$95$m * B$95$m + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $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 := \left(4 \cdot A\right) \cdot C\\
t_1 := \sqrt{2 \cdot C}\\
t_2 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_3 := -t\_2\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-175}:\\
\;\;\;\;\left(\sqrt{F} \cdot \left(B\_m \cdot \sqrt{2}\right)\right) \cdot \frac{-\sqrt{B\_m}}{t\_2}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-30}:\\
\;\;\;\;\frac{t\_1 \cdot \sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B\_m, B\_m, -4 \cdot \left(A \cdot C\right)\right)\right)}}{t\_3}\\
\mathbf{elif}\;{B\_m}^{2} \leq 100000000:\\
\;\;\;\;\frac{\sqrt{F \cdot \left(t\_2 \cdot \left(2 \cdot \left(\left(A + C\right) + \mathsf{hypot}\left(A - C, B\_m\right)\right)\right)\right)}}{t\_3}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+80}:\\
\;\;\;\;\sqrt{2 \cdot \left(F \cdot t\_2\right)} \cdot \frac{-t\_1}{t\_2}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+96}:\\
\;\;\;\;\sqrt{\frac{F \cdot \left(\left(A + C\right) + \mathsf{hypot}\left(B\_m, A - C\right)\right)}{\mathsf{fma}\left(B\_m, B\_m, C \cdot \left(A \cdot -4\right)\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e-262Initial program 21.0%
Taylor expanded in A around -inf 26.6%
if 2.00000000000000002e-262 < (pow.f64 B #s(literal 2 binary64)) < 1e-175Initial program 19.8%
Simplified19.9%
associate-*r*19.9%
associate-+r+19.8%
hypot-undefine19.8%
unpow219.8%
unpow219.8%
+-commutative19.8%
sqrt-prod22.4%
*-commutative22.4%
associate-*r*22.4%
associate-+l+22.4%
Applied egg-rr37.3%
associate-/l*37.5%
associate-*l*37.5%
associate-*r*37.5%
associate-+r+37.5%
Applied egg-rr37.5%
associate-*r*37.5%
distribute-frac-neg237.5%
Simplified37.5%
Taylor expanded in B around inf 18.2%
Taylor expanded in B around inf 16.0%
if 1e-175 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999972e-30Initial program 35.4%
Simplified44.1%
associate-*r*44.1%
associate-+r+42.7%
hypot-undefine35.4%
unpow235.4%
unpow235.4%
+-commutative35.4%
sqrt-prod35.3%
*-commutative35.3%
associate-*r*35.3%
associate-+l+36.1%
Applied egg-rr57.1%
Taylor expanded in A around -inf 46.0%
if 4.99999999999999972e-30 < (pow.f64 B #s(literal 2 binary64)) < 1e8Initial program 62.4%
Simplified62.4%
associate-*r*62.4%
associate-+r+62.4%
hypot-undefine62.4%
unpow262.4%
unpow262.4%
+-commutative62.4%
sqrt-prod62.2%
*-commutative62.2%
associate-*r*62.2%
associate-+l+62.2%
Applied egg-rr62.2%
*-un-lft-identity62.2%
sqrt-unprod62.4%
associate-*r*62.4%
associate-*l*62.2%
associate-*r*62.2%
associate-+r+62.2%
Applied egg-rr62.2%
*-lft-identity62.2%
Simplified62.2%
if 1e8 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999961e80Initial program 23.0%
Simplified26.7%
associate-*r*26.7%
associate-+r+23.4%
hypot-undefine23.0%
unpow223.0%
unpow223.0%
+-commutative23.0%
sqrt-prod23.0%
*-commutative23.0%
associate-*r*23.0%
associate-+l+23.1%
Applied egg-rr34.8%
associate-/l*34.8%
associate-*l*34.8%
associate-*r*34.8%
associate-+r+30.4%
Applied egg-rr30.4%
associate-*r*30.4%
distribute-frac-neg230.4%
Simplified30.4%
Taylor expanded in A around -inf 8.9%
if 4.99999999999999961e80 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e96Initial program 75.7%
associate-*l*75.7%
sqrt-prod74.9%
associate-*l*74.9%
associate-+l+74.9%
unpow274.9%
unpow274.9%
hypot-define98.8%
Applied egg-rr98.8%
Taylor expanded in F around 0 75.3%
mul-1-neg75.3%
Simplified99.6%
if 2.0000000000000001e96 < (pow.f64 B #s(literal 2 binary64)) Initial program 13.2%
Taylor expanded in A around 0 13.0%
mul-1-neg13.0%
*-commutative13.0%
distribute-rgt-neg-in13.0%
unpow213.0%
unpow213.0%
hypot-define22.7%
Simplified22.7%
*-commutative22.7%
sqrt-prod34.8%
Applied egg-rr34.8%
Final simplification32.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
(let* ((t_0 (* (* 4.0 A) C))
(t_1 (+ A (+ C (hypot B_m (- A C)))))
(t_2 (fma B_m B_m (* A (* C -4.0))))
(t_3 (- t_2))
(t_4
(/
(sqrt
(*
(* 2.0 (* (- (pow B_m 2.0) t_0) F))
(+ (* -0.5 (/ (pow B_m 2.0) A)) (* 2.0 C))))
(- t_0 (pow B_m 2.0)))))
(if (<= (pow B_m 2.0) 2e-262)
t_4
(if (<= (pow B_m 2.0) 5e-193)
(* (sqrt (* F (/ t_1 (fma -4.0 (* A C) (pow B_m 2.0))))) (- (sqrt 2.0)))
(if (<= (pow B_m 2.0) 4e-99)
(/
(*
(sqrt (* 2.0 C))
(sqrt (* 2.0 (* F (fma B_m B_m (* -4.0 (* A C)))))))
t_3)
(if (<= (pow B_m 2.0) 4e-31)
t_4
(if (<= (pow B_m 2.0) 20.0)
(/ (sqrt (* (* F t_2) (* 2.0 t_1))) t_3)
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(- (pow (/ B_m (sqrt 2.0)) -1.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 = (4.0 * A) * C;
double t_1 = A + (C + hypot(B_m, (A - C)));
double t_2 = fma(B_m, B_m, (A * (C * -4.0)));
double t_3 = -t_2;
double t_4 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * ((-0.5 * (pow(B_m, 2.0) / A)) + (2.0 * C)))) / (t_0 - pow(B_m, 2.0));
double tmp;
if (pow(B_m, 2.0) <= 2e-262) {
tmp = t_4;
} else if (pow(B_m, 2.0) <= 5e-193) {
tmp = sqrt((F * (t_1 / fma(-4.0, (A * C), pow(B_m, 2.0))))) * -sqrt(2.0);
} else if (pow(B_m, 2.0) <= 4e-99) {
tmp = (sqrt((2.0 * C)) * sqrt((2.0 * (F * fma(B_m, B_m, (-4.0 * (A * C))))))) / t_3;
} else if (pow(B_m, 2.0) <= 4e-31) {
tmp = t_4;
} else if (pow(B_m, 2.0) <= 20.0) {
tmp = sqrt(((F * t_2) * (2.0 * t_1))) / t_3;
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * -pow((B_m / sqrt(2.0)), -1.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 = Float64(Float64(4.0 * A) * C) t_1 = Float64(A + Float64(C + hypot(B_m, Float64(A - C)))) t_2 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_3 = Float64(-t_2) t_4 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(Float64(-0.5 * Float64((B_m ^ 2.0) / A)) + Float64(2.0 * C)))) / Float64(t_0 - (B_m ^ 2.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-262) tmp = t_4; elseif ((B_m ^ 2.0) <= 5e-193) tmp = Float64(sqrt(Float64(F * Float64(t_1 / fma(-4.0, Float64(A * C), (B_m ^ 2.0))))) * Float64(-sqrt(2.0))); elseif ((B_m ^ 2.0) <= 4e-99) tmp = Float64(Float64(sqrt(Float64(2.0 * C)) * sqrt(Float64(2.0 * Float64(F * fma(B_m, B_m, Float64(-4.0 * Float64(A * C))))))) / t_3); elseif ((B_m ^ 2.0) <= 4e-31) tmp = t_4; elseif ((B_m ^ 2.0) <= 20.0) tmp = Float64(sqrt(Float64(Float64(F * t_2) * Float64(2.0 * t_1))) / t_3); else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(-(Float64(B_m / sqrt(2.0)) ^ -1.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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(A + N[(C + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = (-t$95$2)}, Block[{t$95$4 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-262], t$95$4, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-193], N[(N[Sqrt[N[(F * N[(t$95$1 / N[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e-99], N[(N[(N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 * N[(F * N[(B$95$m * B$95$m + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e-31], t$95$4, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 20.0], N[(N[Sqrt[N[(N[(F * t$95$2), $MachinePrecision] * N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision], N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * (-N[Power[N[(B$95$m / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], -1.0], $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 := \left(4 \cdot A\right) \cdot C\\
t_1 := A + \left(C + \mathsf{hypot}\left(B\_m, A - C\right)\right)\\
t_2 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_3 := -t\_2\\
t_4 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(-0.5 \cdot \frac{{B\_m}^{2}}{A} + 2 \cdot C\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-193}:\\
\;\;\;\;\sqrt{F \cdot \frac{t\_1}{\mathsf{fma}\left(-4, A \cdot C, {B\_m}^{2}\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;{B\_m}^{2} \leq 4 \cdot 10^{-99}:\\
\;\;\;\;\frac{\sqrt{2 \cdot C} \cdot \sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B\_m, B\_m, -4 \cdot \left(A \cdot C\right)\right)\right)}}{t\_3}\\
\mathbf{elif}\;{B\_m}^{2} \leq 4 \cdot 10^{-31}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;{B\_m}^{2} \leq 20:\\
\;\;\;\;\frac{\sqrt{\left(F \cdot t\_2\right) \cdot \left(2 \cdot t\_1\right)}}{t\_3}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \left(-{\left(\frac{B\_m}{\sqrt{2}}\right)}^{-1}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e-262 or 4.0000000000000001e-99 < (pow.f64 B #s(literal 2 binary64)) < 4e-31Initial program 23.5%
Taylor expanded in A around -inf 29.1%
if 2.00000000000000002e-262 < (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000005e-193Initial program 17.5%
Taylor expanded in F around 0 23.2%
mul-1-neg23.2%
*-commutative23.2%
distribute-rgt-neg-in23.2%
associate-/l*40.0%
cancel-sign-sub-inv40.0%
metadata-eval40.0%
+-commutative40.0%
Simplified42.3%
if 5.0000000000000005e-193 < (pow.f64 B #s(literal 2 binary64)) < 4.0000000000000001e-99Initial program 31.0%
Simplified40.2%
associate-*r*40.2%
associate-+r+40.2%
hypot-undefine31.0%
unpow231.0%
unpow231.0%
+-commutative31.0%
sqrt-prod30.8%
*-commutative30.8%
associate-*r*30.8%
associate-+l+30.8%
Applied egg-rr62.3%
Taylor expanded in A around -inf 45.3%
if 4e-31 < (pow.f64 B #s(literal 2 binary64)) < 20Initial program 54.1%
Simplified55.8%
if 20 < (pow.f64 B #s(literal 2 binary64)) Initial program 17.2%
Taylor expanded in A around 0 12.9%
mul-1-neg12.9%
*-commutative12.9%
distribute-rgt-neg-in12.9%
unpow212.9%
unpow212.9%
hypot-define21.2%
Simplified21.2%
*-commutative21.2%
sqrt-prod31.3%
Applied egg-rr31.3%
clear-num31.4%
inv-pow31.4%
Applied egg-rr31.4%
Final simplification33.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 (* (* 4.0 A) C))
(t_1 (fma B_m B_m (* A (* C -4.0))))
(t_2 (* F t_1))
(t_3
(/
(sqrt
(*
(* 2.0 (* (- (pow B_m 2.0) t_0) F))
(+ (* -0.5 (/ (pow B_m 2.0) A)) (* 2.0 C))))
(- t_0 (pow B_m 2.0)))))
(if (<= (pow B_m 2.0) 2e-262)
t_3
(if (<= (pow B_m 2.0) 1e-175)
(* (* (sqrt F) (* B_m (sqrt 2.0))) (/ (- (sqrt B_m)) t_1))
(if (<= (pow B_m 2.0) 5e-30)
t_3
(if (<= (pow B_m 2.0) 100000000.0)
(/ (sqrt (* t_2 (* 2.0 (+ A (+ C (hypot B_m (- A C))))))) (- t_1))
(if (<= (pow B_m 2.0) 5e+80)
(* (sqrt (* 2.0 t_2)) (/ (- (sqrt (* 2.0 C))) t_1))
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(- (pow (/ B_m (sqrt 2.0)) -1.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 = (4.0 * A) * C;
double t_1 = fma(B_m, B_m, (A * (C * -4.0)));
double t_2 = F * t_1;
double t_3 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * ((-0.5 * (pow(B_m, 2.0) / A)) + (2.0 * C)))) / (t_0 - pow(B_m, 2.0));
double tmp;
if (pow(B_m, 2.0) <= 2e-262) {
tmp = t_3;
} else if (pow(B_m, 2.0) <= 1e-175) {
tmp = (sqrt(F) * (B_m * sqrt(2.0))) * (-sqrt(B_m) / t_1);
} else if (pow(B_m, 2.0) <= 5e-30) {
tmp = t_3;
} else if (pow(B_m, 2.0) <= 100000000.0) {
tmp = sqrt((t_2 * (2.0 * (A + (C + hypot(B_m, (A - C))))))) / -t_1;
} else if (pow(B_m, 2.0) <= 5e+80) {
tmp = sqrt((2.0 * t_2)) * (-sqrt((2.0 * C)) / t_1);
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * -pow((B_m / sqrt(2.0)), -1.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 = Float64(Float64(4.0 * A) * C) t_1 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_2 = Float64(F * t_1) t_3 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(Float64(-0.5 * Float64((B_m ^ 2.0) / A)) + Float64(2.0 * C)))) / Float64(t_0 - (B_m ^ 2.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-262) tmp = t_3; elseif ((B_m ^ 2.0) <= 1e-175) tmp = Float64(Float64(sqrt(F) * Float64(B_m * sqrt(2.0))) * Float64(Float64(-sqrt(B_m)) / t_1)); elseif ((B_m ^ 2.0) <= 5e-30) tmp = t_3; elseif ((B_m ^ 2.0) <= 100000000.0) tmp = Float64(sqrt(Float64(t_2 * Float64(2.0 * Float64(A + Float64(C + hypot(B_m, Float64(A - C))))))) / Float64(-t_1)); elseif ((B_m ^ 2.0) <= 5e+80) tmp = Float64(sqrt(Float64(2.0 * t_2)) * Float64(Float64(-sqrt(Float64(2.0 * C))) / t_1)); else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(-(Float64(B_m / sqrt(2.0)) ^ -1.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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(F * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-262], t$95$3, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-175], N[(N[(N[Sqrt[F], $MachinePrecision] * N[(B$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((-N[Sqrt[B$95$m], $MachinePrecision]) / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-30], t$95$3, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 100000000.0], N[(N[Sqrt[N[(t$95$2 * N[(2.0 * N[(A + N[(C + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+80], N[(N[Sqrt[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * (-N[Power[N[(B$95$m / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], -1.0], $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 := \left(4 \cdot A\right) \cdot C\\
t_1 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := F \cdot t\_1\\
t_3 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(-0.5 \cdot \frac{{B\_m}^{2}}{A} + 2 \cdot C\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-175}:\\
\;\;\;\;\left(\sqrt{F} \cdot \left(B\_m \cdot \sqrt{2}\right)\right) \cdot \frac{-\sqrt{B\_m}}{t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-30}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;{B\_m}^{2} \leq 100000000:\\
\;\;\;\;\frac{\sqrt{t\_2 \cdot \left(2 \cdot \left(A + \left(C + \mathsf{hypot}\left(B\_m, A - C\right)\right)\right)\right)}}{-t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+80}:\\
\;\;\;\;\sqrt{2 \cdot t\_2} \cdot \frac{-\sqrt{2 \cdot C}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \left(-{\left(\frac{B\_m}{\sqrt{2}}\right)}^{-1}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e-262 or 1e-175 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999972e-30Initial program 24.6%
Taylor expanded in A around -inf 31.9%
if 2.00000000000000002e-262 < (pow.f64 B #s(literal 2 binary64)) < 1e-175Initial program 19.8%
Simplified19.9%
associate-*r*19.9%
associate-+r+19.8%
hypot-undefine19.8%
unpow219.8%
unpow219.8%
+-commutative19.8%
sqrt-prod22.4%
*-commutative22.4%
associate-*r*22.4%
associate-+l+22.4%
Applied egg-rr37.3%
associate-/l*37.5%
associate-*l*37.5%
associate-*r*37.5%
associate-+r+37.5%
Applied egg-rr37.5%
associate-*r*37.5%
distribute-frac-neg237.5%
Simplified37.5%
Taylor expanded in B around inf 18.2%
Taylor expanded in B around inf 16.0%
if 4.99999999999999972e-30 < (pow.f64 B #s(literal 2 binary64)) < 1e8Initial program 62.4%
Simplified62.4%
if 1e8 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999961e80Initial program 23.0%
Simplified26.7%
associate-*r*26.7%
associate-+r+23.4%
hypot-undefine23.0%
unpow223.0%
unpow223.0%
+-commutative23.0%
sqrt-prod23.0%
*-commutative23.0%
associate-*r*23.0%
associate-+l+23.1%
Applied egg-rr34.8%
associate-/l*34.8%
associate-*l*34.8%
associate-*r*34.8%
associate-+r+30.4%
Applied egg-rr30.4%
associate-*r*30.4%
distribute-frac-neg230.4%
Simplified30.4%
Taylor expanded in A around -inf 8.9%
if 4.99999999999999961e80 < (pow.f64 B #s(literal 2 binary64)) Initial program 15.6%
Taylor expanded in A around 0 13.5%
mul-1-neg13.5%
*-commutative13.5%
distribute-rgt-neg-in13.5%
unpow213.5%
unpow213.5%
hypot-define22.9%
Simplified22.9%
*-commutative22.9%
sqrt-prod34.5%
Applied egg-rr34.5%
clear-num34.6%
inv-pow34.6%
Applied egg-rr34.6%
Final simplification32.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
(let* ((t_0 (* (* 4.0 A) C))
(t_1 (fma B_m B_m (* A (* C -4.0))))
(t_2 (* F t_1))
(t_3
(/
(sqrt
(*
(* 2.0 (* (- (pow B_m 2.0) t_0) F))
(+ (* -0.5 (/ (pow B_m 2.0) A)) (* 2.0 C))))
(- t_0 (pow B_m 2.0)))))
(if (<= (pow B_m 2.0) 2e-262)
t_3
(if (<= (pow B_m 2.0) 1e-175)
(* (* (sqrt F) (* B_m (sqrt 2.0))) (/ (- (sqrt B_m)) t_1))
(if (<= (pow B_m 2.0) 5e-30)
t_3
(if (<= (pow B_m 2.0) 100000000.0)
(/ (sqrt (* t_2 (* 2.0 (+ A (+ C (hypot B_m (- A C))))))) (- t_1))
(if (<= (pow B_m 2.0) 5e+80)
(* (sqrt (* 2.0 t_2)) (/ (- (sqrt (* 2.0 C))) t_1))
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(/ (sqrt 2.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) {
double t_0 = (4.0 * A) * C;
double t_1 = fma(B_m, B_m, (A * (C * -4.0)));
double t_2 = F * t_1;
double t_3 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * ((-0.5 * (pow(B_m, 2.0) / A)) + (2.0 * C)))) / (t_0 - pow(B_m, 2.0));
double tmp;
if (pow(B_m, 2.0) <= 2e-262) {
tmp = t_3;
} else if (pow(B_m, 2.0) <= 1e-175) {
tmp = (sqrt(F) * (B_m * sqrt(2.0))) * (-sqrt(B_m) / t_1);
} else if (pow(B_m, 2.0) <= 5e-30) {
tmp = t_3;
} else if (pow(B_m, 2.0) <= 100000000.0) {
tmp = sqrt((t_2 * (2.0 * (A + (C + hypot(B_m, (A - C))))))) / -t_1;
} else if (pow(B_m, 2.0) <= 5e+80) {
tmp = sqrt((2.0 * t_2)) * (-sqrt((2.0 * C)) / t_1);
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * (sqrt(2.0) / -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 = Float64(Float64(4.0 * A) * C) t_1 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_2 = Float64(F * t_1) t_3 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(Float64(-0.5 * Float64((B_m ^ 2.0) / A)) + Float64(2.0 * C)))) / Float64(t_0 - (B_m ^ 2.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-262) tmp = t_3; elseif ((B_m ^ 2.0) <= 1e-175) tmp = Float64(Float64(sqrt(F) * Float64(B_m * sqrt(2.0))) * Float64(Float64(-sqrt(B_m)) / t_1)); elseif ((B_m ^ 2.0) <= 5e-30) tmp = t_3; elseif ((B_m ^ 2.0) <= 100000000.0) tmp = Float64(sqrt(Float64(t_2 * Float64(2.0 * Float64(A + Float64(C + hypot(B_m, Float64(A - C))))))) / Float64(-t_1)); elseif ((B_m ^ 2.0) <= 5e+80) tmp = Float64(sqrt(Float64(2.0 * t_2)) * Float64(Float64(-sqrt(Float64(2.0 * C))) / t_1)); else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(sqrt(2.0) / Float64(-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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(F * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-262], t$95$3, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-175], N[(N[(N[Sqrt[F], $MachinePrecision] * N[(B$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((-N[Sqrt[B$95$m], $MachinePrecision]) / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-30], t$95$3, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 100000000.0], N[(N[Sqrt[N[(t$95$2 * N[(2.0 * N[(A + N[(C + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+80], N[(N[Sqrt[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $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 := \left(4 \cdot A\right) \cdot C\\
t_1 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := F \cdot t\_1\\
t_3 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(-0.5 \cdot \frac{{B\_m}^{2}}{A} + 2 \cdot C\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-175}:\\
\;\;\;\;\left(\sqrt{F} \cdot \left(B\_m \cdot \sqrt{2}\right)\right) \cdot \frac{-\sqrt{B\_m}}{t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-30}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;{B\_m}^{2} \leq 100000000:\\
\;\;\;\;\frac{\sqrt{t\_2 \cdot \left(2 \cdot \left(A + \left(C + \mathsf{hypot}\left(B\_m, A - C\right)\right)\right)\right)}}{-t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+80}:\\
\;\;\;\;\sqrt{2 \cdot t\_2} \cdot \frac{-\sqrt{2 \cdot C}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e-262 or 1e-175 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999972e-30Initial program 24.6%
Taylor expanded in A around -inf 31.9%
if 2.00000000000000002e-262 < (pow.f64 B #s(literal 2 binary64)) < 1e-175Initial program 19.8%
Simplified19.9%
associate-*r*19.9%
associate-+r+19.8%
hypot-undefine19.8%
unpow219.8%
unpow219.8%
+-commutative19.8%
sqrt-prod22.4%
*-commutative22.4%
associate-*r*22.4%
associate-+l+22.4%
Applied egg-rr37.3%
associate-/l*37.5%
associate-*l*37.5%
associate-*r*37.5%
associate-+r+37.5%
Applied egg-rr37.5%
associate-*r*37.5%
distribute-frac-neg237.5%
Simplified37.5%
Taylor expanded in B around inf 18.2%
Taylor expanded in B around inf 16.0%
if 4.99999999999999972e-30 < (pow.f64 B #s(literal 2 binary64)) < 1e8Initial program 62.4%
Simplified62.4%
if 1e8 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999961e80Initial program 23.0%
Simplified26.7%
associate-*r*26.7%
associate-+r+23.4%
hypot-undefine23.0%
unpow223.0%
unpow223.0%
+-commutative23.0%
sqrt-prod23.0%
*-commutative23.0%
associate-*r*23.0%
associate-+l+23.1%
Applied egg-rr34.8%
associate-/l*34.8%
associate-*l*34.8%
associate-*r*34.8%
associate-+r+30.4%
Applied egg-rr30.4%
associate-*r*30.4%
distribute-frac-neg230.4%
Simplified30.4%
Taylor expanded in A around -inf 8.9%
if 4.99999999999999961e80 < (pow.f64 B #s(literal 2 binary64)) Initial program 15.6%
Taylor expanded in A around 0 13.5%
mul-1-neg13.5%
*-commutative13.5%
distribute-rgt-neg-in13.5%
unpow213.5%
unpow213.5%
hypot-define22.9%
Simplified22.9%
*-commutative22.9%
sqrt-prod34.5%
Applied egg-rr34.5%
Final simplification32.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
(let* ((t_0 (* (* 4.0 A) C))
(t_1
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 C)))
(- t_0 (pow B_m 2.0)))))
(if (<= (pow B_m 2.0) 2e-262)
t_1
(if (<= (pow B_m 2.0) 1e-175)
(*
(* (sqrt F) (* B_m (sqrt 2.0)))
(/ (- (sqrt B_m)) (fma B_m B_m (* A (* C -4.0)))))
(if (<= (pow B_m 2.0) 1e-22)
t_1
(if (<= (pow B_m 2.0) 2e+96)
(*
(sqrt
(/
(* F (+ (+ A C) (hypot B_m (- A C))))
(fma B_m B_m (* C (* A -4.0)))))
(- (sqrt 2.0)))
(if (<= (pow B_m 2.0) 2e+200)
(*
(* B_m (pow (* 2.0 F) 0.5))
(/
(sqrt (+ A (+ C (hypot (- A C) B_m))))
(- (fma B_m B_m (* -4.0 (* A C))))))
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(/ (sqrt 2.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) {
double t_0 = (4.0 * A) * C;
double t_1 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - pow(B_m, 2.0));
double tmp;
if (pow(B_m, 2.0) <= 2e-262) {
tmp = t_1;
} else if (pow(B_m, 2.0) <= 1e-175) {
tmp = (sqrt(F) * (B_m * sqrt(2.0))) * (-sqrt(B_m) / fma(B_m, B_m, (A * (C * -4.0))));
} else if (pow(B_m, 2.0) <= 1e-22) {
tmp = t_1;
} else if (pow(B_m, 2.0) <= 2e+96) {
tmp = sqrt(((F * ((A + C) + hypot(B_m, (A - C)))) / fma(B_m, B_m, (C * (A * -4.0))))) * -sqrt(2.0);
} else if (pow(B_m, 2.0) <= 2e+200) {
tmp = (B_m * pow((2.0 * F), 0.5)) * (sqrt((A + (C + hypot((A - C), B_m)))) / -fma(B_m, B_m, (-4.0 * (A * C))));
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * (sqrt(2.0) / -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 = Float64(Float64(4.0 * A) * C) t_1 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * C))) / Float64(t_0 - (B_m ^ 2.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-262) tmp = t_1; elseif ((B_m ^ 2.0) <= 1e-175) tmp = Float64(Float64(sqrt(F) * Float64(B_m * sqrt(2.0))) * Float64(Float64(-sqrt(B_m)) / fma(B_m, B_m, Float64(A * Float64(C * -4.0))))); elseif ((B_m ^ 2.0) <= 1e-22) tmp = t_1; elseif ((B_m ^ 2.0) <= 2e+96) tmp = Float64(sqrt(Float64(Float64(F * Float64(Float64(A + C) + hypot(B_m, Float64(A - C)))) / fma(B_m, B_m, Float64(C * Float64(A * -4.0))))) * Float64(-sqrt(2.0))); elseif ((B_m ^ 2.0) <= 2e+200) tmp = Float64(Float64(B_m * (Float64(2.0 * F) ^ 0.5)) * Float64(sqrt(Float64(A + Float64(C + hypot(Float64(A - C), B_m)))) / Float64(-fma(B_m, B_m, Float64(-4.0 * Float64(A * C)))))); else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(sqrt(2.0) / Float64(-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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-262], t$95$1, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-175], N[(N[(N[Sqrt[F], $MachinePrecision] * N[(B$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((-N[Sqrt[B$95$m], $MachinePrecision]) / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-22], t$95$1, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+96], N[(N[Sqrt[N[(N[(F * N[(N[(A + C), $MachinePrecision] + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(B$95$m * B$95$m + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+200], N[(N[(B$95$m * N[Power[N[(2.0 * F), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(A + N[(C + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(B$95$m * B$95$m + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $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 := \left(4 \cdot A\right) \cdot C\\
t_1 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-175}:\\
\;\;\;\;\left(\sqrt{F} \cdot \left(B\_m \cdot \sqrt{2}\right)\right) \cdot \frac{-\sqrt{B\_m}}{\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+96}:\\
\;\;\;\;\sqrt{\frac{F \cdot \left(\left(A + C\right) + \mathsf{hypot}\left(B\_m, A - C\right)\right)}{\mathsf{fma}\left(B\_m, B\_m, C \cdot \left(A \cdot -4\right)\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+200}:\\
\;\;\;\;\left(B\_m \cdot {\left(2 \cdot F\right)}^{0.5}\right) \cdot \frac{\sqrt{A + \left(C + \mathsf{hypot}\left(A - C, B\_m\right)\right)}}{-\mathsf{fma}\left(B\_m, B\_m, -4 \cdot \left(A \cdot C\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e-262 or 1e-175 < (pow.f64 B #s(literal 2 binary64)) < 1e-22Initial program 25.9%
Taylor expanded in A around -inf 31.8%
if 2.00000000000000002e-262 < (pow.f64 B #s(literal 2 binary64)) < 1e-175Initial program 19.8%
Simplified19.9%
associate-*r*19.9%
associate-+r+19.8%
hypot-undefine19.8%
unpow219.8%
unpow219.8%
+-commutative19.8%
sqrt-prod22.4%
*-commutative22.4%
associate-*r*22.4%
associate-+l+22.4%
Applied egg-rr37.3%
associate-/l*37.5%
associate-*l*37.5%
associate-*r*37.5%
associate-+r+37.5%
Applied egg-rr37.5%
associate-*r*37.5%
distribute-frac-neg237.5%
Simplified37.5%
Taylor expanded in B around inf 18.2%
Taylor expanded in B around inf 16.0%
if 1e-22 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e96Initial program 41.9%
associate-*l*41.9%
sqrt-prod41.7%
associate-*l*41.7%
associate-+l+41.7%
unpow241.7%
unpow241.7%
hypot-define47.0%
Applied egg-rr47.0%
Taylor expanded in F around 0 40.1%
mul-1-neg40.1%
Simplified44.2%
if 2.0000000000000001e96 < (pow.f64 B #s(literal 2 binary64)) < 1.9999999999999999e200Initial program 32.0%
Simplified32.7%
associate-*r*32.7%
associate-+r+32.8%
hypot-undefine32.0%
unpow232.0%
unpow232.0%
+-commutative32.0%
sqrt-prod31.8%
*-commutative31.8%
associate-*r*31.8%
associate-+l+31.9%
Applied egg-rr36.1%
associate-/l*36.2%
associate-*l*36.2%
associate-*r*36.2%
associate-+r+36.4%
Applied egg-rr36.4%
associate-*r*36.4%
distribute-frac-neg236.4%
Simplified36.4%
Taylor expanded in B around inf 19.7%
distribute-rgt-neg-out19.7%
associate-*l*19.8%
pow1/219.8%
metadata-eval19.8%
metadata-eval19.8%
sqrt-pow219.8%
pow1/219.8%
pow-prod-down19.7%
sqrt-pow219.8%
metadata-eval19.8%
metadata-eval19.8%
associate-+l+19.0%
associate-*r*19.0%
Applied egg-rr19.0%
if 1.9999999999999999e200 < (pow.f64 B #s(literal 2 binary64)) Initial program 7.4%
Taylor expanded in A around 0 13.5%
mul-1-neg13.5%
*-commutative13.5%
distribute-rgt-neg-in13.5%
unpow213.5%
unpow213.5%
hypot-define26.0%
Simplified26.0%
*-commutative26.0%
sqrt-prod41.8%
Applied egg-rr41.8%
Final simplification33.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
(let* ((t_0 (* (* 4.0 A) C))
(t_1 (fma B_m B_m (* A (* C -4.0))))
(t_2
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 C)))
(- t_0 (pow B_m 2.0)))))
(if (<= (pow B_m 2.0) 2e-262)
t_2
(if (<= (pow B_m 2.0) 1e-175)
(* (* (sqrt F) (* B_m (sqrt 2.0))) (/ (- (sqrt B_m)) t_1))
(if (<= (pow B_m 2.0) 1e-22)
(/
(*
(sqrt (* 2.0 C))
(sqrt (* 2.0 (* F (fma B_m B_m (* -4.0 (* A C)))))))
(- t_1))
(if (<= (pow B_m 2.0) 1e+64)
(*
(sqrt
(/
(* F (+ (+ A C) (hypot B_m (- A C))))
(fma B_m B_m (* C (* A -4.0)))))
(- (sqrt 2.0)))
(if (<= (pow B_m 2.0) 5e+75)
t_2
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(/ (sqrt 2.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) {
double t_0 = (4.0 * A) * C;
double t_1 = fma(B_m, B_m, (A * (C * -4.0)));
double t_2 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - pow(B_m, 2.0));
double tmp;
if (pow(B_m, 2.0) <= 2e-262) {
tmp = t_2;
} else if (pow(B_m, 2.0) <= 1e-175) {
tmp = (sqrt(F) * (B_m * sqrt(2.0))) * (-sqrt(B_m) / t_1);
} else if (pow(B_m, 2.0) <= 1e-22) {
tmp = (sqrt((2.0 * C)) * sqrt((2.0 * (F * fma(B_m, B_m, (-4.0 * (A * C))))))) / -t_1;
} else if (pow(B_m, 2.0) <= 1e+64) {
tmp = sqrt(((F * ((A + C) + hypot(B_m, (A - C)))) / fma(B_m, B_m, (C * (A * -4.0))))) * -sqrt(2.0);
} else if (pow(B_m, 2.0) <= 5e+75) {
tmp = t_2;
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * (sqrt(2.0) / -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 = Float64(Float64(4.0 * A) * C) t_1 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_2 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * C))) / Float64(t_0 - (B_m ^ 2.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-262) tmp = t_2; elseif ((B_m ^ 2.0) <= 1e-175) tmp = Float64(Float64(sqrt(F) * Float64(B_m * sqrt(2.0))) * Float64(Float64(-sqrt(B_m)) / t_1)); elseif ((B_m ^ 2.0) <= 1e-22) tmp = Float64(Float64(sqrt(Float64(2.0 * C)) * sqrt(Float64(2.0 * Float64(F * fma(B_m, B_m, Float64(-4.0 * Float64(A * C))))))) / Float64(-t_1)); elseif ((B_m ^ 2.0) <= 1e+64) tmp = Float64(sqrt(Float64(Float64(F * Float64(Float64(A + C) + hypot(B_m, Float64(A - C)))) / fma(B_m, B_m, Float64(C * Float64(A * -4.0))))) * Float64(-sqrt(2.0))); elseif ((B_m ^ 2.0) <= 5e+75) tmp = t_2; else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(sqrt(2.0) / Float64(-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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-262], t$95$2, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-175], N[(N[(N[Sqrt[F], $MachinePrecision] * N[(B$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((-N[Sqrt[B$95$m], $MachinePrecision]) / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-22], N[(N[(N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 * N[(F * N[(B$95$m * B$95$m + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+64], N[(N[Sqrt[N[(N[(F * N[(N[(A + C), $MachinePrecision] + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(B$95$m * B$95$m + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+75], t$95$2, N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $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 := \left(4 \cdot A\right) \cdot C\\
t_1 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-175}:\\
\;\;\;\;\left(\sqrt{F} \cdot \left(B\_m \cdot \sqrt{2}\right)\right) \cdot \frac{-\sqrt{B\_m}}{t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-22}:\\
\;\;\;\;\frac{\sqrt{2 \cdot C} \cdot \sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B\_m, B\_m, -4 \cdot \left(A \cdot C\right)\right)\right)}}{-t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+64}:\\
\;\;\;\;\sqrt{\frac{F \cdot \left(\left(A + C\right) + \mathsf{hypot}\left(B\_m, A - C\right)\right)}{\mathsf{fma}\left(B\_m, B\_m, C \cdot \left(A \cdot -4\right)\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+75}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e-262 or 1.00000000000000002e64 < (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000002e75Initial program 20.8%
Taylor expanded in A around -inf 26.3%
if 2.00000000000000002e-262 < (pow.f64 B #s(literal 2 binary64)) < 1e-175Initial program 19.8%
Simplified19.9%
associate-*r*19.9%
associate-+r+19.8%
hypot-undefine19.8%
unpow219.8%
unpow219.8%
+-commutative19.8%
sqrt-prod22.4%
*-commutative22.4%
associate-*r*22.4%
associate-+l+22.4%
Applied egg-rr37.3%
associate-/l*37.5%
associate-*l*37.5%
associate-*r*37.5%
associate-+r+37.5%
Applied egg-rr37.5%
associate-*r*37.5%
distribute-frac-neg237.5%
Simplified37.5%
Taylor expanded in B around inf 18.2%
Taylor expanded in B around inf 16.0%
if 1e-175 < (pow.f64 B #s(literal 2 binary64)) < 1e-22Initial program 39.8%
Simplified47.9%
associate-*r*47.9%
associate-+r+46.7%
hypot-undefine39.8%
unpow239.8%
unpow239.8%
+-commutative39.8%
sqrt-prod39.8%
*-commutative39.8%
associate-*r*39.8%
associate-+l+40.5%
Applied egg-rr60.1%
Taylor expanded in A around -inf 46.3%
if 1e-22 < (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000002e64Initial program 41.2%
associate-*l*41.2%
sqrt-prod41.2%
associate-*l*41.2%
associate-+l+41.2%
unpow241.2%
unpow241.2%
hypot-define41.9%
Applied egg-rr41.9%
Taylor expanded in F around 0 38.8%
mul-1-neg38.8%
Simplified39.2%
if 5.0000000000000002e75 < (pow.f64 B #s(literal 2 binary64)) Initial program 15.3%
Taylor expanded in A around 0 13.3%
mul-1-neg13.3%
*-commutative13.3%
distribute-rgt-neg-in13.3%
unpow213.3%
unpow213.3%
hypot-define22.5%
Simplified22.5%
*-commutative22.5%
sqrt-prod33.9%
Applied egg-rr33.9%
Final simplification32.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
(let* ((t_0 (* (* 4.0 A) C))
(t_1 (fma B_m B_m (* A (* C -4.0))))
(t_2
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 C)))
(- t_0 (pow B_m 2.0)))))
(if (<= (pow B_m 2.0) 2e-262)
t_2
(if (<= (pow B_m 2.0) 1e-175)
(* (* (sqrt F) (* B_m (sqrt 2.0))) (/ (- (sqrt B_m)) t_1))
(if (<= (pow B_m 2.0) 1e-22)
(* (sqrt (* 2.0 (* F t_1))) (/ (- (sqrt (* 2.0 C))) t_1))
(if (<= (pow B_m 2.0) 1e+64)
(*
(sqrt
(/
(* F (+ (+ A C) (hypot B_m (- A C))))
(fma B_m B_m (* C (* A -4.0)))))
(- (sqrt 2.0)))
(if (<= (pow B_m 2.0) 5e+75)
t_2
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(/ (sqrt 2.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) {
double t_0 = (4.0 * A) * C;
double t_1 = fma(B_m, B_m, (A * (C * -4.0)));
double t_2 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - pow(B_m, 2.0));
double tmp;
if (pow(B_m, 2.0) <= 2e-262) {
tmp = t_2;
} else if (pow(B_m, 2.0) <= 1e-175) {
tmp = (sqrt(F) * (B_m * sqrt(2.0))) * (-sqrt(B_m) / t_1);
} else if (pow(B_m, 2.0) <= 1e-22) {
tmp = sqrt((2.0 * (F * t_1))) * (-sqrt((2.0 * C)) / t_1);
} else if (pow(B_m, 2.0) <= 1e+64) {
tmp = sqrt(((F * ((A + C) + hypot(B_m, (A - C)))) / fma(B_m, B_m, (C * (A * -4.0))))) * -sqrt(2.0);
} else if (pow(B_m, 2.0) <= 5e+75) {
tmp = t_2;
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * (sqrt(2.0) / -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 = Float64(Float64(4.0 * A) * C) t_1 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_2 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * C))) / Float64(t_0 - (B_m ^ 2.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-262) tmp = t_2; elseif ((B_m ^ 2.0) <= 1e-175) tmp = Float64(Float64(sqrt(F) * Float64(B_m * sqrt(2.0))) * Float64(Float64(-sqrt(B_m)) / t_1)); elseif ((B_m ^ 2.0) <= 1e-22) tmp = Float64(sqrt(Float64(2.0 * Float64(F * t_1))) * Float64(Float64(-sqrt(Float64(2.0 * C))) / t_1)); elseif ((B_m ^ 2.0) <= 1e+64) tmp = Float64(sqrt(Float64(Float64(F * Float64(Float64(A + C) + hypot(B_m, Float64(A - C)))) / fma(B_m, B_m, Float64(C * Float64(A * -4.0))))) * Float64(-sqrt(2.0))); elseif ((B_m ^ 2.0) <= 5e+75) tmp = t_2; else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(sqrt(2.0) / Float64(-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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-262], t$95$2, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-175], N[(N[(N[Sqrt[F], $MachinePrecision] * N[(B$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((-N[Sqrt[B$95$m], $MachinePrecision]) / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-22], N[(N[Sqrt[N[(2.0 * N[(F * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+64], N[(N[Sqrt[N[(N[(F * N[(N[(A + C), $MachinePrecision] + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(B$95$m * B$95$m + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+75], t$95$2, N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $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 := \left(4 \cdot A\right) \cdot C\\
t_1 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-175}:\\
\;\;\;\;\left(\sqrt{F} \cdot \left(B\_m \cdot \sqrt{2}\right)\right) \cdot \frac{-\sqrt{B\_m}}{t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-22}:\\
\;\;\;\;\sqrt{2 \cdot \left(F \cdot t\_1\right)} \cdot \frac{-\sqrt{2 \cdot C}}{t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+64}:\\
\;\;\;\;\sqrt{\frac{F \cdot \left(\left(A + C\right) + \mathsf{hypot}\left(B\_m, A - C\right)\right)}{\mathsf{fma}\left(B\_m, B\_m, C \cdot \left(A \cdot -4\right)\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+75}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e-262 or 1.00000000000000002e64 < (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000002e75Initial program 20.8%
Taylor expanded in A around -inf 26.3%
if 2.00000000000000002e-262 < (pow.f64 B #s(literal 2 binary64)) < 1e-175Initial program 19.8%
Simplified19.9%
associate-*r*19.9%
associate-+r+19.8%
hypot-undefine19.8%
unpow219.8%
unpow219.8%
+-commutative19.8%
sqrt-prod22.4%
*-commutative22.4%
associate-*r*22.4%
associate-+l+22.4%
Applied egg-rr37.3%
associate-/l*37.5%
associate-*l*37.5%
associate-*r*37.5%
associate-+r+37.5%
Applied egg-rr37.5%
associate-*r*37.5%
distribute-frac-neg237.5%
Simplified37.5%
Taylor expanded in B around inf 18.2%
Taylor expanded in B around inf 16.0%
if 1e-175 < (pow.f64 B #s(literal 2 binary64)) < 1e-22Initial program 39.8%
Simplified47.9%
associate-*r*47.9%
associate-+r+46.7%
hypot-undefine39.8%
unpow239.8%
unpow239.8%
+-commutative39.8%
sqrt-prod39.8%
*-commutative39.8%
associate-*r*39.8%
associate-+l+40.5%
Applied egg-rr60.1%
associate-/l*59.9%
associate-*l*59.9%
associate-*r*59.9%
associate-+r+59.2%
Applied egg-rr59.2%
associate-*r*59.2%
distribute-frac-neg259.2%
Simplified59.2%
Taylor expanded in A around -inf 46.1%
if 1e-22 < (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000002e64Initial program 41.2%
associate-*l*41.2%
sqrt-prod41.2%
associate-*l*41.2%
associate-+l+41.2%
unpow241.2%
unpow241.2%
hypot-define41.9%
Applied egg-rr41.9%
Taylor expanded in F around 0 38.8%
mul-1-neg38.8%
Simplified39.2%
if 5.0000000000000002e75 < (pow.f64 B #s(literal 2 binary64)) Initial program 15.3%
Taylor expanded in A around 0 13.3%
mul-1-neg13.3%
*-commutative13.3%
distribute-rgt-neg-in13.3%
unpow213.3%
unpow213.3%
hypot-define22.5%
Simplified22.5%
*-commutative22.5%
sqrt-prod33.9%
Applied egg-rr33.9%
Final simplification31.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 (* (* 4.0 A) C))
(t_1
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 C)))
(- t_0 (pow B_m 2.0)))))
(if (<= (pow B_m 2.0) 2e-262)
t_1
(if (<= (pow B_m 2.0) 1e-175)
(*
(* (sqrt F) (* B_m (sqrt 2.0)))
(/ (- (sqrt B_m)) (fma B_m B_m (* A (* C -4.0)))))
(if (<= (pow B_m 2.0) 5e-64)
t_1
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(/ (sqrt 2.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) {
double t_0 = (4.0 * A) * C;
double t_1 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - pow(B_m, 2.0));
double tmp;
if (pow(B_m, 2.0) <= 2e-262) {
tmp = t_1;
} else if (pow(B_m, 2.0) <= 1e-175) {
tmp = (sqrt(F) * (B_m * sqrt(2.0))) * (-sqrt(B_m) / fma(B_m, B_m, (A * (C * -4.0))));
} else if (pow(B_m, 2.0) <= 5e-64) {
tmp = t_1;
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * (sqrt(2.0) / -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 = Float64(Float64(4.0 * A) * C) t_1 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * C))) / Float64(t_0 - (B_m ^ 2.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-262) tmp = t_1; elseif ((B_m ^ 2.0) <= 1e-175) tmp = Float64(Float64(sqrt(F) * Float64(B_m * sqrt(2.0))) * Float64(Float64(-sqrt(B_m)) / fma(B_m, B_m, Float64(A * Float64(C * -4.0))))); elseif ((B_m ^ 2.0) <= 5e-64) tmp = t_1; else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(sqrt(2.0) / Float64(-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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-262], t$95$1, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-175], N[(N[(N[Sqrt[F], $MachinePrecision] * N[(B$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((-N[Sqrt[B$95$m], $MachinePrecision]) / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-64], t$95$1, N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $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 := \left(4 \cdot A\right) \cdot C\\
t_1 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{-175}:\\
\;\;\;\;\left(\sqrt{F} \cdot \left(B\_m \cdot \sqrt{2}\right)\right) \cdot \frac{-\sqrt{B\_m}}{\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-64}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e-262 or 1e-175 < (pow.f64 B #s(literal 2 binary64)) < 5.00000000000000033e-64Initial program 25.4%
Taylor expanded in A around -inf 32.6%
if 2.00000000000000002e-262 < (pow.f64 B #s(literal 2 binary64)) < 1e-175Initial program 19.8%
Simplified19.9%
associate-*r*19.9%
associate-+r+19.8%
hypot-undefine19.8%
unpow219.8%
unpow219.8%
+-commutative19.8%
sqrt-prod22.4%
*-commutative22.4%
associate-*r*22.4%
associate-+l+22.4%
Applied egg-rr37.3%
associate-/l*37.5%
associate-*l*37.5%
associate-*r*37.5%
associate-+r+37.5%
Applied egg-rr37.5%
associate-*r*37.5%
distribute-frac-neg237.5%
Simplified37.5%
Taylor expanded in B around inf 18.2%
Taylor expanded in B around inf 16.0%
if 5.00000000000000033e-64 < (pow.f64 B #s(literal 2 binary64)) Initial program 20.3%
Taylor expanded in A around 0 12.3%
mul-1-neg12.3%
*-commutative12.3%
distribute-rgt-neg-in12.3%
unpow212.3%
unpow212.3%
hypot-define19.7%
Simplified19.7%
*-commutative19.7%
sqrt-prod28.7%
Applied egg-rr28.7%
Final simplification29.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 (* (* 4.0 A) C)))
(if (<= (pow B_m 2.0) 1e-17)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 C)))
(- t_0 (pow B_m 2.0)))
(if (<= (pow B_m 2.0) 2e+140)
(* (/ (sqrt 2.0) B_m) (- (pow (* F (+ C (hypot B_m C))) 0.5)))
(* (pow (/ B_m (sqrt 2.0)) -1.0) (* (sqrt F) (- (sqrt (+ B_m C)))))))))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 = (4.0 * A) * C;
double tmp;
if (pow(B_m, 2.0) <= 1e-17) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 2e+140) {
tmp = (sqrt(2.0) / B_m) * -pow((F * (C + hypot(B_m, C))), 0.5);
} else {
tmp = pow((B_m / sqrt(2.0)), -1.0) * (sqrt(F) * -sqrt((B_m + C)));
}
return tmp;
}
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 = (4.0 * A) * C;
double tmp;
if (Math.pow(B_m, 2.0) <= 1e-17) {
tmp = Math.sqrt(((2.0 * ((Math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - Math.pow(B_m, 2.0));
} else if (Math.pow(B_m, 2.0) <= 2e+140) {
tmp = (Math.sqrt(2.0) / B_m) * -Math.pow((F * (C + Math.hypot(B_m, C))), 0.5);
} else {
tmp = Math.pow((B_m / Math.sqrt(2.0)), -1.0) * (Math.sqrt(F) * -Math.sqrt((B_m + C)));
}
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 = (4.0 * A) * C tmp = 0 if math.pow(B_m, 2.0) <= 1e-17: tmp = math.sqrt(((2.0 * ((math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - math.pow(B_m, 2.0)) elif math.pow(B_m, 2.0) <= 2e+140: tmp = (math.sqrt(2.0) / B_m) * -math.pow((F * (C + math.hypot(B_m, C))), 0.5) else: tmp = math.pow((B_m / math.sqrt(2.0)), -1.0) * (math.sqrt(F) * -math.sqrt((B_m + C))) 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(Float64(4.0 * A) * C) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-17) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * C))) / Float64(t_0 - (B_m ^ 2.0))); elseif ((B_m ^ 2.0) <= 2e+140) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-(Float64(F * Float64(C + hypot(B_m, C))) ^ 0.5))); else tmp = Float64((Float64(B_m / sqrt(2.0)) ^ -1.0) * Float64(sqrt(F) * Float64(-sqrt(Float64(B_m + C))))); 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 = (4.0 * A) * C;
tmp = 0.0;
if ((B_m ^ 2.0) <= 1e-17)
tmp = sqrt(((2.0 * (((B_m ^ 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - (B_m ^ 2.0));
elseif ((B_m ^ 2.0) <= 2e+140)
tmp = (sqrt(2.0) / B_m) * -((F * (C + hypot(B_m, C))) ^ 0.5);
else
tmp = ((B_m / sqrt(2.0)) ^ -1.0) * (sqrt(F) * -sqrt((B_m + C)));
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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-17], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+140], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Power[N[(F * N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision])), $MachinePrecision], N[(N[Power[N[(B$95$m / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * N[(N[Sqrt[F], $MachinePrecision] * (-N[Sqrt[N[(B$95$m + C), $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 := \left(4 \cdot A\right) \cdot C\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-17}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+140}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-{\left(F \cdot \left(C + \mathsf{hypot}\left(B\_m, C\right)\right)\right)}^{0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{B\_m}{\sqrt{2}}\right)}^{-1} \cdot \left(\sqrt{F} \cdot \left(-\sqrt{B\_m + C}\right)\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000007e-17Initial program 25.4%
Taylor expanded in A around -inf 28.7%
if 1.00000000000000007e-17 < (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000012e140Initial program 41.3%
Taylor expanded in A around 0 7.3%
mul-1-neg7.3%
*-commutative7.3%
distribute-rgt-neg-in7.3%
unpow27.3%
unpow27.3%
hypot-define8.0%
Simplified8.0%
pow1/28.0%
Applied egg-rr8.0%
if 2.00000000000000012e140 < (pow.f64 B #s(literal 2 binary64)) Initial program 9.9%
Taylor expanded in A around 0 14.2%
mul-1-neg14.2%
*-commutative14.2%
distribute-rgt-neg-in14.2%
unpow214.2%
unpow214.2%
hypot-define25.0%
Simplified25.0%
*-commutative25.0%
sqrt-prod38.4%
Applied egg-rr38.4%
clear-num38.5%
inv-pow38.5%
Applied egg-rr38.5%
Taylor expanded in C around 0 36.3%
Final simplification28.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 (* (* 4.0 A) C))
(t_1 (+ A (+ C (hypot B_m (- A C)))))
(t_2 (fma B_m B_m (* A (* C -4.0))))
(t_3 (+ (* -0.5 (/ (pow B_m 2.0) A)) (* 2.0 C)))
(t_4 (- t_2))
(t_5 (* F t_2))
(t_6 (sqrt (* 2.0 t_5))))
(if (<= B_m 1.5e-128)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) t_3))
(- t_0 (pow B_m 2.0)))
(if (<= B_m 2.8e-96)
(* (sqrt (* F (/ t_1 (fma -4.0 (* A C) (pow B_m 2.0))))) (- (sqrt 2.0)))
(if (<= B_m 3.5e-78)
(* (/ (sqrt (+ (+ A C) (hypot (- A C) B_m))) t_2) (- t_6))
(if (<= B_m 9.6e-16)
(/
(* (sqrt (* 2.0 (* F (fma B_m B_m (* -4.0 (* A C)))))) (sqrt t_3))
t_4)
(if (<= B_m 3.8e+20)
(/ (sqrt (* t_5 (* 2.0 t_1))) t_4)
(if (<= B_m 4.3e+20)
(* t_6 (* -0.25 (* (/ (sqrt 2.0) A) (- (sqrt (/ 1.0 C))))))
(*
(* (sqrt F) (sqrt (+ C (hypot B_m C))))
(- (pow (/ B_m (sqrt 2.0)) -1.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 = (4.0 * A) * C;
double t_1 = A + (C + hypot(B_m, (A - C)));
double t_2 = fma(B_m, B_m, (A * (C * -4.0)));
double t_3 = (-0.5 * (pow(B_m, 2.0) / A)) + (2.0 * C);
double t_4 = -t_2;
double t_5 = F * t_2;
double t_6 = sqrt((2.0 * t_5));
double tmp;
if (B_m <= 1.5e-128) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * t_3)) / (t_0 - pow(B_m, 2.0));
} else if (B_m <= 2.8e-96) {
tmp = sqrt((F * (t_1 / fma(-4.0, (A * C), pow(B_m, 2.0))))) * -sqrt(2.0);
} else if (B_m <= 3.5e-78) {
tmp = (sqrt(((A + C) + hypot((A - C), B_m))) / t_2) * -t_6;
} else if (B_m <= 9.6e-16) {
tmp = (sqrt((2.0 * (F * fma(B_m, B_m, (-4.0 * (A * C)))))) * sqrt(t_3)) / t_4;
} else if (B_m <= 3.8e+20) {
tmp = sqrt((t_5 * (2.0 * t_1))) / t_4;
} else if (B_m <= 4.3e+20) {
tmp = t_6 * (-0.25 * ((sqrt(2.0) / A) * -sqrt((1.0 / C))));
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * -pow((B_m / sqrt(2.0)), -1.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 = Float64(Float64(4.0 * A) * C) t_1 = Float64(A + Float64(C + hypot(B_m, Float64(A - C)))) t_2 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_3 = Float64(Float64(-0.5 * Float64((B_m ^ 2.0) / A)) + Float64(2.0 * C)) t_4 = Float64(-t_2) t_5 = Float64(F * t_2) t_6 = sqrt(Float64(2.0 * t_5)) tmp = 0.0 if (B_m <= 1.5e-128) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * t_3)) / Float64(t_0 - (B_m ^ 2.0))); elseif (B_m <= 2.8e-96) tmp = Float64(sqrt(Float64(F * Float64(t_1 / fma(-4.0, Float64(A * C), (B_m ^ 2.0))))) * Float64(-sqrt(2.0))); elseif (B_m <= 3.5e-78) tmp = Float64(Float64(sqrt(Float64(Float64(A + C) + hypot(Float64(A - C), B_m))) / t_2) * Float64(-t_6)); elseif (B_m <= 9.6e-16) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(F * fma(B_m, B_m, Float64(-4.0 * Float64(A * C)))))) * sqrt(t_3)) / t_4); elseif (B_m <= 3.8e+20) tmp = Float64(sqrt(Float64(t_5 * Float64(2.0 * t_1))) / t_4); elseif (B_m <= 4.3e+20) tmp = Float64(t_6 * Float64(-0.25 * Float64(Float64(sqrt(2.0) / A) * Float64(-sqrt(Float64(1.0 / C)))))); else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(-(Float64(B_m / sqrt(2.0)) ^ -1.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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(A + N[(C + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = (-t$95$2)}, Block[{t$95$5 = N[(F * t$95$2), $MachinePrecision]}, Block[{t$95$6 = N[Sqrt[N[(2.0 * t$95$5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[B$95$m, 1.5e-128], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 2.8e-96], N[(N[Sqrt[N[(F * N[(t$95$1 / N[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 3.5e-78], N[(N[(N[Sqrt[N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision] * (-t$95$6)), $MachinePrecision], If[LessEqual[B$95$m, 9.6e-16], N[(N[(N[Sqrt[N[(2.0 * N[(F * N[(B$95$m * B$95$m + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[t$95$3], $MachinePrecision]), $MachinePrecision] / t$95$4), $MachinePrecision], If[LessEqual[B$95$m, 3.8e+20], N[(N[Sqrt[N[(t$95$5 * N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4), $MachinePrecision], If[LessEqual[B$95$m, 4.3e+20], N[(t$95$6 * N[(-0.25 * N[(N[(N[Sqrt[2.0], $MachinePrecision] / A), $MachinePrecision] * (-N[Sqrt[N[(1.0 / C), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * (-N[Power[N[(B$95$m / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], -1.0], $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 := \left(4 \cdot A\right) \cdot C\\
t_1 := A + \left(C + \mathsf{hypot}\left(B\_m, A - C\right)\right)\\
t_2 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_3 := -0.5 \cdot \frac{{B\_m}^{2}}{A} + 2 \cdot C\\
t_4 := -t\_2\\
t_5 := F \cdot t\_2\\
t_6 := \sqrt{2 \cdot t\_5}\\
\mathbf{if}\;B\_m \leq 1.5 \cdot 10^{-128}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot t\_3}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;B\_m \leq 2.8 \cdot 10^{-96}:\\
\;\;\;\;\sqrt{F \cdot \frac{t\_1}{\mathsf{fma}\left(-4, A \cdot C, {B\_m}^{2}\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;B\_m \leq 3.5 \cdot 10^{-78}:\\
\;\;\;\;\frac{\sqrt{\left(A + C\right) + \mathsf{hypot}\left(A - C, B\_m\right)}}{t\_2} \cdot \left(-t\_6\right)\\
\mathbf{elif}\;B\_m \leq 9.6 \cdot 10^{-16}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B\_m, B\_m, -4 \cdot \left(A \cdot C\right)\right)\right)} \cdot \sqrt{t\_3}}{t\_4}\\
\mathbf{elif}\;B\_m \leq 3.8 \cdot 10^{+20}:\\
\;\;\;\;\frac{\sqrt{t\_5 \cdot \left(2 \cdot t\_1\right)}}{t\_4}\\
\mathbf{elif}\;B\_m \leq 4.3 \cdot 10^{+20}:\\
\;\;\;\;t\_6 \cdot \left(-0.25 \cdot \left(\frac{\sqrt{2}}{A} \cdot \left(-\sqrt{\frac{1}{C}}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \left(-{\left(\frac{B\_m}{\sqrt{2}}\right)}^{-1}\right)\\
\end{array}
\end{array}
if B < 1.49999999999999989e-128Initial program 22.8%
Taylor expanded in A around -inf 19.6%
if 1.49999999999999989e-128 < B < 2.80000000000000015e-96Initial program 12.3%
Taylor expanded in F around 0 26.2%
mul-1-neg26.2%
*-commutative26.2%
distribute-rgt-neg-in26.2%
associate-/l*49.8%
cancel-sign-sub-inv49.8%
metadata-eval49.8%
+-commutative49.8%
Simplified51.9%
if 2.80000000000000015e-96 < B < 3.4999999999999999e-78Initial program 20.5%
Simplified36.4%
associate-*r*36.4%
associate-+r+36.4%
hypot-undefine20.5%
unpow220.5%
unpow220.5%
+-commutative20.5%
sqrt-prod20.3%
*-commutative20.3%
associate-*r*20.3%
associate-+l+20.3%
Applied egg-rr82.9%
associate-/l*83.7%
associate-*l*83.7%
associate-*r*83.7%
associate-+r+83.7%
Applied egg-rr83.7%
associate-*r*83.7%
distribute-frac-neg283.7%
Simplified83.7%
if 3.4999999999999999e-78 < B < 9.60000000000000019e-16Initial program 58.8%
Simplified58.8%
associate-*r*58.8%
associate-+r+58.8%
hypot-undefine58.8%
unpow258.8%
unpow258.8%
+-commutative58.8%
sqrt-prod58.3%
*-commutative58.3%
associate-*r*58.3%
associate-+l+58.3%
Applied egg-rr85.3%
Taylor expanded in A around -inf 44.3%
if 9.60000000000000019e-16 < B < 3.8e20Initial program 49.6%
Simplified55.1%
if 3.8e20 < B < 4.3e20Initial program 22.3%
Simplified27.3%
associate-*r*27.3%
associate-+r+26.4%
hypot-undefine22.3%
unpow222.3%
unpow222.3%
+-commutative22.3%
sqrt-prod23.8%
*-commutative23.8%
associate-*r*23.8%
associate-+l+24.0%
Applied egg-rr32.6%
associate-/l*32.6%
associate-*l*32.6%
associate-*r*32.6%
associate-+r+32.2%
Applied egg-rr32.2%
associate-*r*32.2%
distribute-frac-neg232.2%
Simplified32.2%
Taylor expanded in A around -inf 14.1%
if 4.3e20 < B Initial program 15.4%
Taylor expanded in A around 0 25.4%
mul-1-neg25.4%
*-commutative25.4%
distribute-rgt-neg-in25.4%
unpow225.4%
unpow225.4%
hypot-define41.5%
Simplified41.5%
*-commutative41.5%
sqrt-prod62.4%
Applied egg-rr62.4%
clear-num62.5%
inv-pow62.5%
Applied egg-rr62.5%
Final simplification32.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 (* (* 4.0 A) C)))
(if (<= (pow B_m 2.0) 1e-17)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 C)))
(- t_0 (pow B_m 2.0)))
(if (<= (pow B_m 2.0) 2e+140)
(* (/ (sqrt 2.0) B_m) (- (pow (* F (+ C (hypot B_m C))) 0.5)))
(- (* (sqrt 2.0) (/ (sqrt F) (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 = (4.0 * A) * C;
double tmp;
if (pow(B_m, 2.0) <= 1e-17) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 2e+140) {
tmp = (sqrt(2.0) / B_m) * -pow((F * (C + hypot(B_m, C))), 0.5);
} else {
tmp = -(sqrt(2.0) * (sqrt(F) / sqrt(B_m)));
}
return tmp;
}
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 = (4.0 * A) * C;
double tmp;
if (Math.pow(B_m, 2.0) <= 1e-17) {
tmp = Math.sqrt(((2.0 * ((Math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - Math.pow(B_m, 2.0));
} else if (Math.pow(B_m, 2.0) <= 2e+140) {
tmp = (Math.sqrt(2.0) / B_m) * -Math.pow((F * (C + Math.hypot(B_m, C))), 0.5);
} else {
tmp = -(Math.sqrt(2.0) * (Math.sqrt(F) / 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 = (4.0 * A) * C tmp = 0 if math.pow(B_m, 2.0) <= 1e-17: tmp = math.sqrt(((2.0 * ((math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - math.pow(B_m, 2.0)) elif math.pow(B_m, 2.0) <= 2e+140: tmp = (math.sqrt(2.0) / B_m) * -math.pow((F * (C + math.hypot(B_m, C))), 0.5) else: tmp = -(math.sqrt(2.0) * (math.sqrt(F) / 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 = Float64(Float64(4.0 * A) * C) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-17) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * C))) / Float64(t_0 - (B_m ^ 2.0))); elseif ((B_m ^ 2.0) <= 2e+140) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-(Float64(F * Float64(C + hypot(B_m, C))) ^ 0.5))); else tmp = Float64(-Float64(sqrt(2.0) * Float64(sqrt(F) / 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 = (4.0 * A) * C;
tmp = 0.0;
if ((B_m ^ 2.0) <= 1e-17)
tmp = sqrt(((2.0 * (((B_m ^ 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - (B_m ^ 2.0));
elseif ((B_m ^ 2.0) <= 2e+140)
tmp = (sqrt(2.0) / B_m) * -((F * (C + hypot(B_m, C))) ^ 0.5);
else
tmp = -(sqrt(2.0) * (sqrt(F) / 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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-17], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+140], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Power[N[(F * N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision])), $MachinePrecision], (-N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sqrt[F], $MachinePrecision] / N[Sqrt[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])\\
\\
\begin{array}{l}
t_0 := \left(4 \cdot A\right) \cdot C\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-17}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+140}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-{\left(F \cdot \left(C + \mathsf{hypot}\left(B\_m, C\right)\right)\right)}^{0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{2} \cdot \frac{\sqrt{F}}{\sqrt{B\_m}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000007e-17Initial program 25.4%
Taylor expanded in A around -inf 28.7%
if 1.00000000000000007e-17 < (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000012e140Initial program 41.3%
Taylor expanded in A around 0 7.3%
mul-1-neg7.3%
*-commutative7.3%
distribute-rgt-neg-in7.3%
unpow27.3%
unpow27.3%
hypot-define8.0%
Simplified8.0%
pow1/28.0%
Applied egg-rr8.0%
if 2.00000000000000012e140 < (pow.f64 B #s(literal 2 binary64)) Initial program 9.9%
Taylor expanded in B around inf 29.8%
mul-1-neg29.8%
*-commutative29.8%
distribute-rgt-neg-in29.8%
Simplified29.8%
sqrt-div36.5%
Applied egg-rr36.5%
Final simplification28.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 (* (* 4.0 A) C)))
(if (<= (pow B_m 2.0) 5e-68)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 C)))
(- t_0 (pow B_m 2.0)))
(* (* (sqrt F) (sqrt (+ C (hypot B_m C)))) (/ (sqrt 2.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) {
double t_0 = (4.0 * A) * C;
double tmp;
if (pow(B_m, 2.0) <= 5e-68) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - pow(B_m, 2.0));
} else {
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * (sqrt(2.0) / -B_m);
}
return tmp;
}
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 = (4.0 * A) * C;
double tmp;
if (Math.pow(B_m, 2.0) <= 5e-68) {
tmp = Math.sqrt(((2.0 * ((Math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - Math.pow(B_m, 2.0));
} else {
tmp = (Math.sqrt(F) * Math.sqrt((C + Math.hypot(B_m, C)))) * (Math.sqrt(2.0) / -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 = (4.0 * A) * C tmp = 0 if math.pow(B_m, 2.0) <= 5e-68: tmp = math.sqrt(((2.0 * ((math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - math.pow(B_m, 2.0)) else: tmp = (math.sqrt(F) * math.sqrt((C + math.hypot(B_m, C)))) * (math.sqrt(2.0) / -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 = Float64(Float64(4.0 * A) * C) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-68) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * C))) / Float64(t_0 - (B_m ^ 2.0))); else tmp = Float64(Float64(sqrt(F) * sqrt(Float64(C + hypot(B_m, C)))) * Float64(sqrt(2.0) / Float64(-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 = (4.0 * A) * C;
tmp = 0.0;
if ((B_m ^ 2.0) <= 5e-68)
tmp = sqrt(((2.0 * (((B_m ^ 2.0) - t_0) * F)) * (2.0 * C))) / (t_0 - (B_m ^ 2.0));
else
tmp = (sqrt(F) * sqrt((C + hypot(B_m, C)))) * (sqrt(2.0) / -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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-68], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $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 := \left(4 \cdot A\right) \cdot C\\
\mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{-68}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C + \mathsf{hypot}\left(B\_m, C\right)}\right) \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999971e-68Initial program 23.9%
Taylor expanded in A around -inf 29.0%
if 4.99999999999999971e-68 < (pow.f64 B #s(literal 2 binary64)) Initial program 20.9%
Taylor expanded in A around 0 12.2%
mul-1-neg12.2%
*-commutative12.2%
distribute-rgt-neg-in12.2%
unpow212.2%
unpow212.2%
hypot-define19.5%
Simplified19.5%
*-commutative19.5%
sqrt-prod28.5%
Applied egg-rr28.5%
Final simplification28.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 (<= C 3.5e-12) (- (* (sqrt 2.0) (/ (sqrt F) (sqrt B_m)))) (* (/ (sqrt 2.0) B_m) (- (pow (* F (+ C (hypot B_m C))) 0.5)))))
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 (C <= 3.5e-12) {
tmp = -(sqrt(2.0) * (sqrt(F) / sqrt(B_m)));
} else {
tmp = (sqrt(2.0) / B_m) * -pow((F * (C + hypot(B_m, C))), 0.5);
}
return tmp;
}
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 (C <= 3.5e-12) {
tmp = -(Math.sqrt(2.0) * (Math.sqrt(F) / Math.sqrt(B_m)));
} else {
tmp = (Math.sqrt(2.0) / B_m) * -Math.pow((F * (C + Math.hypot(B_m, C))), 0.5);
}
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 C <= 3.5e-12: tmp = -(math.sqrt(2.0) * (math.sqrt(F) / math.sqrt(B_m))) else: tmp = (math.sqrt(2.0) / B_m) * -math.pow((F * (C + math.hypot(B_m, C))), 0.5) 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 (C <= 3.5e-12) tmp = Float64(-Float64(sqrt(2.0) * Float64(sqrt(F) / sqrt(B_m)))); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-(Float64(F * Float64(C + hypot(B_m, C))) ^ 0.5))); 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 (C <= 3.5e-12)
tmp = -(sqrt(2.0) * (sqrt(F) / sqrt(B_m)));
else
tmp = (sqrt(2.0) / B_m) * -((F * (C + hypot(B_m, C))) ^ 0.5);
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[C, 3.5e-12], (-N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sqrt[F], $MachinePrecision] / N[Sqrt[B$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Power[N[(F * N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $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}\;C \leq 3.5 \cdot 10^{-12}:\\
\;\;\;\;-\sqrt{2} \cdot \frac{\sqrt{F}}{\sqrt{B\_m}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-{\left(F \cdot \left(C + \mathsf{hypot}\left(B\_m, C\right)\right)\right)}^{0.5}\right)\\
\end{array}
\end{array}
if C < 3.5e-12Initial program 18.6%
Taylor expanded in B around inf 15.7%
mul-1-neg15.7%
*-commutative15.7%
distribute-rgt-neg-in15.7%
Simplified15.7%
sqrt-div19.1%
Applied egg-rr19.1%
if 3.5e-12 < C Initial program 31.0%
Taylor expanded in A around 0 5.0%
mul-1-neg5.0%
*-commutative5.0%
distribute-rgt-neg-in5.0%
unpow25.0%
unpow25.0%
hypot-define9.2%
Simplified9.2%
pow1/29.3%
Applied egg-rr9.3%
Final simplification16.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 (<= C 9.5e-12) (- (* (sqrt 2.0) (/ (sqrt F) (sqrt B_m)))) (* (/ (sqrt 2.0) (- B_m)) (sqrt (* F (+ C (hypot B_m C)))))))
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 (C <= 9.5e-12) {
tmp = -(sqrt(2.0) * (sqrt(F) / sqrt(B_m)));
} else {
tmp = (sqrt(2.0) / -B_m) * sqrt((F * (C + hypot(B_m, C))));
}
return tmp;
}
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 (C <= 9.5e-12) {
tmp = -(Math.sqrt(2.0) * (Math.sqrt(F) / Math.sqrt(B_m)));
} else {
tmp = (Math.sqrt(2.0) / -B_m) * Math.sqrt((F * (C + Math.hypot(B_m, C))));
}
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 C <= 9.5e-12: tmp = -(math.sqrt(2.0) * (math.sqrt(F) / math.sqrt(B_m))) else: tmp = (math.sqrt(2.0) / -B_m) * math.sqrt((F * (C + math.hypot(B_m, C)))) 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 (C <= 9.5e-12) tmp = Float64(-Float64(sqrt(2.0) * Float64(sqrt(F) / sqrt(B_m)))); else tmp = Float64(Float64(sqrt(2.0) / Float64(-B_m)) * sqrt(Float64(F * Float64(C + hypot(B_m, C))))); 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 (C <= 9.5e-12)
tmp = -(sqrt(2.0) * (sqrt(F) / sqrt(B_m)));
else
tmp = (sqrt(2.0) / -B_m) * sqrt((F * (C + hypot(B_m, C))));
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[C, 9.5e-12], (-N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sqrt[F], $MachinePrecision] / N[Sqrt[B$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision] * N[Sqrt[N[(F * N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 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}\;C \leq 9.5 \cdot 10^{-12}:\\
\;\;\;\;-\sqrt{2} \cdot \frac{\sqrt{F}}{\sqrt{B\_m}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{-B\_m} \cdot \sqrt{F \cdot \left(C + \mathsf{hypot}\left(B\_m, C\right)\right)}\\
\end{array}
\end{array}
if C < 9.4999999999999995e-12Initial program 18.5%
Taylor expanded in B around inf 15.6%
mul-1-neg15.6%
*-commutative15.6%
distribute-rgt-neg-in15.6%
Simplified15.6%
sqrt-div19.0%
Applied egg-rr19.0%
if 9.4999999999999995e-12 < C Initial program 31.3%
Taylor expanded in A around 0 5.1%
mul-1-neg5.1%
*-commutative5.1%
distribute-rgt-neg-in5.1%
unpow25.1%
unpow25.1%
hypot-define9.4%
Simplified9.4%
Final simplification16.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 (<= C 4.2e+107) (- (* (sqrt 2.0) (/ (sqrt F) (sqrt B_m)))) (* (* (sqrt F) (sqrt C)) (/ -2.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) {
double tmp;
if (C <= 4.2e+107) {
tmp = -(sqrt(2.0) * (sqrt(F) / sqrt(B_m)));
} else {
tmp = (sqrt(F) * sqrt(C)) * (-2.0 / B_m);
}
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 (c <= 4.2d+107) then
tmp = -(sqrt(2.0d0) * (sqrt(f) / sqrt(b_m)))
else
tmp = (sqrt(f) * sqrt(c)) * ((-2.0d0) / 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 (C <= 4.2e+107) {
tmp = -(Math.sqrt(2.0) * (Math.sqrt(F) / Math.sqrt(B_m)));
} else {
tmp = (Math.sqrt(F) * Math.sqrt(C)) * (-2.0 / 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 C <= 4.2e+107: tmp = -(math.sqrt(2.0) * (math.sqrt(F) / math.sqrt(B_m))) else: tmp = (math.sqrt(F) * math.sqrt(C)) * (-2.0 / 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 (C <= 4.2e+107) tmp = Float64(-Float64(sqrt(2.0) * Float64(sqrt(F) / sqrt(B_m)))); else tmp = Float64(Float64(sqrt(F) * sqrt(C)) * Float64(-2.0 / 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 (C <= 4.2e+107)
tmp = -(sqrt(2.0) * (sqrt(F) / sqrt(B_m)));
else
tmp = (sqrt(F) * sqrt(C)) * (-2.0 / 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[C, 4.2e+107], (-N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sqrt[F], $MachinePrecision] / N[Sqrt[B$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[C], $MachinePrecision]), $MachinePrecision] * N[(-2.0 / B$95$m), $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}\;C \leq 4.2 \cdot 10^{+107}:\\
\;\;\;\;-\sqrt{2} \cdot \frac{\sqrt{F}}{\sqrt{B\_m}}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C}\right) \cdot \frac{-2}{B\_m}\\
\end{array}
\end{array}
if C < 4.1999999999999999e107Initial program 23.7%
Taylor expanded in B around inf 15.4%
mul-1-neg15.4%
*-commutative15.4%
distribute-rgt-neg-in15.4%
Simplified15.4%
sqrt-div18.4%
Applied egg-rr18.4%
if 4.1999999999999999e107 < C Initial program 16.2%
Taylor expanded in A around 0 3.1%
mul-1-neg3.1%
*-commutative3.1%
distribute-rgt-neg-in3.1%
unpow23.1%
unpow23.1%
hypot-define5.9%
Simplified5.9%
Taylor expanded in C around inf 3.9%
mul-1-neg3.9%
*-commutative3.9%
distribute-rgt-neg-in3.9%
*-commutative3.9%
mul-1-neg3.9%
unpow23.9%
rem-square-sqrt4.0%
associate-*r/4.0%
metadata-eval4.0%
Simplified4.0%
sqrt-prod4.1%
Applied egg-rr4.1%
Final simplification15.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 (if (<= F 6e-133) (* (/ (sqrt 2.0) B_m) (- (sqrt (* B_m F)))) (- (sqrt (* 2.0 (/ F 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 (F <= 6e-133) {
tmp = (sqrt(2.0) / B_m) * -sqrt((B_m * F));
} else {
tmp = -sqrt((2.0 * (F / B_m)));
}
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 (f <= 6d-133) then
tmp = (sqrt(2.0d0) / b_m) * -sqrt((b_m * f))
else
tmp = -sqrt((2.0d0 * (f / 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 (F <= 6e-133) {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((B_m * F));
} else {
tmp = -Math.sqrt((2.0 * (F / 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 F <= 6e-133: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((B_m * F)) else: tmp = -math.sqrt((2.0 * (F / 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 (F <= 6e-133) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(B_m * F)))); else tmp = Float64(-sqrt(Float64(2.0 * Float64(F / 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 (F <= 6e-133)
tmp = (sqrt(2.0) / B_m) * -sqrt((B_m * F));
else
tmp = -sqrt((2.0 * (F / 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[F, 6e-133], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(B$95$m * F), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], (-N[Sqrt[N[(2.0 * N[(F / 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])\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq 6 \cdot 10^{-133}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{B\_m \cdot F}\right)\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{2 \cdot \frac{F}{B\_m}}\\
\end{array}
\end{array}
if F < 6.00000000000000038e-133Initial program 31.8%
Taylor expanded in A around 0 8.2%
mul-1-neg8.2%
*-commutative8.2%
distribute-rgt-neg-in8.2%
unpow28.2%
unpow28.2%
hypot-define11.6%
Simplified11.6%
Taylor expanded in C around 0 12.5%
*-commutative12.5%
Simplified12.5%
if 6.00000000000000038e-133 < F Initial program 15.4%
Taylor expanded in B around inf 17.8%
mul-1-neg17.8%
*-commutative17.8%
distribute-rgt-neg-in17.8%
Simplified17.8%
pow117.8%
distribute-rgt-neg-out17.8%
pow1/217.8%
pow1/217.9%
pow-prod-down18.0%
Applied egg-rr18.0%
unpow118.0%
unpow1/217.9%
Simplified17.9%
Final simplification15.6%
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 (<= C 7.2e+105) (- (pow (* 2.0 (/ F B_m)) 0.5)) (* (* (sqrt F) (sqrt C)) (/ -2.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) {
double tmp;
if (C <= 7.2e+105) {
tmp = -pow((2.0 * (F / B_m)), 0.5);
} else {
tmp = (sqrt(F) * sqrt(C)) * (-2.0 / B_m);
}
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 (c <= 7.2d+105) then
tmp = -((2.0d0 * (f / b_m)) ** 0.5d0)
else
tmp = (sqrt(f) * sqrt(c)) * ((-2.0d0) / 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 (C <= 7.2e+105) {
tmp = -Math.pow((2.0 * (F / B_m)), 0.5);
} else {
tmp = (Math.sqrt(F) * Math.sqrt(C)) * (-2.0 / 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 C <= 7.2e+105: tmp = -math.pow((2.0 * (F / B_m)), 0.5) else: tmp = (math.sqrt(F) * math.sqrt(C)) * (-2.0 / 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 (C <= 7.2e+105) tmp = Float64(-(Float64(2.0 * Float64(F / B_m)) ^ 0.5)); else tmp = Float64(Float64(sqrt(F) * sqrt(C)) * Float64(-2.0 / 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 (C <= 7.2e+105)
tmp = -((2.0 * (F / B_m)) ^ 0.5);
else
tmp = (sqrt(F) * sqrt(C)) * (-2.0 / 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[C, 7.2e+105], (-N[Power[N[(2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[C], $MachinePrecision]), $MachinePrecision] * N[(-2.0 / B$95$m), $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}\;C \leq 7.2 \cdot 10^{+105}:\\
\;\;\;\;-{\left(2 \cdot \frac{F}{B\_m}\right)}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{F} \cdot \sqrt{C}\right) \cdot \frac{-2}{B\_m}\\
\end{array}
\end{array}
if C < 7.1999999999999998e105Initial program 23.7%
Taylor expanded in B around inf 15.4%
mul-1-neg15.4%
*-commutative15.4%
distribute-rgt-neg-in15.4%
Simplified15.4%
distribute-rgt-neg-out15.4%
pow1/215.4%
pow1/215.5%
pow-prod-down15.6%
Applied egg-rr15.6%
if 7.1999999999999998e105 < C Initial program 16.2%
Taylor expanded in A around 0 3.1%
mul-1-neg3.1%
*-commutative3.1%
distribute-rgt-neg-in3.1%
unpow23.1%
unpow23.1%
hypot-define5.9%
Simplified5.9%
Taylor expanded in C around inf 3.9%
mul-1-neg3.9%
*-commutative3.9%
distribute-rgt-neg-in3.9%
*-commutative3.9%
mul-1-neg3.9%
unpow23.9%
rem-square-sqrt4.0%
associate-*r/4.0%
metadata-eval4.0%
Simplified4.0%
sqrt-prod4.1%
Applied egg-rr4.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 (- (pow (* 2.0 (/ F B_m)) 0.5)))
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 -pow((2.0 * (F / B_m)), 0.5);
}
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 * (f / b_m)) ** 0.5d0)
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 -Math.pow((2.0 * (F / B_m)), 0.5);
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return -math.pow((2.0 * (F / B_m)), 0.5)
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(-(Float64(2.0 * Float64(F / B_m)) ^ 0.5)) 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 * (F / B_m)) ^ 0.5);
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[Power[N[(2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision])
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
-{\left(2 \cdot \frac{F}{B\_m}\right)}^{0.5}
\end{array}
Initial program 22.3%
Taylor expanded in B around inf 13.4%
mul-1-neg13.4%
*-commutative13.4%
distribute-rgt-neg-in13.4%
Simplified13.4%
distribute-rgt-neg-out13.4%
pow1/213.4%
pow1/213.5%
pow-prod-down13.6%
Applied egg-rr13.6%
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 (- (sqrt (* 2.0 (/ F 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 -sqrt((2.0 * (F / 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 = -sqrt((2.0d0 * (f / 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 -Math.sqrt((2.0 * (F / 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 -math.sqrt((2.0 * (F / 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(-sqrt(Float64(2.0 * Float64(F / 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 = -sqrt((2.0 * (F / 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[Sqrt[N[(2.0 * N[(F / 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])\\
\\
-\sqrt{2 \cdot \frac{F}{B\_m}}
\end{array}
Initial program 22.3%
Taylor expanded in B around inf 13.4%
mul-1-neg13.4%
*-commutative13.4%
distribute-rgt-neg-in13.4%
Simplified13.4%
pow113.4%
distribute-rgt-neg-out13.4%
pow1/213.4%
pow1/213.5%
pow-prod-down13.6%
Applied egg-rr13.6%
unpow113.6%
unpow1/213.5%
Simplified13.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 (sqrt (* F (/ 2.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 sqrt((F * (2.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 = sqrt((f * (2.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 Math.sqrt((F * (2.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 math.sqrt((F * (2.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 sqrt(Float64(F * Float64(2.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 = sqrt((F * (2.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[Sqrt[N[(F * N[(2.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])\\
\\
\sqrt{F \cdot \frac{2}{B\_m}}
\end{array}
Initial program 22.3%
Taylor expanded in B around inf 13.4%
mul-1-neg13.4%
*-commutative13.4%
distribute-rgt-neg-in13.4%
Simplified13.4%
pow1/213.5%
pow-to-exp12.6%
Applied egg-rr12.6%
add-sqr-sqrt0.6%
sqrt-unprod2.1%
sqr-neg2.1%
sqrt-prod2.1%
add-sqr-sqrt2.1%
pow12.1%
pow1/22.1%
exp-to-pow2.3%
pow-prod-down2.3%
Applied egg-rr2.3%
unpow12.3%
unpow1/22.1%
*-commutative2.1%
Simplified2.1%
*-commutative2.1%
associate-/l*2.1%
rem-log-exp1.9%
*-un-lft-identity1.9%
metadata-eval1.9%
log-prod1.9%
metadata-eval1.9%
metadata-eval1.9%
rem-log-exp2.1%
associate-/l*2.1%
clear-num2.2%
un-div-inv2.2%
Applied egg-rr2.2%
+-lft-identity2.2%
associate-/r/2.1%
Simplified2.1%
Final simplification2.1%
herbie shell --seed 2024107
(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))))