ABCF->ab-angle b

Percentage Accurate: 19.1% → 49.5%
Time: 18.0s
Alternatives: 7
Speedup: 13.3×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\ \frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0} \end{array} \end{array} \]
(FPCore (A B C F)
 :precision binary64
 (let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
   (/
    (-
     (sqrt
      (*
       (* 2.0 (* t_0 F))
       (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
    t_0)))
double code(double A, double B, double C, double F) {
	double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
	return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    real(8) :: t_0
    t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
    code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
	double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
	return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F):
	t_0 = math.pow(B, 2.0) - ((4.0 * A) * C)
	return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F)
	t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C))
	return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0)
end
function tmp = code(A, B, C, F)
	t_0 = (B ^ 2.0) - ((4.0 * A) * C);
	tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0;
end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * 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]) / t$95$0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 7 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 19.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\ \frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0} \end{array} \end{array} \]
(FPCore (A B C F)
 :precision binary64
 (let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
   (/
    (-
     (sqrt
      (*
       (* 2.0 (* t_0 F))
       (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
    t_0)))
double code(double A, double B, double C, double F) {
	double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
	return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    real(8) :: t_0
    t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
    code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
	double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
	return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F):
	t_0 = math.pow(B, 2.0) - ((4.0 * A) * C)
	return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F)
	t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C))
	return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0)
end
function tmp = code(A, B, C, F)
	t_0 = (B ^ 2.0) - ((4.0 * A) * C);
	tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0;
end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * 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]) / t$95$0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}

Alternative 1: 49.5% accurate, 0.4× speedup?

\[\begin{array}{l} [A, B, C, F] = \mathsf{sort}([A, B, C, F])\\ \\ \begin{array}{l} t_0 := \left(4 \cdot A\right) \cdot C\\ t_1 := \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_0 - {B}^{2}}\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;\frac{-0.5}{C} \cdot \left(\sqrt{F \cdot -4} \cdot \sqrt{C}\right)\\ \mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-193}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{\mathsf{fma}\left(A - C, A - C, B \cdot B\right)}\right)}}{\mathsf{fma}\left(B, -B, A \cdot \left(4 \cdot C\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{C} \cdot \sqrt{C \cdot \left(F \cdot -4\right)}\\ \end{array} \end{array} \]
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
 :precision binary64
 (let* ((t_0 (* (* 4.0 A) C))
        (t_1
         (/
          (sqrt
           (*
            (* 2.0 (* (- (pow B 2.0) t_0) F))
            (- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0))))))
          (- t_0 (pow B 2.0)))))
   (if (<= t_1 (- INFINITY))
     (* (/ -0.5 C) (* (sqrt (* F -4.0)) (sqrt C)))
     (if (<= t_1 -1e-193)
       (/
        (sqrt
         (*
          (* (fma B B (* C (* A -4.0))) (* 2.0 F))
          (- (+ A C) (sqrt (fma (- A C) (- A C) (* B B))))))
        (fma B (- B) (* A (* 4.0 C))))
       (* (/ -0.5 C) (sqrt (* C (* F -4.0))))))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
	double t_0 = (4.0 * A) * C;
	double t_1 = sqrt(((2.0 * ((pow(B, 2.0) - t_0) * F)) * ((A + C) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / (t_0 - pow(B, 2.0));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = (-0.5 / C) * (sqrt((F * -4.0)) * sqrt(C));
	} else if (t_1 <= -1e-193) {
		tmp = sqrt(((fma(B, B, (C * (A * -4.0))) * (2.0 * F)) * ((A + C) - sqrt(fma((A - C), (A - C), (B * B)))))) / fma(B, -B, (A * (4.0 * C)));
	} else {
		tmp = (-0.5 / C) * sqrt((C * (F * -4.0)));
	}
	return tmp;
}
A, B, C, F = sort([A, B, C, F])
function code(A, B, C, F)
	t_0 = Float64(Float64(4.0 * A) * C)
	t_1 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B ^ 2.0) - t_0) * F)) * Float64(Float64(A + C) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0)))))) / Float64(t_0 - (B ^ 2.0)))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(Float64(-0.5 / C) * Float64(sqrt(Float64(F * -4.0)) * sqrt(C)));
	elseif (t_1 <= -1e-193)
		tmp = Float64(sqrt(Float64(Float64(fma(B, B, Float64(C * Float64(A * -4.0))) * Float64(2.0 * F)) * Float64(Float64(A + C) - sqrt(fma(Float64(A - C), Float64(A - C), Float64(B * B)))))) / fma(B, Float64(-B), Float64(A * Float64(4.0 * C))));
	else
		tmp = Float64(Float64(-0.5 / C) * sqrt(Float64(C * Float64(F * -4.0))));
	end
	return tmp
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(-0.5 / C), $MachinePrecision] * N[(N[Sqrt[N[(F * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[C], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e-193], N[(N[Sqrt[N[(N[(N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[(A - C), $MachinePrecision] * N[(A - C), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(B * (-B) + N[(A * N[(4.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 / C), $MachinePrecision] * N[Sqrt[N[(C * N[(F * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \left(4 \cdot A\right) \cdot C\\
t_1 := \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_0 - {B}^{2}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\frac{-0.5}{C} \cdot \left(\sqrt{F \cdot -4} \cdot \sqrt{C}\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -inf.0

    1. Initial program 3.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. Add Preprocessing
    3. Applied rewrites0.7%

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

      \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(\frac{{\left(\sqrt{2}\right)}^{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right)} \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(\frac{{\left(\sqrt{2}\right)}^{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(\frac{{\left(\sqrt{2}\right)}^{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right)} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{-1}{4} \cdot \left(\color{blue}{\frac{{\left(\sqrt{2}\right)}^{2}}{C}} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
      4. unpow2N/A

        \[\leadsto \frac{-1}{4} \cdot \left(\frac{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
      5. lower-*.f64N/A

        \[\leadsto \frac{-1}{4} \cdot \left(\frac{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
      6. lower-sqrt.f64N/A

        \[\leadsto \frac{-1}{4} \cdot \left(\frac{\color{blue}{\sqrt{2}} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
      7. lower-sqrt.f64N/A

        \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \color{blue}{\sqrt{2}}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
      8. lower-sqrt.f64N/A

        \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \color{blue}{\sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{\color{blue}{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}}\right) \]
      10. distribute-rgt-out--N/A

        \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \color{blue}{\left(C \cdot \left(-2 - 2\right)\right)}}\right) \]
      11. metadata-evalN/A

        \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \left(C \cdot \color{blue}{-4}\right)}\right) \]
      12. lower-*.f6439.2

        \[\leadsto -0.25 \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \color{blue}{\left(C \cdot -4\right)}}\right) \]
    6. Applied rewrites39.2%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \left(C \cdot -4\right)}\right)} \]
    7. Step-by-step derivation
      1. Applied rewrites39.7%

        \[\leadsto \frac{-0.5}{C} \cdot \color{blue}{\sqrt{F \cdot \left(C \cdot -4\right)}} \]
      2. Step-by-step derivation
        1. Applied rewrites66.7%

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

        if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -1e-193

        1. Initial program 97.9%

          \[\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. Add Preprocessing
        3. Applied rewrites97.9%

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

        if -1e-193 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)))

        1. Initial program 3.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. Add Preprocessing
        3. Applied rewrites0.8%

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

          \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(\frac{{\left(\sqrt{2}\right)}^{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right)} \]
        5. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(\frac{{\left(\sqrt{2}\right)}^{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right)} \]
          2. lower-*.f64N/A

            \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(\frac{{\left(\sqrt{2}\right)}^{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right)} \]
          3. lower-/.f64N/A

            \[\leadsto \frac{-1}{4} \cdot \left(\color{blue}{\frac{{\left(\sqrt{2}\right)}^{2}}{C}} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
          4. unpow2N/A

            \[\leadsto \frac{-1}{4} \cdot \left(\frac{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
          5. lower-*.f64N/A

            \[\leadsto \frac{-1}{4} \cdot \left(\frac{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
          6. lower-sqrt.f64N/A

            \[\leadsto \frac{-1}{4} \cdot \left(\frac{\color{blue}{\sqrt{2}} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
          7. lower-sqrt.f64N/A

            \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \color{blue}{\sqrt{2}}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
          8. lower-sqrt.f64N/A

            \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \color{blue}{\sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}}\right) \]
          9. lower-*.f64N/A

            \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{\color{blue}{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}}\right) \]
          10. distribute-rgt-out--N/A

            \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \color{blue}{\left(C \cdot \left(-2 - 2\right)\right)}}\right) \]
          11. metadata-evalN/A

            \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \left(C \cdot \color{blue}{-4}\right)}\right) \]
          12. lower-*.f6435.7

            \[\leadsto -0.25 \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \color{blue}{\left(C \cdot -4\right)}}\right) \]
        6. Applied rewrites35.7%

          \[\leadsto \color{blue}{-0.25 \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \left(C \cdot -4\right)}\right)} \]
        7. Step-by-step derivation
          1. Applied rewrites36.2%

            \[\leadsto \frac{-0.5}{C} \cdot \color{blue}{\sqrt{F \cdot \left(C \cdot -4\right)}} \]
          2. Step-by-step derivation
            1. Applied rewrites36.2%

              \[\leadsto \frac{-0.5}{C} \cdot \sqrt{\left(F \cdot -4\right) \cdot C} \]
          3. Recombined 3 regimes into one program.
          4. Final simplification52.8%

            \[\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)}}{\left(4 \cdot A\right) \cdot C - {B}^{2}} \leq -\infty:\\ \;\;\;\;\frac{-0.5}{C} \cdot \left(\sqrt{F \cdot -4} \cdot \sqrt{C}\right)\\ \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)}}{\left(4 \cdot A\right) \cdot C - {B}^{2}} \leq -1 \cdot 10^{-193}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{\mathsf{fma}\left(A - C, A - C, B \cdot B\right)}\right)}}{\mathsf{fma}\left(B, -B, A \cdot \left(4 \cdot C\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{C} \cdot \sqrt{C \cdot \left(F \cdot -4\right)}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 2: 47.8% accurate, 0.5× speedup?

          \[\begin{array}{l} [A, B, C, F] = \mathsf{sort}([A, B, C, F])\\ \\ \begin{array}{l} t_0 := \left(4 \cdot A\right) \cdot C\\ t_1 := \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_0 - {B}^{2}}\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+162}:\\ \;\;\;\;\frac{-0.5}{C} \cdot \left(\sqrt{F \cdot -4} \cdot \sqrt{C}\right)\\ \mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-170}:\\ \;\;\;\;\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{\mathsf{fma}\left(B, B, \left(A - C\right) \cdot \left(A - C\right)\right)}\right)}{\mathsf{fma}\left(A \cdot C, -4, B \cdot B\right)}} \cdot \left(-\sqrt{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{C} \cdot \sqrt{C \cdot \left(F \cdot -4\right)}\\ \end{array} \end{array} \]
          NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
          (FPCore (A B C F)
           :precision binary64
           (let* ((t_0 (* (* 4.0 A) C))
                  (t_1
                   (/
                    (sqrt
                     (*
                      (* 2.0 (* (- (pow B 2.0) t_0) F))
                      (- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0))))))
                    (- t_0 (pow B 2.0)))))
             (if (<= t_1 -4e+162)
               (* (/ -0.5 C) (* (sqrt (* F -4.0)) (sqrt C)))
               (if (<= t_1 -1e-170)
                 (*
                  (sqrt
                   (/
                    (* F (- (+ A C) (sqrt (fma B B (* (- A C) (- A C))))))
                    (fma (* A C) -4.0 (* B B))))
                  (- (sqrt 2.0)))
                 (* (/ -0.5 C) (sqrt (* C (* F -4.0))))))))
          assert(A < B && B < C && C < F);
          double code(double A, double B, double C, double F) {
          	double t_0 = (4.0 * A) * C;
          	double t_1 = sqrt(((2.0 * ((pow(B, 2.0) - t_0) * F)) * ((A + C) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / (t_0 - pow(B, 2.0));
          	double tmp;
          	if (t_1 <= -4e+162) {
          		tmp = (-0.5 / C) * (sqrt((F * -4.0)) * sqrt(C));
          	} else if (t_1 <= -1e-170) {
          		tmp = sqrt(((F * ((A + C) - sqrt(fma(B, B, ((A - C) * (A - C)))))) / fma((A * C), -4.0, (B * B)))) * -sqrt(2.0);
          	} else {
          		tmp = (-0.5 / C) * sqrt((C * (F * -4.0)));
          	}
          	return tmp;
          }
          
          A, B, C, F = sort([A, B, C, F])
          function code(A, B, C, F)
          	t_0 = Float64(Float64(4.0 * A) * C)
          	t_1 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B ^ 2.0) - t_0) * F)) * Float64(Float64(A + C) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0)))))) / Float64(t_0 - (B ^ 2.0)))
          	tmp = 0.0
          	if (t_1 <= -4e+162)
          		tmp = Float64(Float64(-0.5 / C) * Float64(sqrt(Float64(F * -4.0)) * sqrt(C)));
          	elseif (t_1 <= -1e-170)
          		tmp = Float64(sqrt(Float64(Float64(F * Float64(Float64(A + C) - sqrt(fma(B, B, Float64(Float64(A - C) * Float64(A - C)))))) / fma(Float64(A * C), -4.0, Float64(B * B)))) * Float64(-sqrt(2.0)));
          	else
          		tmp = Float64(Float64(-0.5 / C) * sqrt(Float64(C * Float64(F * -4.0))));
          	end
          	return tmp
          end
          
          NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
          code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+162], N[(N[(-0.5 / C), $MachinePrecision] * N[(N[Sqrt[N[(F * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[C], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e-170], N[(N[Sqrt[N[(N[(F * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(B * B + N[(N[(A - C), $MachinePrecision] * N[(A - C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(A * C), $MachinePrecision] * -4.0 + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[(-0.5 / C), $MachinePrecision] * N[Sqrt[N[(C * N[(F * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
          
          \begin{array}{l}
          [A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
          \\
          \begin{array}{l}
          t_0 := \left(4 \cdot A\right) \cdot C\\
          t_1 := \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_0 - {B}^{2}}\\
          \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+162}:\\
          \;\;\;\;\frac{-0.5}{C} \cdot \left(\sqrt{F \cdot -4} \cdot \sqrt{C}\right)\\
          
          \mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-170}:\\
          \;\;\;\;\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{\mathsf{fma}\left(B, B, \left(A - C\right) \cdot \left(A - C\right)\right)}\right)}{\mathsf{fma}\left(A \cdot C, -4, B \cdot B\right)}} \cdot \left(-\sqrt{2}\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{-0.5}{C} \cdot \sqrt{C \cdot \left(F \cdot -4\right)}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -3.9999999999999998e162

            1. Initial program 9.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. Add Preprocessing
            3. Applied rewrites2.2%

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

              \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(\frac{{\left(\sqrt{2}\right)}^{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right)} \]
            5. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(\frac{{\left(\sqrt{2}\right)}^{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right)} \]
              2. lower-*.f64N/A

                \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(\frac{{\left(\sqrt{2}\right)}^{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right)} \]
              3. lower-/.f64N/A

                \[\leadsto \frac{-1}{4} \cdot \left(\color{blue}{\frac{{\left(\sqrt{2}\right)}^{2}}{C}} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
              4. unpow2N/A

                \[\leadsto \frac{-1}{4} \cdot \left(\frac{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
              5. lower-*.f64N/A

                \[\leadsto \frac{-1}{4} \cdot \left(\frac{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
              6. lower-sqrt.f64N/A

                \[\leadsto \frac{-1}{4} \cdot \left(\frac{\color{blue}{\sqrt{2}} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
              7. lower-sqrt.f64N/A

                \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \color{blue}{\sqrt{2}}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
              8. lower-sqrt.f64N/A

                \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \color{blue}{\sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}}\right) \]
              9. lower-*.f64N/A

                \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{\color{blue}{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}}\right) \]
              10. distribute-rgt-out--N/A

                \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \color{blue}{\left(C \cdot \left(-2 - 2\right)\right)}}\right) \]
              11. metadata-evalN/A

                \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \left(C \cdot \color{blue}{-4}\right)}\right) \]
              12. lower-*.f6446.3

                \[\leadsto -0.25 \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \color{blue}{\left(C \cdot -4\right)}}\right) \]
            6. Applied rewrites46.3%

              \[\leadsto \color{blue}{-0.25 \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \left(C \cdot -4\right)}\right)} \]
            7. Step-by-step derivation
              1. Applied rewrites47.0%

                \[\leadsto \frac{-0.5}{C} \cdot \color{blue}{\sqrt{F \cdot \left(C \cdot -4\right)}} \]
              2. Step-by-step derivation
                1. Applied rewrites63.7%

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

                if -3.9999999999999998e162 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -9.99999999999999983e-171

                1. Initial program 97.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. Add Preprocessing
                3. Taylor expanded in F around 0

                  \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
                4. Step-by-step derivation
                  1. mul-1-negN/A

                    \[\leadsto \color{blue}{\mathsf{neg}\left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
                  2. distribute-rgt-neg-inN/A

                    \[\leadsto \color{blue}{\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \left(\mathsf{neg}\left(\sqrt{2}\right)\right)} \]
                  3. lower-*.f64N/A

                    \[\leadsto \color{blue}{\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \left(\mathsf{neg}\left(\sqrt{2}\right)\right)} \]
                5. Applied rewrites93.8%

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

                if -9.99999999999999983e-171 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)))

                1. Initial program 7.9%

                  \[\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. Add Preprocessing
                3. Applied rewrites2.0%

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

                  \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(\frac{{\left(\sqrt{2}\right)}^{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right)} \]
                5. Step-by-step derivation
                  1. lower-*.f64N/A

                    \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(\frac{{\left(\sqrt{2}\right)}^{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right)} \]
                  2. lower-*.f64N/A

                    \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(\frac{{\left(\sqrt{2}\right)}^{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right)} \]
                  3. lower-/.f64N/A

                    \[\leadsto \frac{-1}{4} \cdot \left(\color{blue}{\frac{{\left(\sqrt{2}\right)}^{2}}{C}} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
                  4. unpow2N/A

                    \[\leadsto \frac{-1}{4} \cdot \left(\frac{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
                  5. lower-*.f64N/A

                    \[\leadsto \frac{-1}{4} \cdot \left(\frac{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
                  6. lower-sqrt.f64N/A

                    \[\leadsto \frac{-1}{4} \cdot \left(\frac{\color{blue}{\sqrt{2}} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
                  7. lower-sqrt.f64N/A

                    \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \color{blue}{\sqrt{2}}}{C} \cdot \sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}\right) \]
                  8. lower-sqrt.f64N/A

                    \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \color{blue}{\sqrt{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}}\right) \]
                  9. lower-*.f64N/A

                    \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{\color{blue}{F \cdot \left(-2 \cdot C - 2 \cdot C\right)}}\right) \]
                  10. distribute-rgt-out--N/A

                    \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \color{blue}{\left(C \cdot \left(-2 - 2\right)\right)}}\right) \]
                  11. metadata-evalN/A

                    \[\leadsto \frac{-1}{4} \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \left(C \cdot \color{blue}{-4}\right)}\right) \]
                  12. lower-*.f6434.2

                    \[\leadsto -0.25 \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \color{blue}{\left(C \cdot -4\right)}}\right) \]
                6. Applied rewrites34.2%

                  \[\leadsto \color{blue}{-0.25 \cdot \left(\frac{\sqrt{2} \cdot \sqrt{2}}{C} \cdot \sqrt{F \cdot \left(C \cdot -4\right)}\right)} \]
                7. Step-by-step derivation
                  1. Applied rewrites34.6%

                    \[\leadsto \frac{-0.5}{C} \cdot \color{blue}{\sqrt{F \cdot \left(C \cdot -4\right)}} \]
                  2. Step-by-step derivation
                    1. Applied rewrites34.6%

                      \[\leadsto \frac{-0.5}{C} \cdot \sqrt{\left(F \cdot -4\right) \cdot C} \]
                  3. Recombined 3 regimes into one program.
                  4. Final simplification47.8%

                    \[\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)}}{\left(4 \cdot A\right) \cdot C - {B}^{2}} \leq -4 \cdot 10^{+162}:\\ \;\;\;\;\frac{-0.5}{C} \cdot \left(\sqrt{F \cdot -4} \cdot \sqrt{C}\right)\\ \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)}}{\left(4 \cdot A\right) \cdot C - {B}^{2}} \leq -1 \cdot 10^{-170}:\\ \;\;\;\;\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{\mathsf{fma}\left(B, B, \left(A - C\right) \cdot \left(A - C\right)\right)}\right)}{\mathsf{fma}\left(A \cdot C, -4, B \cdot B\right)}} \cdot \left(-\sqrt{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{C} \cdot \sqrt{C \cdot \left(F \cdot -4\right)}\\ \end{array} \]
                  5. Add Preprocessing

                  Reproduce

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