Average Error: 52.6 → 42.1
Time: 21.6s
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 := \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\\ \mathbf{if}\;C \leq -6000000:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{-8 \cdot \left(A \cdot F\right)} \cdot \sqrt{2}}{A}\\ \mathbf{elif}\;C \leq 1.9 \cdot 10^{-172}:\\ \;\;\;\;-\frac{\sqrt{\left(F \cdot t_0\right) \cdot \left(2 \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \left(-\sqrt{-0.5 \cdot \frac{F}{C}}\right)\\ \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 (fma B B (* C (* A -4.0)))))
   (if (<= C -6000000.0)
     (* -0.25 (/ (* (sqrt (* -8.0 (* A F))) (sqrt 2.0)) A))
     (if (<= C 1.9e-172)
       (- (/ (sqrt (* (* F t_0) (* 2.0 (- (+ C A) (hypot B (- A C)))))) t_0))
       (* (sqrt 2.0) (- (sqrt (* -0.5 (/ F C)))))))))
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 = fma(B, B, (C * (A * -4.0)));
	double tmp;
	if (C <= -6000000.0) {
		tmp = -0.25 * ((sqrt((-8.0 * (A * F))) * sqrt(2.0)) / A);
	} else if (C <= 1.9e-172) {
		tmp = -(sqrt(((F * t_0) * (2.0 * ((C + A) - hypot(B, (A - C)))))) / t_0);
	} else {
		tmp = sqrt(2.0) * -sqrt((-0.5 * (F / C)));
	}
	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 = fma(B, B, Float64(C * Float64(A * -4.0)))
	tmp = 0.0
	if (C <= -6000000.0)
		tmp = Float64(-0.25 * Float64(Float64(sqrt(Float64(-8.0 * Float64(A * F))) * sqrt(2.0)) / A));
	elseif (C <= 1.9e-172)
		tmp = Float64(-Float64(sqrt(Float64(Float64(F * t_0) * Float64(2.0 * Float64(Float64(C + A) - hypot(B, Float64(A - C)))))) / t_0));
	else
		tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(-0.5 * Float64(F / C)))));
	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[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[C, -6000000.0], N[(-0.25 * N[(N[(N[Sqrt[N[(-8.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision], If[LessEqual[C, 1.9e-172], (-N[(N[Sqrt[N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * N[(N[(C + A), $MachinePrecision] - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(-0.5 * N[(F / C), $MachinePrecision]), $MachinePrecision]], $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 := \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\\
\mathbf{if}\;C \leq -6000000:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{-8 \cdot \left(A \cdot F\right)} \cdot \sqrt{2}}{A}\\

\mathbf{elif}\;C \leq 1.9 \cdot 10^{-172}:\\
\;\;\;\;-\frac{\sqrt{\left(F \cdot t_0\right) \cdot \left(2 \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{t_0}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{-0.5 \cdot \frac{F}{C}}\right)\\


\end{array}

Error

Bits error versus A

Bits error versus B

Bits error versus C

Bits error versus F

Derivation

  1. Split input into 3 regimes
  2. if C < -6e6

    1. Initial program 53.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. Simplified46.7

      \[\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. Taylor expanded in F around 0 46.7

      \[\leadsto \frac{-\sqrt{\color{blue}{\left(\left({B}^{2} - 4 \cdot \left(A \cdot C\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)} \]
    4. Taylor expanded in C around -inf 36.0

      \[\leadsto \color{blue}{-0.25 \cdot \frac{\sqrt{-8 \cdot \left(A \cdot F\right)} \cdot \sqrt{2}}{A}} \]

    if -6e6 < C < 1.89999999999999993e-172

    1. Initial program 47.3

      \[\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. Simplified44.7

      \[\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-rr44.7

      \[\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(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}} \]

    if 1.89999999999999993e-172 < C

    1. Initial program 57.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. Simplified54.1

      \[\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. Taylor expanded in A around -inf 43.5

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \sqrt{2}\right)} \]
    4. Simplified43.5

      \[\leadsto \color{blue}{-\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \sqrt{2}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification42.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;C \leq -6000000:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{-8 \cdot \left(A \cdot F\right)} \cdot \sqrt{2}}{A}\\ \mathbf{elif}\;C \leq 1.9 \cdot 10^{-172}:\\ \;\;\;\;-\frac{\sqrt{\left(F \cdot \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\right) \cdot \left(2 \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \left(-\sqrt{-0.5 \cdot \frac{F}{C}}\right)\\ \end{array} \]

Reproduce

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