Quadratic roots, narrow range

Percentage Accurate: 55.7% → 91.7%
Time: 15.9s
Alternatives: 11
Speedup: 29.0×

Specification

?
\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\right)\]
\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\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 11 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: 55.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}

Alternative 1: 91.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{{c}^{4}}{{b}^{6}}\\ \mathbf{if}\;b \leq 0.022:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-2, \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}, \mathsf{fma}\left(-1, \mathsf{fma}\left(a, \frac{{c}^{2}}{{b}^{3}}, \frac{c}{b}\right), {a}^{3} \cdot \left(\frac{\mathsf{fma}\left(16, t\_0, 4 \cdot t\_0\right)}{b} \cdot -0.25\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (/ (pow c 4.0) (pow b 6.0))))
   (if (<= b 0.022)
     (/ (- (sqrt (fma b b (* c (* a -4.0)))) b) (* a 2.0))
     (fma
      -2.0
      (/ (* (pow c 3.0) (pow a 2.0)) (pow b 5.0))
      (fma
       -1.0
       (fma a (/ (pow c 2.0) (pow b 3.0)) (/ c b))
       (* (pow a 3.0) (* (/ (fma 16.0 t_0 (* 4.0 t_0)) b) -0.25)))))))
double code(double a, double b, double c) {
	double t_0 = pow(c, 4.0) / pow(b, 6.0);
	double tmp;
	if (b <= 0.022) {
		tmp = (sqrt(fma(b, b, (c * (a * -4.0)))) - b) / (a * 2.0);
	} else {
		tmp = fma(-2.0, ((pow(c, 3.0) * pow(a, 2.0)) / pow(b, 5.0)), fma(-1.0, fma(a, (pow(c, 2.0) / pow(b, 3.0)), (c / b)), (pow(a, 3.0) * ((fma(16.0, t_0, (4.0 * t_0)) / b) * -0.25))));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = Float64((c ^ 4.0) / (b ^ 6.0))
	tmp = 0.0
	if (b <= 0.022)
		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))) - b) / Float64(a * 2.0));
	else
		tmp = fma(-2.0, Float64(Float64((c ^ 3.0) * (a ^ 2.0)) / (b ^ 5.0)), fma(-1.0, fma(a, Float64((c ^ 2.0) / (b ^ 3.0)), Float64(c / b)), Float64((a ^ 3.0) * Float64(Float64(fma(16.0, t_0, Float64(4.0 * t_0)) / b) * -0.25))));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[Power[c, 4.0], $MachinePrecision] / N[Power[b, 6.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 0.022], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[(N[Power[c, 3.0], $MachinePrecision] * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 * N[(a * N[(N[Power[c, 2.0], $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(N[Power[a, 3.0], $MachinePrecision] * N[(N[(N[(16.0 * t$95$0 + N[(4.0 * t$95$0), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{{c}^{4}}{{b}^{6}}\\
\mathbf{if}\;b \leq 0.022:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-2, \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}, \mathsf{fma}\left(-1, \mathsf{fma}\left(a, \frac{{c}^{2}}{{b}^{3}}, \frac{c}{b}\right), {a}^{3} \cdot \left(\frac{\mathsf{fma}\left(16, t\_0, 4 \cdot t\_0\right)}{b} \cdot -0.25\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 0.021999999999999999

    1. Initial program 88.0%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative88.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
      2. +-commutative88.0%

        \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{a \cdot 2} \]
      3. sqr-neg88.0%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(-b\right) \cdot \left(-b\right)} - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{a \cdot 2} \]
      4. unsub-neg88.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(4 \cdot a\right) \cdot c} - b}}{a \cdot 2} \]
      5. sqr-neg88.0%

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b} - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2} \]
      6. fma-neg88.2%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b}{a \cdot 2} \]
      7. distribute-lft-neg-in88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-4 \cdot a\right) \cdot c}\right)} - b}{a \cdot 2} \]
      8. *-commutative88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)} - b}{a \cdot 2} \]
      9. *-commutative88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-\color{blue}{a \cdot 4}\right)\right)} - b}{a \cdot 2} \]
      10. distribute-rgt-neg-in88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \color{blue}{\left(a \cdot \left(-4\right)\right)}\right)} - b}{a \cdot 2} \]
      11. metadata-eval88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot \color{blue}{-4}\right)\right)} - b}{a \cdot 2} \]
    3. Simplified88.2%

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}} \]
    4. Add Preprocessing

    if 0.021999999999999999 < b

    1. Initial program 52.7%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative52.7%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified52.7%

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Taylor expanded in a around 0 93.8%

      \[\leadsto \color{blue}{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{{a}^{3} \cdot \left(16 \cdot \frac{{c}^{4}}{{b}^{6}} + {\left(-2 \cdot \frac{{c}^{2}}{{b}^{3}}\right)}^{2}\right)}{b}\right)\right)} \]
    6. Simplified93.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-2, \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}, \mathsf{fma}\left(-1, \mathsf{fma}\left(a, \frac{{c}^{2}}{{b}^{3}}, \frac{c}{b}\right), {a}^{3} \cdot \left(\frac{\mathsf{fma}\left(16, \frac{{c}^{4}}{{b}^{6}}, 4 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b} \cdot -0.25\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification93.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 0.022:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-2, \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}, \mathsf{fma}\left(-1, \mathsf{fma}\left(a, \frac{{c}^{2}}{{b}^{3}}, \frac{c}{b}\right), {a}^{3} \cdot \left(\frac{\mathsf{fma}\left(16, \frac{{c}^{4}}{{b}^{6}}, 4 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b} \cdot -0.25\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 91.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(c \cdot a\right)}^{4}\\ \mathbf{if}\;b \leq 0.022:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(\left(-0.25 \cdot \frac{16 \cdot t\_0 + 4 \cdot t\_0}{a \cdot {b}^{7}} - \frac{a \cdot {c}^{2}}{{b}^{3}}\right) - \frac{c}{b}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (pow (* c a) 4.0)))
   (if (<= b 0.022)
     (/ (- (sqrt (fma b b (* c (* a -4.0)))) b) (* a 2.0))
     (+
      (* -2.0 (/ (* (pow c 3.0) (pow a 2.0)) (pow b 5.0)))
      (-
       (-
        (* -0.25 (/ (+ (* 16.0 t_0) (* 4.0 t_0)) (* a (pow b 7.0))))
        (/ (* a (pow c 2.0)) (pow b 3.0)))
       (/ c b))))))
double code(double a, double b, double c) {
	double t_0 = pow((c * a), 4.0);
	double tmp;
	if (b <= 0.022) {
		tmp = (sqrt(fma(b, b, (c * (a * -4.0)))) - b) / (a * 2.0);
	} else {
		tmp = (-2.0 * ((pow(c, 3.0) * pow(a, 2.0)) / pow(b, 5.0))) + (((-0.25 * (((16.0 * t_0) + (4.0 * t_0)) / (a * pow(b, 7.0)))) - ((a * pow(c, 2.0)) / pow(b, 3.0))) - (c / b));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = Float64(c * a) ^ 4.0
	tmp = 0.0
	if (b <= 0.022)
		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))) - b) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(-2.0 * Float64(Float64((c ^ 3.0) * (a ^ 2.0)) / (b ^ 5.0))) + Float64(Float64(Float64(-0.25 * Float64(Float64(Float64(16.0 * t_0) + Float64(4.0 * t_0)) / Float64(a * (b ^ 7.0)))) - Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))) - Float64(c / b)));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[Power[N[(c * a), $MachinePrecision], 4.0], $MachinePrecision]}, If[LessEqual[b, 0.022], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(N[(N[Power[c, 3.0], $MachinePrecision] * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-0.25 * N[(N[(N[(16.0 * t$95$0), $MachinePrecision] + N[(4.0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(a * N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(c \cdot a\right)}^{4}\\
\mathbf{if}\;b \leq 0.022:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(\left(-0.25 \cdot \frac{16 \cdot t\_0 + 4 \cdot t\_0}{a \cdot {b}^{7}} - \frac{a \cdot {c}^{2}}{{b}^{3}}\right) - \frac{c}{b}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 0.021999999999999999

    1. Initial program 88.0%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative88.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
      2. +-commutative88.0%

        \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{a \cdot 2} \]
      3. sqr-neg88.0%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(-b\right) \cdot \left(-b\right)} - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{a \cdot 2} \]
      4. unsub-neg88.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(4 \cdot a\right) \cdot c} - b}}{a \cdot 2} \]
      5. sqr-neg88.0%

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b} - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2} \]
      6. fma-neg88.2%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b}{a \cdot 2} \]
      7. distribute-lft-neg-in88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-4 \cdot a\right) \cdot c}\right)} - b}{a \cdot 2} \]
      8. *-commutative88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)} - b}{a \cdot 2} \]
      9. *-commutative88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-\color{blue}{a \cdot 4}\right)\right)} - b}{a \cdot 2} \]
      10. distribute-rgt-neg-in88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \color{blue}{\left(a \cdot \left(-4\right)\right)}\right)} - b}{a \cdot 2} \]
      11. metadata-eval88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot \color{blue}{-4}\right)\right)} - b}{a \cdot 2} \]
    3. Simplified88.2%

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}} \]
    4. Add Preprocessing

    if 0.021999999999999999 < b

    1. Initial program 52.7%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative52.7%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified52.7%

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Taylor expanded in b around inf 93.8%

      \[\leadsto \color{blue}{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + {\left(-2 \cdot \left({a}^{2} \cdot {c}^{2}\right)\right)}^{2}}{a \cdot {b}^{7}}\right)\right)} \]
    6. Step-by-step derivation
      1. *-commutative93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + {\color{blue}{\left(\left({a}^{2} \cdot {c}^{2}\right) \cdot -2\right)}}^{2}}{a \cdot {b}^{7}}\right)\right) \]
      2. unpow-prod-down93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + \color{blue}{{\left({a}^{2} \cdot {c}^{2}\right)}^{2} \cdot {-2}^{2}}}{a \cdot {b}^{7}}\right)\right) \]
      3. pow-prod-down93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + {\color{blue}{\left({\left(a \cdot c\right)}^{2}\right)}}^{2} \cdot {-2}^{2}}{a \cdot {b}^{7}}\right)\right) \]
      4. pow-pow93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + \color{blue}{{\left(a \cdot c\right)}^{\left(2 \cdot 2\right)}} \cdot {-2}^{2}}{a \cdot {b}^{7}}\right)\right) \]
      5. metadata-eval93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + {\left(a \cdot c\right)}^{\color{blue}{4}} \cdot {-2}^{2}}{a \cdot {b}^{7}}\right)\right) \]
      6. metadata-eval93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + {\left(a \cdot c\right)}^{4} \cdot \color{blue}{4}}{a \cdot {b}^{7}}\right)\right) \]
    7. Applied egg-rr93.8%

      \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + \color{blue}{{\left(a \cdot c\right)}^{4} \cdot 4}}{a \cdot {b}^{7}}\right)\right) \]
    8. Step-by-step derivation
      1. pow-prod-down93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \color{blue}{{\left(a \cdot c\right)}^{4}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
      2. metadata-eval93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot {\left(a \cdot c\right)}^{\color{blue}{\left(2 \cdot 2\right)}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
      3. pow-pow93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \color{blue}{{\left({\left(a \cdot c\right)}^{2}\right)}^{2}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
    9. Applied egg-rr93.8%

      \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \color{blue}{{\left({\left(a \cdot c\right)}^{2}\right)}^{2}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
    10. Step-by-step derivation
      1. unpow293.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \color{blue}{\left({\left(a \cdot c\right)}^{2} \cdot {\left(a \cdot c\right)}^{2}\right)} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
      2. pow-sqr93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \color{blue}{{\left(a \cdot c\right)}^{\left(2 \cdot 2\right)}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
      3. metadata-eval93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot {\left(a \cdot c\right)}^{\color{blue}{4}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
    11. Simplified93.8%

      \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \color{blue}{{\left(a \cdot c\right)}^{4}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification93.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 0.022:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(\left(-0.25 \cdot \frac{16 \cdot {\left(c \cdot a\right)}^{4} + 4 \cdot {\left(c \cdot a\right)}^{4}}{a \cdot {b}^{7}} - \frac{a \cdot {c}^{2}}{{b}^{3}}\right) - \frac{c}{b}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 91.7% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(c \cdot a\right)}^{4}\\ \mathbf{if}\;b \leq 0.022:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(\left(-0.25 \cdot \frac{16 \cdot t\_0 + 4 \cdot t\_0}{a \cdot {b}^{7}} - {\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right) - \frac{c}{b}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (pow (* c a) 4.0)))
   (if (<= b 0.022)
     (/ (- (sqrt (fma b b (* c (* a -4.0)))) b) (* a 2.0))
     (+
      (* -2.0 (/ (* (pow c 3.0) (pow a 2.0)) (pow b 5.0)))
      (-
       (-
        (* -0.25 (/ (+ (* 16.0 t_0) (* 4.0 t_0)) (* a (pow b 7.0))))
        (* (pow (/ c b) 2.0) (/ a b)))
       (/ c b))))))
double code(double a, double b, double c) {
	double t_0 = pow((c * a), 4.0);
	double tmp;
	if (b <= 0.022) {
		tmp = (sqrt(fma(b, b, (c * (a * -4.0)))) - b) / (a * 2.0);
	} else {
		tmp = (-2.0 * ((pow(c, 3.0) * pow(a, 2.0)) / pow(b, 5.0))) + (((-0.25 * (((16.0 * t_0) + (4.0 * t_0)) / (a * pow(b, 7.0)))) - (pow((c / b), 2.0) * (a / b))) - (c / b));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = Float64(c * a) ^ 4.0
	tmp = 0.0
	if (b <= 0.022)
		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))) - b) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(-2.0 * Float64(Float64((c ^ 3.0) * (a ^ 2.0)) / (b ^ 5.0))) + Float64(Float64(Float64(-0.25 * Float64(Float64(Float64(16.0 * t_0) + Float64(4.0 * t_0)) / Float64(a * (b ^ 7.0)))) - Float64((Float64(c / b) ^ 2.0) * Float64(a / b))) - Float64(c / b)));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[Power[N[(c * a), $MachinePrecision], 4.0], $MachinePrecision]}, If[LessEqual[b, 0.022], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(N[(N[Power[c, 3.0], $MachinePrecision] * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-0.25 * N[(N[(N[(16.0 * t$95$0), $MachinePrecision] + N[(4.0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(a * N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Power[N[(c / b), $MachinePrecision], 2.0], $MachinePrecision] * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(c \cdot a\right)}^{4}\\
\mathbf{if}\;b \leq 0.022:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(\left(-0.25 \cdot \frac{16 \cdot t\_0 + 4 \cdot t\_0}{a \cdot {b}^{7}} - {\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right) - \frac{c}{b}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 0.021999999999999999

    1. Initial program 88.0%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative88.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
      2. +-commutative88.0%

        \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{a \cdot 2} \]
      3. sqr-neg88.0%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(-b\right) \cdot \left(-b\right)} - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{a \cdot 2} \]
      4. unsub-neg88.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(4 \cdot a\right) \cdot c} - b}}{a \cdot 2} \]
      5. sqr-neg88.0%

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b} - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2} \]
      6. fma-neg88.2%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b}{a \cdot 2} \]
      7. distribute-lft-neg-in88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-4 \cdot a\right) \cdot c}\right)} - b}{a \cdot 2} \]
      8. *-commutative88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)} - b}{a \cdot 2} \]
      9. *-commutative88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-\color{blue}{a \cdot 4}\right)\right)} - b}{a \cdot 2} \]
      10. distribute-rgt-neg-in88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \color{blue}{\left(a \cdot \left(-4\right)\right)}\right)} - b}{a \cdot 2} \]
      11. metadata-eval88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot \color{blue}{-4}\right)\right)} - b}{a \cdot 2} \]
    3. Simplified88.2%

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}} \]
    4. Add Preprocessing

    if 0.021999999999999999 < b

    1. Initial program 52.7%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative52.7%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified52.7%

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Taylor expanded in b around inf 93.8%

      \[\leadsto \color{blue}{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + {\left(-2 \cdot \left({a}^{2} \cdot {c}^{2}\right)\right)}^{2}}{a \cdot {b}^{7}}\right)\right)} \]
    6. Step-by-step derivation
      1. *-commutative93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + {\color{blue}{\left(\left({a}^{2} \cdot {c}^{2}\right) \cdot -2\right)}}^{2}}{a \cdot {b}^{7}}\right)\right) \]
      2. unpow-prod-down93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + \color{blue}{{\left({a}^{2} \cdot {c}^{2}\right)}^{2} \cdot {-2}^{2}}}{a \cdot {b}^{7}}\right)\right) \]
      3. pow-prod-down93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + {\color{blue}{\left({\left(a \cdot c\right)}^{2}\right)}}^{2} \cdot {-2}^{2}}{a \cdot {b}^{7}}\right)\right) \]
      4. pow-pow93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + \color{blue}{{\left(a \cdot c\right)}^{\left(2 \cdot 2\right)}} \cdot {-2}^{2}}{a \cdot {b}^{7}}\right)\right) \]
      5. metadata-eval93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + {\left(a \cdot c\right)}^{\color{blue}{4}} \cdot {-2}^{2}}{a \cdot {b}^{7}}\right)\right) \]
      6. metadata-eval93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + {\left(a \cdot c\right)}^{4} \cdot \color{blue}{4}}{a \cdot {b}^{7}}\right)\right) \]
    7. Applied egg-rr93.8%

      \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \left({a}^{4} \cdot {c}^{4}\right) + \color{blue}{{\left(a \cdot c\right)}^{4} \cdot 4}}{a \cdot {b}^{7}}\right)\right) \]
    8. Step-by-step derivation
      1. pow-prod-down93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \color{blue}{{\left(a \cdot c\right)}^{4}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
      2. metadata-eval93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot {\left(a \cdot c\right)}^{\color{blue}{\left(2 \cdot 2\right)}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
      3. pow-pow93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \color{blue}{{\left({\left(a \cdot c\right)}^{2}\right)}^{2}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
    9. Applied egg-rr93.8%

      \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \color{blue}{{\left({\left(a \cdot c\right)}^{2}\right)}^{2}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
    10. Step-by-step derivation
      1. unpow293.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \color{blue}{\left({\left(a \cdot c\right)}^{2} \cdot {\left(a \cdot c\right)}^{2}\right)} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
      2. pow-sqr93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \color{blue}{{\left(a \cdot c\right)}^{\left(2 \cdot 2\right)}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
      3. metadata-eval93.8%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot {\left(a \cdot c\right)}^{\color{blue}{4}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
    11. Simplified93.8%

      \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.25 \cdot \frac{16 \cdot \color{blue}{{\left(a \cdot c\right)}^{4}} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
    12. Step-by-step derivation
      1. *-commutative90.9%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \frac{\color{blue}{{c}^{2} \cdot a}}{{b}^{3}}\right) \]
      2. unpow390.9%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \frac{{c}^{2} \cdot a}{\color{blue}{\left(b \cdot b\right) \cdot b}}\right) \]
      3. times-frac90.9%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \color{blue}{\left(\frac{{c}^{2}}{b \cdot b} \cdot \frac{a}{b}\right)}\right) \]
      4. unpow290.9%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left(\frac{\color{blue}{c \cdot c}}{b \cdot b} \cdot \frac{a}{b}\right)\right) \]
      5. frac-times90.9%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left(\color{blue}{\left(\frac{c}{b} \cdot \frac{c}{b}\right)} \cdot \frac{a}{b}\right)\right) \]
      6. pow290.9%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left(\color{blue}{{\left(\frac{c}{b}\right)}^{2}} \cdot \frac{a}{b}\right)\right) \]
    13. Applied egg-rr93.8%

      \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + \left(-1 \cdot \color{blue}{\left({\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right)} + -0.25 \cdot \frac{16 \cdot {\left(a \cdot c\right)}^{4} + {\left(a \cdot c\right)}^{4} \cdot 4}{a \cdot {b}^{7}}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification93.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 0.022:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(\left(-0.25 \cdot \frac{16 \cdot {\left(c \cdot a\right)}^{4} + 4 \cdot {\left(c \cdot a\right)}^{4}}{a \cdot {b}^{7}} - {\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right) - \frac{c}{b}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 89.1% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 0.022:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} - \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 0.022)
   (/ (- (sqrt (fma b b (* c (* a -4.0)))) b) (* a 2.0))
   (-
    (* -2.0 (/ (* (pow c 3.0) (pow a 2.0)) (pow b 5.0)))
    (+ (/ c b) (/ (* a (pow c 2.0)) (pow b 3.0))))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 0.022) {
		tmp = (sqrt(fma(b, b, (c * (a * -4.0)))) - b) / (a * 2.0);
	} else {
		tmp = (-2.0 * ((pow(c, 3.0) * pow(a, 2.0)) / pow(b, 5.0))) - ((c / b) + ((a * pow(c, 2.0)) / pow(b, 3.0)));
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= 0.022)
		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))) - b) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(-2.0 * Float64(Float64((c ^ 3.0) * (a ^ 2.0)) / (b ^ 5.0))) - Float64(Float64(c / b) + Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, 0.022], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(N[(N[Power[c, 3.0], $MachinePrecision] * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(c / b), $MachinePrecision] + N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.022:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} - \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 0.021999999999999999

    1. Initial program 88.0%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative88.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
      2. +-commutative88.0%

        \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{a \cdot 2} \]
      3. sqr-neg88.0%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(-b\right) \cdot \left(-b\right)} - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{a \cdot 2} \]
      4. unsub-neg88.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(4 \cdot a\right) \cdot c} - b}}{a \cdot 2} \]
      5. sqr-neg88.0%

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b} - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2} \]
      6. fma-neg88.2%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b}{a \cdot 2} \]
      7. distribute-lft-neg-in88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-4 \cdot a\right) \cdot c}\right)} - b}{a \cdot 2} \]
      8. *-commutative88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)} - b}{a \cdot 2} \]
      9. *-commutative88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-\color{blue}{a \cdot 4}\right)\right)} - b}{a \cdot 2} \]
      10. distribute-rgt-neg-in88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \color{blue}{\left(a \cdot \left(-4\right)\right)}\right)} - b}{a \cdot 2} \]
      11. metadata-eval88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot \color{blue}{-4}\right)\right)} - b}{a \cdot 2} \]
    3. Simplified88.2%

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}} \]
    4. Add Preprocessing

    if 0.021999999999999999 < b

    1. Initial program 52.7%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative52.7%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified52.7%

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Taylor expanded in b around inf 90.9%

      \[\leadsto \color{blue}{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 0.022:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} - \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 89.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 0.022:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(a \cdot \left(a \cdot \left({c}^{3} \cdot {b}^{-5}\right)\right)\right) - \left(\frac{c}{b} + {\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 0.022)
   (/ (- (sqrt (fma b b (* c (* a -4.0)))) b) (* a 2.0))
   (-
    (* -2.0 (* a (* a (* (pow c 3.0) (pow b -5.0)))))
    (+ (/ c b) (* (pow (/ c b) 2.0) (/ a b))))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 0.022) {
		tmp = (sqrt(fma(b, b, (c * (a * -4.0)))) - b) / (a * 2.0);
	} else {
		tmp = (-2.0 * (a * (a * (pow(c, 3.0) * pow(b, -5.0))))) - ((c / b) + (pow((c / b), 2.0) * (a / b)));
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= 0.022)
		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))) - b) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(-2.0 * Float64(a * Float64(a * Float64((c ^ 3.0) * (b ^ -5.0))))) - Float64(Float64(c / b) + Float64((Float64(c / b) ^ 2.0) * Float64(a / b))));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, 0.022], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(a * N[(a * N[(N[Power[c, 3.0], $MachinePrecision] * N[Power[b, -5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(c / b), $MachinePrecision] + N[(N[Power[N[(c / b), $MachinePrecision], 2.0], $MachinePrecision] * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.022:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(a \cdot \left(a \cdot \left({c}^{3} \cdot {b}^{-5}\right)\right)\right) - \left(\frac{c}{b} + {\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 0.021999999999999999

    1. Initial program 88.0%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative88.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
      2. +-commutative88.0%

        \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{a \cdot 2} \]
      3. sqr-neg88.0%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(-b\right) \cdot \left(-b\right)} - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{a \cdot 2} \]
      4. unsub-neg88.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(4 \cdot a\right) \cdot c} - b}}{a \cdot 2} \]
      5. sqr-neg88.0%

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b} - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2} \]
      6. fma-neg88.2%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b}{a \cdot 2} \]
      7. distribute-lft-neg-in88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-4 \cdot a\right) \cdot c}\right)} - b}{a \cdot 2} \]
      8. *-commutative88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)} - b}{a \cdot 2} \]
      9. *-commutative88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-\color{blue}{a \cdot 4}\right)\right)} - b}{a \cdot 2} \]
      10. distribute-rgt-neg-in88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \color{blue}{\left(a \cdot \left(-4\right)\right)}\right)} - b}{a \cdot 2} \]
      11. metadata-eval88.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot \color{blue}{-4}\right)\right)} - b}{a \cdot 2} \]
    3. Simplified88.2%

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}} \]
    4. Add Preprocessing

    if 0.021999999999999999 < b

    1. Initial program 52.7%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative52.7%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified52.7%

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Taylor expanded in b around inf 90.9%

      \[\leadsto \color{blue}{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)} \]
    6. Step-by-step derivation
      1. *-commutative90.9%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \frac{\color{blue}{{c}^{2} \cdot a}}{{b}^{3}}\right) \]
      2. unpow390.9%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \frac{{c}^{2} \cdot a}{\color{blue}{\left(b \cdot b\right) \cdot b}}\right) \]
      3. times-frac90.9%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \color{blue}{\left(\frac{{c}^{2}}{b \cdot b} \cdot \frac{a}{b}\right)}\right) \]
      4. unpow290.9%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left(\frac{\color{blue}{c \cdot c}}{b \cdot b} \cdot \frac{a}{b}\right)\right) \]
      5. frac-times90.9%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left(\color{blue}{\left(\frac{c}{b} \cdot \frac{c}{b}\right)} \cdot \frac{a}{b}\right)\right) \]
      6. pow290.9%

        \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left(\color{blue}{{\left(\frac{c}{b}\right)}^{2}} \cdot \frac{a}{b}\right)\right) \]
    7. Applied egg-rr90.9%

      \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \color{blue}{\left({\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right)}\right) \]
    8. Step-by-step derivation
      1. associate-/l*90.9%

        \[\leadsto -2 \cdot \color{blue}{\left({a}^{2} \cdot \frac{{c}^{3}}{{b}^{5}}\right)} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left({\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right)\right) \]
      2. unpow290.9%

        \[\leadsto -2 \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot \frac{{c}^{3}}{{b}^{5}}\right) + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left({\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right)\right) \]
      3. associate-*l*90.9%

        \[\leadsto -2 \cdot \color{blue}{\left(a \cdot \left(a \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left({\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right)\right) \]
      4. div-inv90.9%

        \[\leadsto -2 \cdot \left(a \cdot \left(a \cdot \color{blue}{\left({c}^{3} \cdot \frac{1}{{b}^{5}}\right)}\right)\right) + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left({\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right)\right) \]
      5. pow-flip90.9%

        \[\leadsto -2 \cdot \left(a \cdot \left(a \cdot \left({c}^{3} \cdot \color{blue}{{b}^{\left(-5\right)}}\right)\right)\right) + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left({\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right)\right) \]
      6. metadata-eval90.9%

        \[\leadsto -2 \cdot \left(a \cdot \left(a \cdot \left({c}^{3} \cdot {b}^{\color{blue}{-5}}\right)\right)\right) + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left({\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right)\right) \]
    9. Applied egg-rr90.9%

      \[\leadsto -2 \cdot \color{blue}{\left(a \cdot \left(a \cdot \left({c}^{3} \cdot {b}^{-5}\right)\right)\right)} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \left({\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 0.022:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(a \cdot \left(a \cdot \left({c}^{3} \cdot {b}^{-5}\right)\right)\right) - \left(\frac{c}{b} + {\left(\frac{c}{b}\right)}^{2} \cdot \frac{a}{b}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 84.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 5:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-\mathsf{fma}\left(c, \frac{1}{b}, \left(a \cdot {c}^{2}\right) \cdot {b}^{-3}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 5.0)
   (/ (- (sqrt (fma b b (* c (* a -4.0)))) b) (* a 2.0))
   (- (fma c (/ 1.0 b) (* (* a (pow c 2.0)) (pow b -3.0))))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 5.0) {
		tmp = (sqrt(fma(b, b, (c * (a * -4.0)))) - b) / (a * 2.0);
	} else {
		tmp = -fma(c, (1.0 / b), ((a * pow(c, 2.0)) * pow(b, -3.0)));
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= 5.0)
		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))) - b) / Float64(a * 2.0));
	else
		tmp = Float64(-fma(c, Float64(1.0 / b), Float64(Float64(a * (c ^ 2.0)) * (b ^ -3.0))));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, 5.0], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], (-N[(c * N[(1.0 / b), $MachinePrecision] + N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[b, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 5:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(c, \frac{1}{b}, \left(a \cdot {c}^{2}\right) \cdot {b}^{-3}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 5

    1. Initial program 80.4%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative80.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
      2. +-commutative80.4%

        \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{a \cdot 2} \]
      3. sqr-neg80.4%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(-b\right) \cdot \left(-b\right)} - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{a \cdot 2} \]
      4. unsub-neg80.4%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(4 \cdot a\right) \cdot c} - b}}{a \cdot 2} \]
      5. sqr-neg80.4%

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b} - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2} \]
      6. fma-neg80.4%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b}{a \cdot 2} \]
      7. distribute-lft-neg-in80.4%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-4 \cdot a\right) \cdot c}\right)} - b}{a \cdot 2} \]
      8. *-commutative80.4%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)} - b}{a \cdot 2} \]
      9. *-commutative80.4%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-\color{blue}{a \cdot 4}\right)\right)} - b}{a \cdot 2} \]
      10. distribute-rgt-neg-in80.4%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \color{blue}{\left(a \cdot \left(-4\right)\right)}\right)} - b}{a \cdot 2} \]
      11. metadata-eval80.4%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot \color{blue}{-4}\right)\right)} - b}{a \cdot 2} \]
    3. Simplified80.4%

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}} \]
    4. Add Preprocessing

    if 5 < b

    1. Initial program 48.4%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative48.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified48.4%

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Taylor expanded in b around inf 87.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}} \]
    6. Step-by-step derivation
      1. distribute-lft-out87.7%

        \[\leadsto \color{blue}{-1 \cdot \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right)} \]
      2. associate-/l*87.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + \color{blue}{a \cdot \frac{{c}^{2}}{{b}^{3}}}\right) \]
    7. Simplified87.7%

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{c}{b} + a \cdot \frac{{c}^{2}}{{b}^{3}}\right)} \]
    8. Step-by-step derivation
      1. div-inv87.6%

        \[\leadsto -1 \cdot \left(\color{blue}{c \cdot \frac{1}{b}} + a \cdot \frac{{c}^{2}}{{b}^{3}}\right) \]
      2. fma-define87.7%

        \[\leadsto -1 \cdot \color{blue}{\mathsf{fma}\left(c, \frac{1}{b}, a \cdot \frac{{c}^{2}}{{b}^{3}}\right)} \]
      3. div-inv87.7%

        \[\leadsto -1 \cdot \mathsf{fma}\left(c, \frac{1}{b}, a \cdot \color{blue}{\left({c}^{2} \cdot \frac{1}{{b}^{3}}\right)}\right) \]
      4. pow-flip87.7%

        \[\leadsto -1 \cdot \mathsf{fma}\left(c, \frac{1}{b}, a \cdot \left({c}^{2} \cdot \color{blue}{{b}^{\left(-3\right)}}\right)\right) \]
      5. metadata-eval87.7%

        \[\leadsto -1 \cdot \mathsf{fma}\left(c, \frac{1}{b}, a \cdot \left({c}^{2} \cdot {b}^{\color{blue}{-3}}\right)\right) \]
    9. Applied egg-rr87.7%

      \[\leadsto -1 \cdot \color{blue}{\mathsf{fma}\left(c, \frac{1}{b}, a \cdot \left({c}^{2} \cdot {b}^{-3}\right)\right)} \]
    10. Step-by-step derivation
      1. associate-*r*87.7%

        \[\leadsto -1 \cdot \mathsf{fma}\left(c, \frac{1}{b}, \color{blue}{\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}}\right) \]
    11. Simplified87.7%

      \[\leadsto -1 \cdot \color{blue}{\mathsf{fma}\left(c, \frac{1}{b}, \left(a \cdot {c}^{2}\right) \cdot {b}^{-3}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 5:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-\mathsf{fma}\left(c, \frac{1}{b}, \left(a \cdot {c}^{2}\right) \cdot {b}^{-3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 84.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 5:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b} - a \cdot \left(c \cdot \left(c \cdot {b}^{-3}\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 5.0)
   (/ (- (sqrt (fma b b (* c (* a -4.0)))) b) (* a 2.0))
   (- (/ (- c) b) (* a (* c (* c (pow b -3.0)))))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 5.0) {
		tmp = (sqrt(fma(b, b, (c * (a * -4.0)))) - b) / (a * 2.0);
	} else {
		tmp = (-c / b) - (a * (c * (c * pow(b, -3.0))));
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= 5.0)
		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))) - b) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(Float64(-c) / b) - Float64(a * Float64(c * Float64(c * (b ^ -3.0)))));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, 5.0], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[((-c) / b), $MachinePrecision] - N[(a * N[(c * N[(c * N[Power[b, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 5:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{-c}{b} - a \cdot \left(c \cdot \left(c \cdot {b}^{-3}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 5

    1. Initial program 80.4%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative80.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
      2. +-commutative80.4%

        \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{a \cdot 2} \]
      3. sqr-neg80.4%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(-b\right) \cdot \left(-b\right)} - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{a \cdot 2} \]
      4. unsub-neg80.4%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(4 \cdot a\right) \cdot c} - b}}{a \cdot 2} \]
      5. sqr-neg80.4%

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b} - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2} \]
      6. fma-neg80.4%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b}{a \cdot 2} \]
      7. distribute-lft-neg-in80.4%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-4 \cdot a\right) \cdot c}\right)} - b}{a \cdot 2} \]
      8. *-commutative80.4%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)} - b}{a \cdot 2} \]
      9. *-commutative80.4%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-\color{blue}{a \cdot 4}\right)\right)} - b}{a \cdot 2} \]
      10. distribute-rgt-neg-in80.4%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \color{blue}{\left(a \cdot \left(-4\right)\right)}\right)} - b}{a \cdot 2} \]
      11. metadata-eval80.4%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot \color{blue}{-4}\right)\right)} - b}{a \cdot 2} \]
    3. Simplified80.4%

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}} \]
    4. Add Preprocessing

    if 5 < b

    1. Initial program 48.4%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative48.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified48.4%

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Taylor expanded in b around inf 87.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}} \]
    6. Step-by-step derivation
      1. distribute-lft-out87.7%

        \[\leadsto \color{blue}{-1 \cdot \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right)} \]
      2. associate-/l*87.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + \color{blue}{a \cdot \frac{{c}^{2}}{{b}^{3}}}\right) \]
    7. Simplified87.7%

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{c}{b} + a \cdot \frac{{c}^{2}}{{b}^{3}}\right)} \]
    8. Step-by-step derivation
      1. div-inv87.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \color{blue}{\left({c}^{2} \cdot \frac{1}{{b}^{3}}\right)}\right) \]
      2. unpow287.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot \frac{1}{{b}^{3}}\right)\right) \]
      3. associate-*l*87.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \color{blue}{\left(c \cdot \left(c \cdot \frac{1}{{b}^{3}}\right)\right)}\right) \]
      4. pow-flip87.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \left(c \cdot \left(c \cdot \color{blue}{{b}^{\left(-3\right)}}\right)\right)\right) \]
      5. metadata-eval87.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \left(c \cdot \left(c \cdot {b}^{\color{blue}{-3}}\right)\right)\right) \]
    9. Applied egg-rr87.7%

      \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \color{blue}{\left(c \cdot \left(c \cdot {b}^{-3}\right)\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 5:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b} - a \cdot \left(c \cdot \left(c \cdot {b}^{-3}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 84.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 5.2:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b} - a \cdot \left(c \cdot \left(c \cdot {b}^{-3}\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 5.2)
   (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
   (- (/ (- c) b) (* a (* c (* c (pow b -3.0)))))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 5.2) {
		tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
	} else {
		tmp = (-c / b) - (a * (c * (c * pow(b, -3.0))));
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= 5.2d0) then
        tmp = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
    else
        tmp = (-c / b) - (a * (c * (c * (b ** (-3.0d0)))))
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= 5.2) {
		tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
	} else {
		tmp = (-c / b) - (a * (c * (c * Math.pow(b, -3.0))));
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= 5.2:
		tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0)
	else:
		tmp = (-c / b) - (a * (c * (c * math.pow(b, -3.0))))
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= 5.2)
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(Float64(-c) / b) - Float64(a * Float64(c * Float64(c * (b ^ -3.0)))));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= 5.2)
		tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
	else
		tmp = (-c / b) - (a * (c * (c * (b ^ -3.0))));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, 5.2], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[((-c) / b), $MachinePrecision] - N[(a * N[(c * N[(c * N[Power[b, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.2:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{-c}{b} - a \cdot \left(c \cdot \left(c \cdot {b}^{-3}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 5.20000000000000018

    1. Initial program 80.4%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Add Preprocessing

    if 5.20000000000000018 < b

    1. Initial program 48.4%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative48.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified48.4%

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Taylor expanded in b around inf 87.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}} \]
    6. Step-by-step derivation
      1. distribute-lft-out87.7%

        \[\leadsto \color{blue}{-1 \cdot \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right)} \]
      2. associate-/l*87.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + \color{blue}{a \cdot \frac{{c}^{2}}{{b}^{3}}}\right) \]
    7. Simplified87.7%

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{c}{b} + a \cdot \frac{{c}^{2}}{{b}^{3}}\right)} \]
    8. Step-by-step derivation
      1. div-inv87.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \color{blue}{\left({c}^{2} \cdot \frac{1}{{b}^{3}}\right)}\right) \]
      2. unpow287.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot \frac{1}{{b}^{3}}\right)\right) \]
      3. associate-*l*87.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \color{blue}{\left(c \cdot \left(c \cdot \frac{1}{{b}^{3}}\right)\right)}\right) \]
      4. pow-flip87.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \left(c \cdot \left(c \cdot \color{blue}{{b}^{\left(-3\right)}}\right)\right)\right) \]
      5. metadata-eval87.7%

        \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \left(c \cdot \left(c \cdot {b}^{\color{blue}{-3}}\right)\right)\right) \]
    9. Applied egg-rr87.7%

      \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \color{blue}{\left(c \cdot \left(c \cdot {b}^{-3}\right)\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 5.2:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b} - a \cdot \left(c \cdot \left(c \cdot {b}^{-3}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 81.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{-c}{b} - a \cdot \left(c \cdot \left(c \cdot {b}^{-3}\right)\right) \end{array} \]
(FPCore (a b c)
 :precision binary64
 (- (/ (- c) b) (* a (* c (* c (pow b -3.0))))))
double code(double a, double b, double c) {
	return (-c / b) - (a * (c * (c * pow(b, -3.0))));
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-c / b) - (a * (c * (c * (b ** (-3.0d0)))))
end function
public static double code(double a, double b, double c) {
	return (-c / b) - (a * (c * (c * Math.pow(b, -3.0))));
}
def code(a, b, c):
	return (-c / b) - (a * (c * (c * math.pow(b, -3.0))))
function code(a, b, c)
	return Float64(Float64(Float64(-c) / b) - Float64(a * Float64(c * Float64(c * (b ^ -3.0)))))
end
function tmp = code(a, b, c)
	tmp = (-c / b) - (a * (c * (c * (b ^ -3.0))));
end
code[a_, b_, c_] := N[(N[((-c) / b), $MachinePrecision] - N[(a * N[(c * N[(c * N[Power[b, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-c}{b} - a \cdot \left(c \cdot \left(c \cdot {b}^{-3}\right)\right)
\end{array}
Derivation
  1. Initial program 55.6%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Step-by-step derivation
    1. *-commutative55.6%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
  3. Simplified55.6%

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
  4. Add Preprocessing
  5. Taylor expanded in b around inf 81.7%

    \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}} \]
  6. Step-by-step derivation
    1. distribute-lft-out81.7%

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right)} \]
    2. associate-/l*81.7%

      \[\leadsto -1 \cdot \left(\frac{c}{b} + \color{blue}{a \cdot \frac{{c}^{2}}{{b}^{3}}}\right) \]
  7. Simplified81.7%

    \[\leadsto \color{blue}{-1 \cdot \left(\frac{c}{b} + a \cdot \frac{{c}^{2}}{{b}^{3}}\right)} \]
  8. Step-by-step derivation
    1. div-inv81.7%

      \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \color{blue}{\left({c}^{2} \cdot \frac{1}{{b}^{3}}\right)}\right) \]
    2. unpow281.7%

      \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot \frac{1}{{b}^{3}}\right)\right) \]
    3. associate-*l*81.7%

      \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \color{blue}{\left(c \cdot \left(c \cdot \frac{1}{{b}^{3}}\right)\right)}\right) \]
    4. pow-flip81.7%

      \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \left(c \cdot \left(c \cdot \color{blue}{{b}^{\left(-3\right)}}\right)\right)\right) \]
    5. metadata-eval81.7%

      \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \left(c \cdot \left(c \cdot {b}^{\color{blue}{-3}}\right)\right)\right) \]
  9. Applied egg-rr81.7%

    \[\leadsto -1 \cdot \left(\frac{c}{b} + a \cdot \color{blue}{\left(c \cdot \left(c \cdot {b}^{-3}\right)\right)}\right) \]
  10. Final simplification81.7%

    \[\leadsto \frac{-c}{b} - a \cdot \left(c \cdot \left(c \cdot {b}^{-3}\right)\right) \]
  11. Add Preprocessing

Alternative 10: 64.2% accurate, 29.0× speedup?

\[\begin{array}{l} \\ \frac{-c}{b} \end{array} \]
(FPCore (a b c) :precision binary64 (/ (- c) b))
double code(double a, double b, double c) {
	return -c / b;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = -c / b
end function
public static double code(double a, double b, double c) {
	return -c / b;
}
def code(a, b, c):
	return -c / b
function code(a, b, c)
	return Float64(Float64(-c) / b)
end
function tmp = code(a, b, c)
	tmp = -c / b;
end
code[a_, b_, c_] := N[((-c) / b), $MachinePrecision]
\begin{array}{l}

\\
\frac{-c}{b}
\end{array}
Derivation
  1. Initial program 55.6%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Step-by-step derivation
    1. *-commutative55.6%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
  3. Simplified55.6%

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
  4. Add Preprocessing
  5. Taylor expanded in b around inf 64.1%

    \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
  6. Step-by-step derivation
    1. mul-1-neg64.1%

      \[\leadsto \color{blue}{-\frac{c}{b}} \]
    2. distribute-neg-frac64.1%

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
  7. Simplified64.1%

    \[\leadsto \color{blue}{\frac{-c}{b}} \]
  8. Final simplification64.1%

    \[\leadsto \frac{-c}{b} \]
  9. Add Preprocessing

Alternative 11: 3.2% accurate, 116.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
	return 0.0;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = 0.0d0
end function
public static double code(double a, double b, double c) {
	return 0.0;
}
def code(a, b, c):
	return 0.0
function code(a, b, c)
	return 0.0
end
function tmp = code(a, b, c)
	tmp = 0.0;
end
code[a_, b_, c_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 55.6%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Step-by-step derivation
    1. *-commutative55.6%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
  3. Simplified55.6%

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
  4. Add Preprocessing
  5. Taylor expanded in b around inf 64.0%

    \[\leadsto \frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b}}}{a \cdot 2} \]
  6. Step-by-step derivation
    1. expm1-log1p-u56.5%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{-2 \cdot \frac{a \cdot c}{b}}{a \cdot 2}\right)\right)} \]
    2. expm1-undefine44.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{-2 \cdot \frac{a \cdot c}{b}}{a \cdot 2}\right)} - 1} \]
    3. *-commutative44.7%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{-2 \cdot \frac{a \cdot c}{b}}{\color{blue}{2 \cdot a}}\right)} - 1 \]
    4. times-frac44.7%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{-2}{2} \cdot \frac{\frac{a \cdot c}{b}}{a}}\right)} - 1 \]
    5. metadata-eval44.7%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{-1} \cdot \frac{\frac{a \cdot c}{b}}{a}\right)} - 1 \]
    6. associate-/l*44.7%

      \[\leadsto e^{\mathsf{log1p}\left(-1 \cdot \frac{\color{blue}{a \cdot \frac{c}{b}}}{a}\right)} - 1 \]
  7. Applied egg-rr44.7%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(-1 \cdot \frac{a \cdot \frac{c}{b}}{a}\right)} - 1} \]
  8. Step-by-step derivation
    1. sub-neg44.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(-1 \cdot \frac{a \cdot \frac{c}{b}}{a}\right)} + \left(-1\right)} \]
    2. metadata-eval44.7%

      \[\leadsto e^{\mathsf{log1p}\left(-1 \cdot \frac{a \cdot \frac{c}{b}}{a}\right)} + \color{blue}{-1} \]
    3. +-commutative44.7%

      \[\leadsto \color{blue}{-1 + e^{\mathsf{log1p}\left(-1 \cdot \frac{a \cdot \frac{c}{b}}{a}\right)}} \]
    4. log1p-undefine44.7%

      \[\leadsto -1 + e^{\color{blue}{\log \left(1 + -1 \cdot \frac{a \cdot \frac{c}{b}}{a}\right)}} \]
    5. rem-exp-log52.2%

      \[\leadsto -1 + \color{blue}{\left(1 + -1 \cdot \frac{a \cdot \frac{c}{b}}{a}\right)} \]
    6. mul-1-neg52.2%

      \[\leadsto -1 + \left(1 + \color{blue}{\left(-\frac{a \cdot \frac{c}{b}}{a}\right)}\right) \]
    7. unsub-neg52.2%

      \[\leadsto -1 + \color{blue}{\left(1 - \frac{a \cdot \frac{c}{b}}{a}\right)} \]
    8. *-commutative52.2%

      \[\leadsto -1 + \left(1 - \frac{\color{blue}{\frac{c}{b} \cdot a}}{a}\right) \]
    9. associate-/l*52.2%

      \[\leadsto -1 + \left(1 - \color{blue}{\frac{c}{b} \cdot \frac{a}{a}}\right) \]
    10. *-inverses52.2%

      \[\leadsto -1 + \left(1 - \frac{c}{b} \cdot \color{blue}{1}\right) \]
    11. *-rgt-identity52.2%

      \[\leadsto -1 + \left(1 - \color{blue}{\frac{c}{b}}\right) \]
  9. Simplified52.2%

    \[\leadsto \color{blue}{-1 + \left(1 - \frac{c}{b}\right)} \]
  10. Taylor expanded in c around 0 3.2%

    \[\leadsto -1 + \color{blue}{1} \]
  11. Final simplification3.2%

    \[\leadsto 0 \]
  12. Add Preprocessing

Reproduce

?
herbie shell --seed 2024040 
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :precision binary64
  :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))