Average Error: 52.3 → 40.7
Time: 27.8s
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 := C - \mathsf{hypot}\left(B, A - C\right)\\ t_1 := -0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\ t_2 := \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\\ t_3 := t_2 \cdot \left(F \cdot 2\right)\\ \mathbf{if}\;A \leq -1.12 \cdot 10^{+177}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;A \leq -1.22 \cdot 10^{-262}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(A, t_3, t_3 \cdot t_0\right)} \cdot \frac{-1}{t_2}\\ \mathbf{elif}\;A \leq -2.1 \cdot 10^{-305}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;A \leq 1.6 \cdot 10^{+17}:\\ \;\;\;\;\frac{-{\left({t_2}^{0.25} \cdot {\left(F \cdot \left(2 \cdot \left(A + t_0\right)\right)\right)}^{0.25}\right)}^{2}}{t_2}\\ \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 (- C (hypot B (- A C))))
        (t_1 (* -0.25 (/ (sqrt (* -16.0 (* C F))) C)))
        (t_2 (fma B B (* C (* A -4.0))))
        (t_3 (* t_2 (* F 2.0))))
   (if (<= A -1.12e+177)
     t_1
     (if (<= A -1.22e-262)
       (* (sqrt (fma A t_3 (* t_3 t_0))) (/ -1.0 t_2))
       (if (<= A -2.1e-305)
         t_1
         (if (<= A 1.6e+17)
           (/
            (- (pow (* (pow t_2 0.25) (pow (* F (* 2.0 (+ A t_0))) 0.25)) 2.0))
            t_2)
           (* -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 = C - hypot(B, (A - C));
	double t_1 = -0.25 * (sqrt((-16.0 * (C * F))) / C);
	double t_2 = fma(B, B, (C * (A * -4.0)));
	double t_3 = t_2 * (F * 2.0);
	double tmp;
	if (A <= -1.12e+177) {
		tmp = t_1;
	} else if (A <= -1.22e-262) {
		tmp = sqrt(fma(A, t_3, (t_3 * t_0))) * (-1.0 / t_2);
	} else if (A <= -2.1e-305) {
		tmp = t_1;
	} else if (A <= 1.6e+17) {
		tmp = -pow((pow(t_2, 0.25) * pow((F * (2.0 * (A + t_0))), 0.25)), 2.0) / t_2;
	} 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(C - hypot(B, Float64(A - C)))
	t_1 = Float64(-0.25 * Float64(sqrt(Float64(-16.0 * Float64(C * F))) / C))
	t_2 = fma(B, B, Float64(C * Float64(A * -4.0)))
	t_3 = Float64(t_2 * Float64(F * 2.0))
	tmp = 0.0
	if (A <= -1.12e+177)
		tmp = t_1;
	elseif (A <= -1.22e-262)
		tmp = Float64(sqrt(fma(A, t_3, Float64(t_3 * t_0))) * Float64(-1.0 / t_2));
	elseif (A <= -2.1e-305)
		tmp = t_1;
	elseif (A <= 1.6e+17)
		tmp = Float64(Float64(-(Float64((t_2 ^ 0.25) * (Float64(F * Float64(2.0 * Float64(A + t_0))) ^ 0.25)) ^ 2.0)) / t_2);
	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[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.25 * N[(N[Sqrt[N[(-16.0 * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[A, -1.12e+177], t$95$1, If[LessEqual[A, -1.22e-262], N[(N[Sqrt[N[(A * t$95$3 + N[(t$95$3 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, -2.1e-305], t$95$1, If[LessEqual[A, 1.6e+17], N[((-N[Power[N[(N[Power[t$95$2, 0.25], $MachinePrecision] * N[Power[N[(F * N[(2.0 * N[(A + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]) / t$95$2), $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 := C - \mathsf{hypot}\left(B, A - C\right)\\
t_1 := -0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\
t_2 := \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\\
t_3 := t_2 \cdot \left(F \cdot 2\right)\\
\mathbf{if}\;A \leq -1.12 \cdot 10^{+177}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;A \leq -1.22 \cdot 10^{-262}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(A, t_3, t_3 \cdot t_0\right)} \cdot \frac{-1}{t_2}\\

\mathbf{elif}\;A \leq -2.1 \cdot 10^{-305}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;A \leq 1.6 \cdot 10^{+17}:\\
\;\;\;\;\frac{-{\left({t_2}^{0.25} \cdot {\left(F \cdot \left(2 \cdot \left(A + t_0\right)\right)\right)}^{0.25}\right)}^{2}}{t_2}\\

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


\end{array}

Error

Bits error versus A

Bits error versus B

Bits error versus C

Bits error versus F

Derivation

  1. Split input into 4 regimes
  2. if A < -1.1200000000000001e177 or -1.2199999999999999e-262 < A < -2.1e-305

    1. Initial program 60.0

      \[\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. Simplified51.4

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

      \[\leadsto \frac{-\color{blue}{{\left({\left(\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}^{0.25}\right)}^{2}}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)} \]
    4. Applied egg-rr51.4

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

      \[\leadsto \left(-\sqrt{\color{blue}{\mathsf{fma}\left(A, \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F \cdot 2\right), \left(C - \mathsf{hypot}\left(B, A - C\right)\right) \cdot \left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F \cdot 2\right)\right)\right)}}\right) \cdot \frac{1}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)} \]
    6. Taylor expanded in A around -inf 35.0

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

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

    if -1.1200000000000001e177 < A < -1.2199999999999999e-262

    1. Initial program 45.0

      \[\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. Simplified41.3

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

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

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

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

    if -2.1e-305 < A < 1.6e17

    1. Initial program 49.7

      \[\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. Simplified45.8

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

      \[\leadsto \frac{-\color{blue}{{\left({\left(\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}^{0.25}\right)}^{2}}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)} \]
    4. Applied egg-rr41.7

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

    if 1.6e17 < A

    1. Initial program 61.7

      \[\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. Simplified60.6

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

      \[\leadsto \frac{-\color{blue}{{\left({\left(\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}^{0.25}\right)}^{2}}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)} \]
    4. Applied egg-rr60.6

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

      \[\leadsto \left(-\sqrt{\color{blue}{\mathsf{fma}\left(A, \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F \cdot 2\right), \left(C - \mathsf{hypot}\left(B, A - C\right)\right) \cdot \left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F \cdot 2\right)\right)\right)}}\right) \cdot \frac{1}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)} \]
    6. Taylor expanded in C around -inf 42.1

      \[\leadsto \color{blue}{-0.25 \cdot \frac{\sqrt{-16 \cdot \left(A \cdot F\right)}}{A}} \]
    7. Simplified42.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;A \leq -1.12 \cdot 10^{+177}:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\ \mathbf{elif}\;A \leq -1.22 \cdot 10^{-262}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(A, \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F \cdot 2\right), \left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F \cdot 2\right)\right) \cdot \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)} \cdot \frac{-1}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}\\ \mathbf{elif}\;A \leq -2.1 \cdot 10^{-305}:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\ \mathbf{elif}\;A \leq 1.6 \cdot 10^{+17}:\\ \;\;\;\;\frac{-{\left({\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\right)}^{0.25} \cdot {\left(F \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}^{0.25}\right)}^{2}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(A \cdot F\right)}}{A}\\ \end{array} \]

Reproduce

herbie shell --seed 2022162 
(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))))