Average Error: 52.5 → 39.1
Time: 21.0s
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{hypot}\left(B, A - C\right)\\ t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\ t_2 := \sqrt{2 \cdot \left(F \cdot t_1\right)}\\ t_3 := -\frac{t_2 \cdot \sqrt{C + \left(A + t_0\right)}}{t_1}\\ \mathbf{if}\;C \leq -8.5 \cdot 10^{-99}:\\ \;\;\;\;\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \left(-\sqrt{2}\right)\\ \mathbf{elif}\;C \leq 5 \cdot 10^{-288}:\\ \;\;\;\;\frac{\left({\left(2 \cdot t_1\right)}^{0.5} \cdot \sqrt{F}\right) \cdot \left(-\sqrt{\left(C + A\right) + t_0}\right)}{t_1}\\ \mathbf{elif}\;C \leq 4.2 \cdot 10^{-168}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;C \leq 10^{-140}:\\ \;\;\;\;\frac{t_2 \cdot \left(-\sqrt{C \cdot 2 + -0.5 \cdot \frac{{B}^{2}}{A}}\right)}{t_1}\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \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 (hypot B (- A C)))
        (t_1 (fma B B (* A (* C -4.0))))
        (t_2 (sqrt (* 2.0 (* F t_1))))
        (t_3 (- (/ (* t_2 (sqrt (+ C (+ A t_0)))) t_1))))
   (if (<= C -8.5e-99)
     (* (sqrt (* -0.5 (/ F C))) (- (sqrt 2.0)))
     (if (<= C 5e-288)
       (/
        (* (* (pow (* 2.0 t_1) 0.5) (sqrt F)) (- (sqrt (+ (+ C A) t_0))))
        t_1)
       (if (<= C 4.2e-168)
         t_3
         (if (<= C 1e-140)
           (/ (* t_2 (- (sqrt (+ (* C 2.0) (* -0.5 (/ (pow B 2.0) A)))))) t_1)
           t_3))))))
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 = hypot(B, (A - C));
	double t_1 = fma(B, B, (A * (C * -4.0)));
	double t_2 = sqrt((2.0 * (F * t_1)));
	double t_3 = -((t_2 * sqrt((C + (A + t_0)))) / t_1);
	double tmp;
	if (C <= -8.5e-99) {
		tmp = sqrt((-0.5 * (F / C))) * -sqrt(2.0);
	} else if (C <= 5e-288) {
		tmp = ((pow((2.0 * t_1), 0.5) * sqrt(F)) * -sqrt(((C + A) + t_0))) / t_1;
	} else if (C <= 4.2e-168) {
		tmp = t_3;
	} else if (C <= 1e-140) {
		tmp = (t_2 * -sqrt(((C * 2.0) + (-0.5 * (pow(B, 2.0) / A))))) / t_1;
	} else {
		tmp = t_3;
	}
	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 = hypot(B, Float64(A - C))
	t_1 = fma(B, B, Float64(A * Float64(C * -4.0)))
	t_2 = sqrt(Float64(2.0 * Float64(F * t_1)))
	t_3 = Float64(-Float64(Float64(t_2 * sqrt(Float64(C + Float64(A + t_0)))) / t_1))
	tmp = 0.0
	if (C <= -8.5e-99)
		tmp = Float64(sqrt(Float64(-0.5 * Float64(F / C))) * Float64(-sqrt(2.0)));
	elseif (C <= 5e-288)
		tmp = Float64(Float64(Float64((Float64(2.0 * t_1) ^ 0.5) * sqrt(F)) * Float64(-sqrt(Float64(Float64(C + A) + t_0)))) / t_1);
	elseif (C <= 4.2e-168)
		tmp = t_3;
	elseif (C <= 1e-140)
		tmp = Float64(Float64(t_2 * Float64(-sqrt(Float64(Float64(C * 2.0) + Float64(-0.5 * Float64((B ^ 2.0) / A)))))) / t_1);
	else
		tmp = t_3;
	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[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(2.0 * N[(F * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = (-N[(N[(t$95$2 * N[Sqrt[N[(C + N[(A + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision])}, If[LessEqual[C, -8.5e-99], N[(N[Sqrt[N[(-0.5 * N[(F / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[C, 5e-288], N[(N[(N[(N[Power[N[(2.0 * t$95$1), $MachinePrecision], 0.5], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] * (-N[Sqrt[N[(N[(C + A), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[C, 4.2e-168], t$95$3, If[LessEqual[C, 1e-140], N[(N[(t$95$2 * (-N[Sqrt[N[(N[(C * 2.0), $MachinePrecision] + N[(-0.5 * N[(N[Power[B, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], t$95$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}
\begin{array}{l}
t_0 := \mathsf{hypot}\left(B, A - C\right)\\
t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := \sqrt{2 \cdot \left(F \cdot t_1\right)}\\
t_3 := -\frac{t_2 \cdot \sqrt{C + \left(A + t_0\right)}}{t_1}\\
\mathbf{if}\;C \leq -8.5 \cdot 10^{-99}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \left(-\sqrt{2}\right)\\

\mathbf{elif}\;C \leq 5 \cdot 10^{-288}:\\
\;\;\;\;\frac{\left({\left(2 \cdot t_1\right)}^{0.5} \cdot \sqrt{F}\right) \cdot \left(-\sqrt{\left(C + A\right) + t_0}\right)}{t_1}\\

\mathbf{elif}\;C \leq 4.2 \cdot 10^{-168}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;C \leq 10^{-140}:\\
\;\;\;\;\frac{t_2 \cdot \left(-\sqrt{C \cdot 2 + -0.5 \cdot \frac{{B}^{2}}{A}}\right)}{t_1}\\

\mathbf{else}:\\
\;\;\;\;t_3\\


\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 C < -8.5000000000000004e-99

    1. Initial program 58.6

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

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

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

      \[\leadsto \color{blue}{-\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \sqrt{2}} \]

    if -8.5000000000000004e-99 < C < 5.00000000000000011e-288

    1. Initial program 47.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. Simplified43.5

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

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

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

    if 5.00000000000000011e-288 < C < 4.19999999999999988e-168 or 9.9999999999999998e-141 < C

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

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

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

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

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

    if 4.19999999999999988e-168 < C < 9.9999999999999998e-141

    1. Initial program 50.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. Simplified45.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;C \leq -8.5 \cdot 10^{-99}:\\ \;\;\;\;\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \left(-\sqrt{2}\right)\\ \mathbf{elif}\;C \leq 5 \cdot 10^{-288}:\\ \;\;\;\;\frac{\left({\left(2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right)}^{0.5} \cdot \sqrt{F}\right) \cdot \left(-\sqrt{\left(C + A\right) + \mathsf{hypot}\left(B, A - C\right)}\right)}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{elif}\;C \leq 4.2 \cdot 10^{-168}:\\ \;\;\;\;-\frac{\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right)} \cdot \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{elif}\;C \leq 10^{-140}:\\ \;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right)} \cdot \left(-\sqrt{C \cdot 2 + -0.5 \cdot \frac{{B}^{2}}{A}}\right)}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;-\frac{\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right)} \cdot \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\ \end{array} \]

Reproduce

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