?

Average Accuracy: 18.6% → 41.1%
Time: 1.5min
Precision: binary64

?

\[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
\[\begin{array}{l} t_0 := -0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\ t_1 := \mathsf{hypot}\left(A - C, B\right)\\ t_2 := C \cdot \left(A \cdot -4\right)\\ t_3 := \mathsf{fma}\left(B, B, t_2\right)\\ t_4 := \sqrt[3]{t_3 \cdot \left(F + F\right)}\\ t_5 := \mathsf{hypot}\left(B, \sqrt{t_2}\right)\\ \mathbf{if}\;A \leq -9 \cdot 10^{+124}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;A \leq -1.3 \cdot 10^{-18}:\\ \;\;\;\;\frac{-\sqrt{\left(C - \left(t_1 - A\right)\right) \cdot t_4} \cdot \sqrt{{t_4}^{2}}}{t_3}\\ \mathbf{elif}\;A \leq -2.2 \cdot 10^{-93}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;A \leq 2.2 \cdot 10^{+33}:\\ \;\;\;\;\frac{-\frac{t_5}{\frac{t_5}{\left(\sqrt{\left(\left(A + C\right) - t_1\right) \cdot \sqrt[3]{F}} \cdot \left|\sqrt[3]{F}\right|\right) \cdot \sqrt{2}}}}{t_5}\\ \mathbf{else}:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(A \cdot F\right)}}{A}\\ \end{array} \]
(FPCore (A B C F)
 :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))))
(FPCore (A B C F)
 :precision binary64
 (let* ((t_0 (* -0.25 (/ (sqrt (* -16.0 (* C F))) C)))
        (t_1 (hypot (- A C) B))
        (t_2 (* C (* A -4.0)))
        (t_3 (fma B B t_2))
        (t_4 (cbrt (* t_3 (+ F F))))
        (t_5 (hypot B (sqrt t_2))))
   (if (<= A -9e+124)
     t_0
     (if (<= A -1.3e-18)
       (/ (- (* (sqrt (* (- C (- t_1 A)) t_4)) (sqrt (pow t_4 2.0)))) t_3)
       (if (<= A -2.2e-93)
         t_0
         (if (<= A 2.2e+33)
           (/
            (-
             (/
              t_5
              (/
               t_5
               (*
                (* (sqrt (* (- (+ A C) t_1) (cbrt F))) (fabs (cbrt F)))
                (sqrt 2.0)))))
            t_5)
           (* -0.25 (/ (sqrt (* -16.0 (* A F))) A))))))))
double code(double A, double B, double C, double F) {
	return -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));
}
double code(double A, double B, double C, double F) {
	double t_0 = -0.25 * (sqrt((-16.0 * (C * F))) / C);
	double t_1 = hypot((A - C), B);
	double t_2 = C * (A * -4.0);
	double t_3 = fma(B, B, t_2);
	double t_4 = cbrt((t_3 * (F + F)));
	double t_5 = hypot(B, sqrt(t_2));
	double tmp;
	if (A <= -9e+124) {
		tmp = t_0;
	} else if (A <= -1.3e-18) {
		tmp = -(sqrt(((C - (t_1 - A)) * t_4)) * sqrt(pow(t_4, 2.0))) / t_3;
	} else if (A <= -2.2e-93) {
		tmp = t_0;
	} else if (A <= 2.2e+33) {
		tmp = -(t_5 / (t_5 / ((sqrt((((A + C) - t_1) * cbrt(F))) * fabs(cbrt(F))) * sqrt(2.0)))) / t_5;
	} else {
		tmp = -0.25 * (sqrt((-16.0 * (A * F))) / A);
	}
	return tmp;
}
function code(A, B, C, F)
	return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)))
end
function code(A, B, C, F)
	t_0 = Float64(-0.25 * Float64(sqrt(Float64(-16.0 * Float64(C * F))) / C))
	t_1 = hypot(Float64(A - C), B)
	t_2 = Float64(C * Float64(A * -4.0))
	t_3 = fma(B, B, t_2)
	t_4 = cbrt(Float64(t_3 * Float64(F + F)))
	t_5 = hypot(B, sqrt(t_2))
	tmp = 0.0
	if (A <= -9e+124)
		tmp = t_0;
	elseif (A <= -1.3e-18)
		tmp = Float64(Float64(-Float64(sqrt(Float64(Float64(C - Float64(t_1 - A)) * t_4)) * sqrt((t_4 ^ 2.0)))) / t_3);
	elseif (A <= -2.2e-93)
		tmp = t_0;
	elseif (A <= 2.2e+33)
		tmp = Float64(Float64(-Float64(t_5 / Float64(t_5 / Float64(Float64(sqrt(Float64(Float64(Float64(A + C) - t_1) * cbrt(F))) * abs(cbrt(F))) * sqrt(2.0))))) / t_5);
	else
		tmp = Float64(-0.25 * Float64(sqrt(Float64(-16.0 * Float64(A * F))) / A));
	end
	return tmp
end
code[A_, B_, C_, F_] := N[((-N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision] * 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]) / N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(-0.25 * N[(N[Sqrt[N[(-16.0 * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]}, Block[{t$95$2 = N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(B * B + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[(t$95$3 * N[(F + F), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[B ^ 2 + N[Sqrt[t$95$2], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[A, -9e+124], t$95$0, If[LessEqual[A, -1.3e-18], N[((-N[(N[Sqrt[N[(N[(C - N[(t$95$1 - A), $MachinePrecision]), $MachinePrecision] * t$95$4), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Power[t$95$4, 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]) / t$95$3), $MachinePrecision], If[LessEqual[A, -2.2e-93], t$95$0, If[LessEqual[A, 2.2e+33], N[((-N[(t$95$5 / N[(t$95$5 / N[(N[(N[Sqrt[N[(N[(N[(A + C), $MachinePrecision] - t$95$1), $MachinePrecision] * N[Power[F, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Abs[N[Power[F, 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) / t$95$5), $MachinePrecision], N[(-0.25 * N[(N[Sqrt[N[(-16.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}
\begin{array}{l}
t_0 := -0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\
t_1 := \mathsf{hypot}\left(A - C, B\right)\\
t_2 := C \cdot \left(A \cdot -4\right)\\
t_3 := \mathsf{fma}\left(B, B, t_2\right)\\
t_4 := \sqrt[3]{t_3 \cdot \left(F + F\right)}\\
t_5 := \mathsf{hypot}\left(B, \sqrt{t_2}\right)\\
\mathbf{if}\;A \leq -9 \cdot 10^{+124}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;A \leq -1.3 \cdot 10^{-18}:\\
\;\;\;\;\frac{-\sqrt{\left(C - \left(t_1 - A\right)\right) \cdot t_4} \cdot \sqrt{{t_4}^{2}}}{t_3}\\

\mathbf{elif}\;A \leq -2.2 \cdot 10^{-93}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;A \leq 2.2 \cdot 10^{+33}:\\
\;\;\;\;\frac{-\frac{t_5}{\frac{t_5}{\left(\sqrt{\left(\left(A + C\right) - t_1\right) \cdot \sqrt[3]{F}} \cdot \left|\sqrt[3]{F}\right|\right) \cdot \sqrt{2}}}}{t_5}\\

\mathbf{else}:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(A \cdot F\right)}}{A}\\


\end{array}

Error?

Derivation?

  1. Split input into 4 regimes
  2. if A < -9.0000000000000008e124 or -1.3e-18 < A < -2.19999999999999996e-93

    1. Initial program 13.2%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified25.7%

      \[\leadsto \color{blue}{\frac{-\sqrt{\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F + F\right)\right) \cdot \left(C - \left(\mathsf{hypot}\left(A - C, B\right) - A\right)\right)}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}} \]
      Proof
    3. Taylor expanded in A around -inf 43.2%

      \[\leadsto \color{blue}{-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}} \]

    if -9.0000000000000008e124 < A < -1.3e-18

    1. Initial program 37.5%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified38.9%

      \[\leadsto \color{blue}{\frac{-\sqrt{\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F + F\right)\right) \cdot \left(C - \left(\mathsf{hypot}\left(A - C, B\right) - A\right)\right)}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}} \]
      Proof
    3. Applied egg-rr45.4%

      \[\leadsto \frac{-\color{blue}{\sqrt{\left(C - \left(\mathsf{hypot}\left(A - C, B\right) - A\right)\right) \cdot \sqrt[3]{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F + F\right)}} \cdot \sqrt{{\left(\sqrt[3]{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F + F\right)}\right)}^{2}}}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)} \]

    if -2.19999999999999996e-93 < A < 2.19999999999999994e33

    1. Initial program 24.2%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified29.1%

      \[\leadsto \color{blue}{\frac{-\sqrt{\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F + F\right)\right) \cdot \left(C - \left(\mathsf{hypot}\left(A - C, B\right) - A\right)\right)}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}} \]
      Proof
    3. Applied egg-rr36.1%

      \[\leadsto \color{blue}{\frac{-\frac{\mathsf{hypot}\left(B, \sqrt{C \cdot \left(A \cdot -4\right)}\right)}{\frac{\mathsf{hypot}\left(B, \sqrt{C \cdot \left(A \cdot -4\right)}\right)}{\sqrt{\left(F + F\right) \cdot \left(C - \left(\mathsf{hypot}\left(A - C, B\right) - A\right)\right)}}}}{\mathsf{hypot}\left(B, \sqrt{C \cdot \left(A \cdot -4\right)}\right)}} \]
    4. Applied egg-rr36.0%

      \[\leadsto \frac{-\frac{\mathsf{hypot}\left(B, \sqrt{C \cdot \left(A \cdot -4\right)}\right)}{\frac{\mathsf{hypot}\left(B, \sqrt{C \cdot \left(A \cdot -4\right)}\right)}{\color{blue}{\sqrt{F \cdot \left(C - \left(\mathsf{hypot}\left(A - C, B\right) - A\right)\right)} \cdot \sqrt{2}}}}}{\mathsf{hypot}\left(B, \sqrt{C \cdot \left(A \cdot -4\right)}\right)} \]
    5. Applied egg-rr42.6%

      \[\leadsto \frac{-\frac{\mathsf{hypot}\left(B, \sqrt{C \cdot \left(A \cdot -4\right)}\right)}{\frac{\mathsf{hypot}\left(B, \sqrt{C \cdot \left(A \cdot -4\right)}\right)}{\color{blue}{\left(\sqrt{\left(\left(A + C\right) - \mathsf{hypot}\left(A - C, B\right)\right) \cdot \sqrt[3]{F}} \cdot \left|\sqrt[3]{F}\right|\right)} \cdot \sqrt{2}}}}{\mathsf{hypot}\left(B, \sqrt{C \cdot \left(A \cdot -4\right)}\right)} \]

    if 2.19999999999999994e33 < A

    1. Initial program 2.8%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified7.5%

      \[\leadsto \color{blue}{\frac{-\sqrt{\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F + F\right)\right) \cdot \left(C - \left(\mathsf{hypot}\left(A - C, B\right) - A\right)\right)}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}} \]
      Proof
    3. Taylor expanded in C around -inf 34.0%

      \[\leadsto \color{blue}{-0.25 \cdot \frac{\sqrt{-16 \cdot \left(A \cdot F\right)}}{A}} \]
  3. Recombined 4 regimes into one program.

Reproduce?

herbie shell --seed 2023151 
(FPCore (A B C F)
  :name "ABCF->ab-angle b"
  :precision binary64
  (/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))