Average Error: 52.7 → 39.2
Time: 44.2s
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 := \left(4 \cdot A\right) \cdot C\\ t_1 := B \cdot B - t_0\\ t_2 := \sqrt{\left(A + C\right) + \mathsf{hypot}\left(A - C, B\right)}\\ t_3 := {B}^{2} - t_0\\ t_4 := \frac{-\sqrt{\left(2 \cdot \left(t_3 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_3}\\ \mathbf{if}\;t_4 \leq 0:\\ \;\;\;\;\frac{-\left({\left(2 \cdot t_1\right)}^{0.5} \cdot \sqrt{F}\right) \cdot t_2}{t_3}\\ \mathbf{elif}\;t_4 \leq \infty:\\ \;\;\;\;-\frac{t_2 \cdot {\left(2 \cdot \left(F \cdot t_1\right)\right)}^{0.5}}{t_1}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{A}}\\ \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}
t_0 := \left(4 \cdot A\right) \cdot C\\
t_1 := B \cdot B - t_0\\
t_2 := \sqrt{\left(A + C\right) + \mathsf{hypot}\left(A - C, B\right)}\\
t_3 := {B}^{2} - t_0\\
t_4 := \frac{-\sqrt{\left(2 \cdot \left(t_3 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_3}\\
\mathbf{if}\;t_4 \leq 0:\\
\;\;\;\;\frac{-\left({\left(2 \cdot t_1\right)}^{0.5} \cdot \sqrt{F}\right) \cdot t_2}{t_3}\\

\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;-\frac{t_2 \cdot {\left(2 \cdot \left(F \cdot t_1\right)\right)}^{0.5}}{t_1}\\

\mathbf{else}:\\
\;\;\;\;-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{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 (* (* 4.0 A) C))
        (t_1 (- (* B B) t_0))
        (t_2 (sqrt (+ (+ A C) (hypot (- A C) B))))
        (t_3 (- (pow B 2.0) t_0))
        (t_4
         (/
          (-
           (sqrt
            (*
             (* 2.0 (* t_3 F))
             (+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
          t_3)))
   (if (<= t_4 0.0)
     (/ (- (* (* (pow (* 2.0 t_1) 0.5) (sqrt F)) t_2)) t_3)
     (if (<= t_4 INFINITY)
       (- (/ (* t_2 (pow (* 2.0 (* F t_1)) 0.5)) t_1))
       (- (* (sqrt 2.0) (sqrt (* -0.5 (/ 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 = (4.0 * A) * C;
	double t_1 = (B * B) - t_0;
	double t_2 = sqrt(((A + C) + hypot((A - C), B)));
	double t_3 = pow(B, 2.0) - t_0;
	double t_4 = -sqrt(((2.0 * (t_3 * F)) * ((A + C) + sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_3;
	double tmp;
	if (t_4 <= 0.0) {
		tmp = -((pow((2.0 * t_1), 0.5) * sqrt(F)) * t_2) / t_3;
	} else if (t_4 <= ((double) INFINITY)) {
		tmp = -((t_2 * pow((2.0 * (F * t_1)), 0.5)) / t_1);
	} else {
		tmp = -(sqrt(2.0) * sqrt((-0.5 * (F / A))));
	}
	return tmp;
}

Error

Bits error versus A

Bits error versus B

Bits error versus C

Bits error versus F

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -0.0

    1. Initial program 45.4

      \[\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. Applied egg-rr35.0

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

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

    if -0.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < +inf.0

    1. Initial program 39.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. Applied egg-rr12.0

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

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

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

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

    if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)))

    1. Initial program 64.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. Taylor expanded in C around inf 57.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\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{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \leq 0:\\ \;\;\;\;\frac{-\left({\left(2 \cdot \left(B \cdot B - \left(4 \cdot A\right) \cdot C\right)\right)}^{0.5} \cdot \sqrt{F}\right) \cdot \sqrt{\left(A + C\right) + \mathsf{hypot}\left(A - C, B\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\ \mathbf{elif}\;\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{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \leq \infty:\\ \;\;\;\;-\frac{\sqrt{\left(A + C\right) + \mathsf{hypot}\left(A - C, B\right)} \cdot {\left(2 \cdot \left(F \cdot \left(B \cdot B - \left(4 \cdot A\right) \cdot C\right)\right)\right)}^{0.5}}{B \cdot B - \left(4 \cdot A\right) \cdot C}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{A}}\\ \end{array} \]

Reproduce

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