Average Error: 52.8 → 40.2
Time: 30.9s
Precision: binary64
Cost: 14856
\[ \begin{array}{c}[A, C] = \mathsf{sort}([A, C])\\ \end{array} \]
\[\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} \mathbf{if}\;B \leq -2.7 \cdot 10^{+72}:\\ \;\;\;\;\frac{2}{B} \cdot \sqrt{A \cdot F}\\ \mathbf{elif}\;B \leq 1.7 \cdot 10^{+41}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot \left(B \cdot B\right) - F \cdot \left(C \cdot \left(A \cdot 4\right)\right)\right) \cdot \left(A + A\right)\right)}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)}}{B}\\ \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
 (if (<= B -2.7e+72)
   (* (/ 2.0 B) (sqrt (* A F)))
   (if (<= B 1.7e+41)
     (/
      (- (sqrt (* 2.0 (* (- (* F (* B B)) (* F (* C (* A 4.0)))) (+ A A)))))
      (fma B B (* C (* A -4.0))))
     (/ (- (sqrt (* 2.0 (* F (- A (hypot B A)))))) B))))
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 tmp;
	if (B <= -2.7e+72) {
		tmp = (2.0 / B) * sqrt((A * F));
	} else if (B <= 1.7e+41) {
		tmp = -sqrt((2.0 * (((F * (B * B)) - (F * (C * (A * 4.0)))) * (A + A)))) / fma(B, B, (C * (A * -4.0)));
	} else {
		tmp = -sqrt((2.0 * (F * (A - hypot(B, A))))) / B;
	}
	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)
	tmp = 0.0
	if (B <= -2.7e+72)
		tmp = Float64(Float64(2.0 / B) * sqrt(Float64(A * F)));
	elseif (B <= 1.7e+41)
		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(Float64(F * Float64(B * B)) - Float64(F * Float64(C * Float64(A * 4.0)))) * Float64(A + A))))) / fma(B, B, Float64(C * Float64(A * -4.0))));
	else
		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(B, A)))))) / B);
	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_] := If[LessEqual[B, -2.7e+72], N[(N[(2.0 / B), $MachinePrecision] * N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 1.7e+41], N[((-N[Sqrt[N[(2.0 * N[(N[(N[(F * N[(B * B), $MachinePrecision]), $MachinePrecision] - N[(F * N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $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}
\mathbf{if}\;B \leq -2.7 \cdot 10^{+72}:\\
\;\;\;\;\frac{2}{B} \cdot \sqrt{A \cdot F}\\

\mathbf{elif}\;B \leq 1.7 \cdot 10^{+41}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot \left(B \cdot B\right) - F \cdot \left(C \cdot \left(A \cdot 4\right)\right)\right) \cdot \left(A + A\right)\right)}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)}}{B}\\


\end{array}

Error

Derivation

  1. Split input into 3 regimes
  2. if B < -2.7000000000000001e72

    1. Initial program 58.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. Simplified57.9

      \[\leadsto \color{blue}{\frac{-\sqrt{2 \cdot \left(\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right) \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 C around inf 61.9

      \[\leadsto \frac{-\sqrt{2 \cdot \left(\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right) \cdot \left(A + \color{blue}{A}\right)\right)}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)} \]
    4. Taylor expanded in B around 0 62.6

      \[\leadsto \frac{-\sqrt{2 \cdot \color{blue}{\left(2 \cdot \left(A \cdot \left(F \cdot {B}^{2}\right)\right) + -8 \cdot \left({A}^{2} \cdot \left(C \cdot F\right)\right)\right)}}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)} \]
    5. Simplified63.0

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

      \[\leadsto \color{blue}{\sqrt{A \cdot F} \cdot \frac{{\left(\sqrt{2}\right)}^{2}}{B}} \]
    7. Simplified56.7

      \[\leadsto \color{blue}{\frac{2}{B} \cdot \sqrt{A \cdot F}} \]

    if -2.7000000000000001e72 < B < 1.69999999999999999e41

    1. Initial program 49.1

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

      \[\leadsto \color{blue}{\frac{-\sqrt{2 \cdot \left(\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right) \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 C around inf 37.8

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

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

    if 1.69999999999999999e41 < B

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

      \[\leadsto \color{blue}{\frac{-\sqrt{2 \cdot \left(\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right) \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 C around 0 53.5

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{\sqrt{2}}{B} \cdot \sqrt{\left(A - \sqrt{{B}^{2} + {A}^{2}}\right) \cdot F}\right)} \]
    4. Applied egg-rr32.4

      \[\leadsto -1 \cdot \color{blue}{\frac{\sqrt{2 \cdot \left(\left(A - \mathsf{hypot}\left(B, A\right)\right) \cdot F\right)}}{B}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification40.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;B \leq -2.7 \cdot 10^{+72}:\\ \;\;\;\;\frac{2}{B} \cdot \sqrt{A \cdot F}\\ \mathbf{elif}\;B \leq 1.7 \cdot 10^{+41}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot \left(B \cdot B\right) - F \cdot \left(C \cdot \left(A \cdot 4\right)\right)\right) \cdot \left(A + A\right)\right)}}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)}}{B}\\ \end{array} \]

Alternatives

Alternative 1
Error40.1
Cost14728
\[\begin{array}{l} \mathbf{if}\;B \leq -1 \cdot 10^{+110}:\\ \;\;\;\;\frac{2}{B} \cdot \sqrt{A \cdot F}\\ \mathbf{elif}\;B \leq 1.7 \cdot 10^{+41}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(2 \cdot \left(\left(A \cdot F\right) \cdot \mathsf{fma}\left(-4, A \cdot C, B \cdot B\right)\right)\right)}}{B \cdot B - C \cdot \left(A \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)}}{B}\\ \end{array} \]
Alternative 2
Error41.3
Cost14472
\[\begin{array}{l} \mathbf{if}\;B \leq -1.35 \cdot 10^{-23}:\\ \;\;\;\;\frac{2}{\frac{B}{\sqrt{A \cdot F}}}\\ \mathbf{elif}\;B \leq 3.4 \cdot 10^{-15}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(2 \cdot \left(\left(A \cdot F\right) \cdot \mathsf{fma}\left(-4, A \cdot C, B \cdot B\right)\right)\right)}}{A \cdot \left(C \cdot -4\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)}}{B}\\ \end{array} \]
Alternative 3
Error43.5
Cost14344
\[\begin{array}{l} \mathbf{if}\;B \leq -8 \cdot 10^{-20}:\\ \;\;\;\;\frac{2}{\frac{B}{\sqrt{A \cdot F}}}\\ \mathbf{elif}\;B \leq 4.8 \cdot 10^{-9}:\\ \;\;\;\;\frac{-{\left(\left(A \cdot -16\right) \cdot \left(A \cdot \left(F \cdot C\right)\right)\right)}^{0.5}}{C \cdot \left(A \cdot -4\right) + {B}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)}}{B}\\ \end{array} \]
Alternative 4
Error43.6
Cost14280
\[\begin{array}{l} \mathbf{if}\;B \leq -8 \cdot 10^{-20}:\\ \;\;\;\;\frac{2}{\frac{B}{\sqrt{A \cdot F}}}\\ \mathbf{elif}\;B \leq 4.8 \cdot 10^{-9}:\\ \;\;\;\;\frac{-\sqrt{-16 \cdot \left(A \cdot \left(A \cdot \left(F \cdot C\right)\right)\right)}}{C \cdot \left(A \cdot -4\right) + {B}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)}}{B}\\ \end{array} \]
Alternative 5
Error45.5
Cost13768
\[\begin{array}{l} \mathbf{if}\;B \leq -8 \cdot 10^{-20}:\\ \;\;\;\;\frac{2}{\frac{B}{\sqrt{A \cdot F}}}\\ \mathbf{elif}\;B \leq 2.2 \cdot 10^{-47}:\\ \;\;\;\;\frac{-\sqrt{-16 \cdot \left(\left(F \cdot C\right) \cdot \left(A \cdot A\right)\right)}}{B \cdot B - C \cdot \left(A \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)}}{B}\\ \end{array} \]
Alternative 6
Error46.7
Cost13704
\[\begin{array}{l} \mathbf{if}\;B \leq -8 \cdot 10^{-20}:\\ \;\;\;\;\frac{2}{\frac{B}{\sqrt{A \cdot F}}}\\ \mathbf{elif}\;B \leq 3.35 \cdot 10^{-15}:\\ \;\;\;\;\frac{-\sqrt{-16 \cdot \left(\left(F \cdot C\right) \cdot \left(A \cdot A\right)\right)}}{B \cdot B - C \cdot \left(A \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - B\right)} \cdot \frac{-\sqrt{2}}{B}\\ \end{array} \]
Alternative 7
Error52.4
Cost7556
\[\begin{array}{l} \mathbf{if}\;A \leq -6.567434420042127 \cdot 10^{+148}:\\ \;\;\;\;\frac{2}{\frac{B}{\sqrt{A \cdot F}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{-16 \cdot \left(\left(F \cdot C\right) \cdot \left(A \cdot A\right)\right)}}{A \cdot \left(C \cdot -4\right)}\\ \end{array} \]
Alternative 8
Error58.4
Cost6980
\[\begin{array}{l} t_0 := \sqrt{A \cdot F}\\ \mathbf{if}\;B \leq -8.6 \cdot 10^{-281}:\\ \;\;\;\;\frac{2}{B} \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{t_0}{B}\\ \end{array} \]
Alternative 9
Error58.4
Cost6980
\[\begin{array}{l} t_0 := \sqrt{A \cdot F}\\ \mathbf{if}\;B \leq -8.6 \cdot 10^{-281}:\\ \;\;\;\;\frac{2}{\frac{B}{t_0}}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{t_0}{B}\\ \end{array} \]
Alternative 10
Error60.7
Cost6848
\[\frac{-2}{\frac{B}{\sqrt{A \cdot F}}} \]
Alternative 11
Error60.7
Cost6848
\[-2 \cdot \frac{\sqrt{A \cdot F}}{B} \]
Alternative 12
Error61.6
Cost6656
\[-\sqrt{\frac{F}{A}} \]
Alternative 13
Error63.1
Cost6592
\[\sqrt{\frac{F}{A}} \]

Error

Reproduce

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