Quadratic roots, narrow range

Percentage Accurate: 55.6% → 99.6%
Time: 21.9s
Alternatives: 9
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 9 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.6% 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: 99.6% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \sqrt[3]{64}\\ \frac{t\_0 \cdot \left(-0.5\right)}{b + \sqrt{{b}^{2} - t\_0 \cdot a}} \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* c (cbrt 64.0))))
   (/ (* t_0 (- 0.5)) (+ b (sqrt (- (pow b 2.0) (* t_0 a)))))))
double code(double a, double b, double c) {
	double t_0 = c * cbrt(64.0);
	return (t_0 * -0.5) / (b + sqrt((pow(b, 2.0) - (t_0 * a))));
}
public static double code(double a, double b, double c) {
	double t_0 = c * Math.cbrt(64.0);
	return (t_0 * -0.5) / (b + Math.sqrt((Math.pow(b, 2.0) - (t_0 * a))));
}
function code(a, b, c)
	t_0 = Float64(c * cbrt(64.0))
	return Float64(Float64(t_0 * Float64(-0.5)) / Float64(b + sqrt(Float64((b ^ 2.0) - Float64(t_0 * a)))))
end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[Power[64.0, 1/3], $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 * (-0.5)), $MachinePrecision] / N[(b + N[Sqrt[N[(N[Power[b, 2.0], $MachinePrecision] - N[(t$95$0 * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot \sqrt[3]{64}\\
\frac{t\_0 \cdot \left(-0.5\right)}{b + \sqrt{{b}^{2} - t\_0 \cdot a}}
\end{array}
\end{array}
Derivation
  1. Initial program 57.3%

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

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

    \[\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. Step-by-step derivation
    1. add-cbrt-cube57.2%

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({\left(\left(4 \cdot a\right) \cdot c\right)}^{3}\right)}}^{0.3333333333333333}}}{a \cdot 2} \]
    4. associate-*l*57.1%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\color{blue}{\left(4 \cdot \left(a \cdot c\right)\right)}}^{3}\right)}^{0.3333333333333333}}}{a \cdot 2} \]
    5. unpow-prod-down57.1%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left(\color{blue}{64} \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}{a \cdot 2} \]
  6. Applied egg-rr57.1%

    \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
  7. Step-by-step derivation
    1. flip-+57.0%

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}} \cdot \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}}{a \cdot 2} \]
    2. pow257.1%

      \[\leadsto \frac{\frac{\color{blue}{{\left(-b\right)}^{2}} - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}} \cdot \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
    3. add-sqr-sqrt58.6%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\left(b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}\right)}}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
    4. pow258.5%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left(\color{blue}{{b}^{2}} - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
    5. unpow1/358.7%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \color{blue}{\sqrt[3]{64 \cdot {\left(a \cdot c\right)}^{3}}}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
    6. *-commutative58.7%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \sqrt[3]{\color{blue}{{\left(a \cdot c\right)}^{3} \cdot 64}}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
    7. cbrt-prod58.7%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \color{blue}{\sqrt[3]{{\left(a \cdot c\right)}^{3}} \cdot \sqrt[3]{64}}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
    8. unpow358.7%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \sqrt[3]{\color{blue}{\left(\left(a \cdot c\right) \cdot \left(a \cdot c\right)\right) \cdot \left(a \cdot c\right)}} \cdot \sqrt[3]{64}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
    9. add-cbrt-cube58.7%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \color{blue}{\left(a \cdot c\right)} \cdot \sqrt[3]{64}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
    10. *-commutative58.7%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \color{blue}{\left(c \cdot a\right)} \cdot \sqrt[3]{64}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
  8. Applied egg-rr58.7%

    \[\leadsto \frac{\color{blue}{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}\right)}{\left(-b\right) - \sqrt{{b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}}}}}{a \cdot 2} \]
  9. Step-by-step derivation
    1. *-un-lft-identity58.7%

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

      \[\leadsto 1 \cdot \color{blue}{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}}\right)}} \]
    3. associate--r-99.2%

      \[\leadsto 1 \cdot \frac{\color{blue}{\left({\left(-b\right)}^{2} - {b}^{2}\right) + \left(c \cdot a\right) \cdot \sqrt[3]{64}}}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}}\right)} \]
    4. neg-mul-199.2%

      \[\leadsto 1 \cdot \frac{\left({\color{blue}{\left(-1 \cdot b\right)}}^{2} - {b}^{2}\right) + \left(c \cdot a\right) \cdot \sqrt[3]{64}}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}}\right)} \]
    5. unpow-prod-down99.2%

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

      \[\leadsto 1 \cdot \frac{\left(\color{blue}{1} \cdot {b}^{2} - {b}^{2}\right) + \left(c \cdot a\right) \cdot \sqrt[3]{64}}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}}\right)} \]
    7. *-un-lft-identity99.2%

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

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

      \[\leadsto 1 \cdot \frac{\left({b}^{2} - {b}^{2}\right) + c \cdot \left(a \cdot \sqrt[3]{64}\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - \color{blue}{c \cdot \left(a \cdot \sqrt[3]{64}\right)}}\right)} \]
  10. Applied egg-rr99.2%

    \[\leadsto \color{blue}{1 \cdot \frac{\left({b}^{2} - {b}^{2}\right) + c \cdot \left(a \cdot \sqrt[3]{64}\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot \sqrt[3]{64}\right)}\right)}} \]
  11. Step-by-step derivation
    1. *-lft-identity99.2%

      \[\leadsto \color{blue}{\frac{\left({b}^{2} - {b}^{2}\right) + c \cdot \left(a \cdot \sqrt[3]{64}\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot \sqrt[3]{64}\right)}\right)}} \]
    2. associate-/r*99.4%

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

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

      \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(a \cdot \sqrt[3]{64}\right)}}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot \sqrt[3]{64}\right)}} \]
    5. associate-*r*99.4%

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

      \[\leadsto \frac{\frac{\color{blue}{\left(a \cdot c\right)} \cdot \sqrt[3]{64}}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot \sqrt[3]{64}\right)}} \]
    7. associate-*r*99.4%

      \[\leadsto \frac{\frac{\color{blue}{a \cdot \left(c \cdot \sqrt[3]{64}\right)}}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot \sqrt[3]{64}\right)}} \]
    8. associate-*r*99.4%

      \[\leadsto \frac{\frac{a \cdot \left(c \cdot \sqrt[3]{64}\right)}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - \color{blue}{\left(c \cdot a\right) \cdot \sqrt[3]{64}}}} \]
    9. *-commutative99.4%

      \[\leadsto \frac{\frac{a \cdot \left(c \cdot \sqrt[3]{64}\right)}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - \color{blue}{\left(a \cdot c\right)} \cdot \sqrt[3]{64}}} \]
    10. associate-*r*99.4%

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

    \[\leadsto \color{blue}{\frac{\frac{a \cdot \left(c \cdot \sqrt[3]{64}\right)}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - a \cdot \left(c \cdot \sqrt[3]{64}\right)}}} \]
  13. Taylor expanded in a around 0 99.5%

    \[\leadsto \frac{\color{blue}{0.5 \cdot \left(c \cdot \sqrt[3]{64}\right)}}{\left(-b\right) - \sqrt{{b}^{2} - a \cdot \left(c \cdot \sqrt[3]{64}\right)}} \]
  14. Step-by-step derivation
    1. *-commutative99.5%

      \[\leadsto \frac{\color{blue}{\left(c \cdot \sqrt[3]{64}\right) \cdot 0.5}}{\left(-b\right) - \sqrt{{b}^{2} - a \cdot \left(c \cdot \sqrt[3]{64}\right)}} \]
  15. Simplified99.5%

    \[\leadsto \frac{\color{blue}{\left(c \cdot \sqrt[3]{64}\right) \cdot 0.5}}{\left(-b\right) - \sqrt{{b}^{2} - a \cdot \left(c \cdot \sqrt[3]{64}\right)}} \]
  16. Final simplification99.5%

    \[\leadsto \frac{\left(c \cdot \sqrt[3]{64}\right) \cdot \left(-0.5\right)}{b + \sqrt{{b}^{2} - \left(c \cdot \sqrt[3]{64}\right) \cdot a}} \]
  17. Add Preprocessing

Alternative 2: 89.4% accurate, 0.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.40000000000000002

    1. Initial program 86.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. *-commutative86.0%

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

        \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{a \cdot 2} \]
      3. sqr-neg86.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-neg86.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-neg86.0%

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b} - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2} \]
      6. fma-neg86.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-in86.4%

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

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)} - b}{a \cdot 2} \]
      9. *-commutative86.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-in86.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-eval86.4%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot \color{blue}{-4}\right)\right)} - b}{a \cdot 2} \]
    3. Simplified86.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 -0.40000000000000002 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 50.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. *-commutative50.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified50.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 a around 0 93.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -0.25 \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right)} \]
    6. Taylor expanded in c around 0 93.7%

      \[\leadsto -1 \cdot \frac{c}{b} + a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + \color{blue}{-5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}}\right)\right) \]
    7. Taylor expanded in a around 0 91.4%

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

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

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

      \[\leadsto -1 \cdot \frac{c}{b} + a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + \color{blue}{\frac{\left(-2 \cdot a\right) \cdot {c}^{3}}{{b}^{5}}}\right) \]
    10. Taylor expanded in c around inf 91.4%

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

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

Alternative 3: 89.3% accurate, 0.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.40000000000000002

    1. Initial program 86.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. *-commutative86.0%

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

        \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{a \cdot 2} \]
      3. sqr-neg86.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-neg86.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-neg86.0%

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b} - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2} \]
      6. fma-neg86.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-in86.4%

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

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)} - b}{a \cdot 2} \]
      9. *-commutative86.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-in86.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-eval86.4%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot \color{blue}{-4}\right)\right)} - b}{a \cdot 2} \]
    3. Simplified86.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 -0.40000000000000002 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 50.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. *-commutative50.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified50.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 c around 0 91.2%

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

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

Alternative 4: 85.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(c \cdot \sqrt[3]{64}\right) \cdot a\\ \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a} \leq -0.002648:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t\_0}{2 \cdot a}}{0.5 \cdot \frac{t\_0}{b} - b \cdot 2}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* (* c (cbrt 64.0)) a)))
   (if (<= (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a)) -0.002648)
     (/ (- (sqrt (fma b b (* c (* a -4.0)))) b) (* 2.0 a))
     (/ (/ t_0 (* 2.0 a)) (- (* 0.5 (/ t_0 b)) (* b 2.0))))))
double code(double a, double b, double c) {
	double t_0 = (c * cbrt(64.0)) * a;
	double tmp;
	if (((sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a)) <= -0.002648) {
		tmp = (sqrt(fma(b, b, (c * (a * -4.0)))) - b) / (2.0 * a);
	} else {
		tmp = (t_0 / (2.0 * a)) / ((0.5 * (t_0 / b)) - (b * 2.0));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = Float64(Float64(c * cbrt(64.0)) * a)
	tmp = 0.0
	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a)) <= -0.002648)
		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))) - b) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(t_0 / Float64(2.0 * a)) / Float64(Float64(0.5 * Float64(t_0 / b)) - Float64(b * 2.0)));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * N[Power[64.0, 1/3], $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], -0.002648], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] / N[(N[(0.5 * N[(t$95$0 / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{2 \cdot a}}{0.5 \cdot \frac{t\_0}{b} - b \cdot 2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.0026480000000000002

    1. Initial program 80.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. *-commutative80.6%

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

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

        \[\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.6%

        \[\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.6%

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

        \[\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.9%

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

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

        \[\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.9%

        \[\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.9%

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

      \[\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.0026480000000000002 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 45.9%

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

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

      \[\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. Step-by-step derivation
      1. add-cbrt-cube45.8%

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({\left(\left(4 \cdot a\right) \cdot c\right)}^{3}\right)}}^{0.3333333333333333}}}{a \cdot 2} \]
      4. associate-*l*45.8%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\color{blue}{\left(4 \cdot \left(a \cdot c\right)\right)}}^{3}\right)}^{0.3333333333333333}}}{a \cdot 2} \]
      5. unpow-prod-down45.8%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left(\color{blue}{64} \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}{a \cdot 2} \]
    6. Applied egg-rr45.8%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
    7. Step-by-step derivation
      1. flip-+45.7%

        \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}} \cdot \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}}{a \cdot 2} \]
      2. pow245.8%

        \[\leadsto \frac{\frac{\color{blue}{{\left(-b\right)}^{2}} - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}} \cdot \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
      3. add-sqr-sqrt47.4%

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

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left(\color{blue}{{b}^{2}} - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
      5. unpow1/347.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \color{blue}{\sqrt[3]{64 \cdot {\left(a \cdot c\right)}^{3}}}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
      6. *-commutative47.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \sqrt[3]{\color{blue}{{\left(a \cdot c\right)}^{3} \cdot 64}}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
      7. cbrt-prod47.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \color{blue}{\sqrt[3]{{\left(a \cdot c\right)}^{3}} \cdot \sqrt[3]{64}}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
      8. unpow347.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \sqrt[3]{\color{blue}{\left(\left(a \cdot c\right) \cdot \left(a \cdot c\right)\right) \cdot \left(a \cdot c\right)}} \cdot \sqrt[3]{64}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
      9. add-cbrt-cube47.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \color{blue}{\left(a \cdot c\right)} \cdot \sqrt[3]{64}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
      10. *-commutative47.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \color{blue}{\left(c \cdot a\right)} \cdot \sqrt[3]{64}\right)}{\left(-b\right) - \sqrt{b \cdot b - {\left(64 \cdot {\left(a \cdot c\right)}^{3}\right)}^{0.3333333333333333}}}}{a \cdot 2} \]
    8. Applied egg-rr47.4%

      \[\leadsto \frac{\color{blue}{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}\right)}{\left(-b\right) - \sqrt{{b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}}}}}{a \cdot 2} \]
    9. Step-by-step derivation
      1. *-un-lft-identity47.4%

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

        \[\leadsto 1 \cdot \color{blue}{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}}\right)}} \]
      3. associate--r-99.3%

        \[\leadsto 1 \cdot \frac{\color{blue}{\left({\left(-b\right)}^{2} - {b}^{2}\right) + \left(c \cdot a\right) \cdot \sqrt[3]{64}}}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}}\right)} \]
      4. neg-mul-199.3%

        \[\leadsto 1 \cdot \frac{\left({\color{blue}{\left(-1 \cdot b\right)}}^{2} - {b}^{2}\right) + \left(c \cdot a\right) \cdot \sqrt[3]{64}}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}}\right)} \]
      5. unpow-prod-down99.3%

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

        \[\leadsto 1 \cdot \frac{\left(\color{blue}{1} \cdot {b}^{2} - {b}^{2}\right) + \left(c \cdot a\right) \cdot \sqrt[3]{64}}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - \left(c \cdot a\right) \cdot \sqrt[3]{64}}\right)} \]
      7. *-un-lft-identity99.3%

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

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

        \[\leadsto 1 \cdot \frac{\left({b}^{2} - {b}^{2}\right) + c \cdot \left(a \cdot \sqrt[3]{64}\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - \color{blue}{c \cdot \left(a \cdot \sqrt[3]{64}\right)}}\right)} \]
    10. Applied egg-rr99.3%

      \[\leadsto \color{blue}{1 \cdot \frac{\left({b}^{2} - {b}^{2}\right) + c \cdot \left(a \cdot \sqrt[3]{64}\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot \sqrt[3]{64}\right)}\right)}} \]
    11. Step-by-step derivation
      1. *-lft-identity99.3%

        \[\leadsto \color{blue}{\frac{\left({b}^{2} - {b}^{2}\right) + c \cdot \left(a \cdot \sqrt[3]{64}\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot \sqrt[3]{64}\right)}\right)}} \]
      2. associate-/r*99.5%

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

        \[\leadsto \frac{\frac{\color{blue}{0} + c \cdot \left(a \cdot \sqrt[3]{64}\right)}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot \sqrt[3]{64}\right)}} \]
      4. +-lft-identity99.5%

        \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(a \cdot \sqrt[3]{64}\right)}}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot \sqrt[3]{64}\right)}} \]
      5. associate-*r*99.5%

        \[\leadsto \frac{\frac{\color{blue}{\left(c \cdot a\right) \cdot \sqrt[3]{64}}}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot \sqrt[3]{64}\right)}} \]
      6. *-commutative99.5%

        \[\leadsto \frac{\frac{\color{blue}{\left(a \cdot c\right)} \cdot \sqrt[3]{64}}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot \sqrt[3]{64}\right)}} \]
      7. associate-*r*99.5%

        \[\leadsto \frac{\frac{\color{blue}{a \cdot \left(c \cdot \sqrt[3]{64}\right)}}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot \sqrt[3]{64}\right)}} \]
      8. associate-*r*99.5%

        \[\leadsto \frac{\frac{a \cdot \left(c \cdot \sqrt[3]{64}\right)}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - \color{blue}{\left(c \cdot a\right) \cdot \sqrt[3]{64}}}} \]
      9. *-commutative99.5%

        \[\leadsto \frac{\frac{a \cdot \left(c \cdot \sqrt[3]{64}\right)}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - \color{blue}{\left(a \cdot c\right)} \cdot \sqrt[3]{64}}} \]
      10. associate-*r*99.5%

        \[\leadsto \frac{\frac{a \cdot \left(c \cdot \sqrt[3]{64}\right)}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - \color{blue}{a \cdot \left(c \cdot \sqrt[3]{64}\right)}}} \]
    12. Simplified99.5%

      \[\leadsto \color{blue}{\frac{\frac{a \cdot \left(c \cdot \sqrt[3]{64}\right)}{a \cdot 2}}{\left(-b\right) - \sqrt{{b}^{2} - a \cdot \left(c \cdot \sqrt[3]{64}\right)}}} \]
    13. Taylor expanded in a around 0 89.8%

      \[\leadsto \frac{\frac{a \cdot \left(c \cdot \sqrt[3]{64}\right)}{a \cdot 2}}{\color{blue}{0.5 \cdot \frac{a \cdot \left(c \cdot \sqrt[3]{64}\right)}{b} - 2 \cdot b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.9%

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

Alternative 5: 85.1% accurate, 0.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.0026480000000000002

    1. Initial program 80.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. *-commutative80.6%

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

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

        \[\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.6%

        \[\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.6%

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

        \[\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.9%

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

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

        \[\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.9%

        \[\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.9%

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

      \[\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.0026480000000000002 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 45.9%

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

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

      \[\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 89.4%

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

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

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

      \[\leadsto \frac{\color{blue}{a \cdot \left(-2 \cdot \left(\frac{c}{b} + a \cdot \frac{{c}^{2}}{{b}^{3}}\right)\right)}}{a \cdot 2} \]
    8. Taylor expanded in b around inf 89.5%

      \[\leadsto \color{blue}{\frac{-1 \cdot c + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}} \]
    9. Step-by-step derivation
      1. neg-mul-189.5%

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

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

        \[\leadsto \frac{\color{blue}{-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} - c}}{b} \]
      4. mul-1-neg89.5%

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

        \[\leadsto \frac{\left(-\color{blue}{a \cdot \frac{{c}^{2}}{{b}^{2}}}\right) - c}{b} \]
      6. distribute-lft-neg-in89.5%

        \[\leadsto \frac{\color{blue}{\left(-a\right) \cdot \frac{{c}^{2}}{{b}^{2}}} - c}{b} \]
      7. unpow289.5%

        \[\leadsto \frac{\left(-a\right) \cdot \frac{\color{blue}{c \cdot c}}{{b}^{2}} - c}{b} \]
      8. unpow289.5%

        \[\leadsto \frac{\left(-a\right) \cdot \frac{c \cdot c}{\color{blue}{b \cdot b}} - c}{b} \]
      9. times-frac89.5%

        \[\leadsto \frac{\left(-a\right) \cdot \color{blue}{\left(\frac{c}{b} \cdot \frac{c}{b}\right)} - c}{b} \]
      10. unpow189.5%

        \[\leadsto \frac{\left(-a\right) \cdot \left(\color{blue}{{\left(\frac{c}{b}\right)}^{1}} \cdot \frac{c}{b}\right) - c}{b} \]
      11. pow-plus89.5%

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

        \[\leadsto \frac{\left(-a\right) \cdot {\left(\frac{c}{b}\right)}^{\color{blue}{2}} - c}{b} \]
    10. Simplified89.5%

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

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

Alternative 6: 85.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\ \mathbf{if}\;t\_0 \leq -0.002648:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot \left(-{\left(\frac{c}{b}\right)}^{2}\right) - c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a))))
   (if (<= t_0 -0.002648) t_0 (/ (- (* a (- (pow (/ c b) 2.0))) c) b))))
double code(double a, double b, double c) {
	double t_0 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
	double tmp;
	if (t_0 <= -0.002648) {
		tmp = t_0;
	} else {
		tmp = ((a * -pow((c / b), 2.0)) - c) / b;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (2.0d0 * a)
    if (t_0 <= (-0.002648d0)) then
        tmp = t_0
    else
        tmp = ((a * -((c / b) ** 2.0d0)) - c) / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double t_0 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
	double tmp;
	if (t_0 <= -0.002648) {
		tmp = t_0;
	} else {
		tmp = ((a * -Math.pow((c / b), 2.0)) - c) / b;
	}
	return tmp;
}
def code(a, b, c):
	t_0 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a)
	tmp = 0
	if t_0 <= -0.002648:
		tmp = t_0
	else:
		tmp = ((a * -math.pow((c / b), 2.0)) - c) / b
	return tmp
function code(a, b, c)
	t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a))
	tmp = 0.0
	if (t_0 <= -0.002648)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(a * Float64(-(Float64(c / b) ^ 2.0))) - c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	t_0 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
	tmp = 0.0;
	if (t_0 <= -0.002648)
		tmp = t_0;
	else
		tmp = ((a * -((c / b) ^ 2.0)) - c) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.002648], t$95$0, N[(N[(N[(a * (-N[Power[N[(c / b), $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision] - c), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.0026480000000000002

    1. Initial program 80.6%

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

    if -0.0026480000000000002 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 45.9%

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

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

      \[\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 89.4%

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

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

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

      \[\leadsto \frac{\color{blue}{a \cdot \left(-2 \cdot \left(\frac{c}{b} + a \cdot \frac{{c}^{2}}{{b}^{3}}\right)\right)}}{a \cdot 2} \]
    8. Taylor expanded in b around inf 89.5%

      \[\leadsto \color{blue}{\frac{-1 \cdot c + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}} \]
    9. Step-by-step derivation
      1. neg-mul-189.5%

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

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

        \[\leadsto \frac{\color{blue}{-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} - c}}{b} \]
      4. mul-1-neg89.5%

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

        \[\leadsto \frac{\left(-\color{blue}{a \cdot \frac{{c}^{2}}{{b}^{2}}}\right) - c}{b} \]
      6. distribute-lft-neg-in89.5%

        \[\leadsto \frac{\color{blue}{\left(-a\right) \cdot \frac{{c}^{2}}{{b}^{2}}} - c}{b} \]
      7. unpow289.5%

        \[\leadsto \frac{\left(-a\right) \cdot \frac{\color{blue}{c \cdot c}}{{b}^{2}} - c}{b} \]
      8. unpow289.5%

        \[\leadsto \frac{\left(-a\right) \cdot \frac{c \cdot c}{\color{blue}{b \cdot b}} - c}{b} \]
      9. times-frac89.5%

        \[\leadsto \frac{\left(-a\right) \cdot \color{blue}{\left(\frac{c}{b} \cdot \frac{c}{b}\right)} - c}{b} \]
      10. unpow189.5%

        \[\leadsto \frac{\left(-a\right) \cdot \left(\color{blue}{{\left(\frac{c}{b}\right)}^{1}} \cdot \frac{c}{b}\right) - c}{b} \]
      11. pow-plus89.5%

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

        \[\leadsto \frac{\left(-a\right) \cdot {\left(\frac{c}{b}\right)}^{\color{blue}{2}} - c}{b} \]
    10. Simplified89.5%

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

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

Alternative 7: 81.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{a \cdot \left(-{\left(\frac{c}{b}\right)}^{2}\right) - c}{b} \end{array} \]
(FPCore (a b c) :precision binary64 (/ (- (* a (- (pow (/ c b) 2.0))) c) b))
double code(double a, double b, double c) {
	return ((a * -pow((c / b), 2.0)) - 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 = ((a * -((c / b) ** 2.0d0)) - c) / b
end function
public static double code(double a, double b, double c) {
	return ((a * -Math.pow((c / b), 2.0)) - c) / b;
}
def code(a, b, c):
	return ((a * -math.pow((c / b), 2.0)) - c) / b
function code(a, b, c)
	return Float64(Float64(Float64(a * Float64(-(Float64(c / b) ^ 2.0))) - c) / b)
end
function tmp = code(a, b, c)
	tmp = ((a * -((c / b) ^ 2.0)) - c) / b;
end
code[a_, b_, c_] := N[(N[(N[(a * (-N[Power[N[(c / b), $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision] - c), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}

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

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

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

    \[\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 79.9%

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

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

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

    \[\leadsto \frac{\color{blue}{a \cdot \left(-2 \cdot \left(\frac{c}{b} + a \cdot \frac{{c}^{2}}{{b}^{3}}\right)\right)}}{a \cdot 2} \]
  8. Taylor expanded in b around inf 80.0%

    \[\leadsto \color{blue}{\frac{-1 \cdot c + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}} \]
  9. Step-by-step derivation
    1. neg-mul-180.0%

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} - c}}{b} \]
    4. mul-1-neg80.0%

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

      \[\leadsto \frac{\left(-\color{blue}{a \cdot \frac{{c}^{2}}{{b}^{2}}}\right) - c}{b} \]
    6. distribute-lft-neg-in80.0%

      \[\leadsto \frac{\color{blue}{\left(-a\right) \cdot \frac{{c}^{2}}{{b}^{2}}} - c}{b} \]
    7. unpow280.0%

      \[\leadsto \frac{\left(-a\right) \cdot \frac{\color{blue}{c \cdot c}}{{b}^{2}} - c}{b} \]
    8. unpow280.0%

      \[\leadsto \frac{\left(-a\right) \cdot \frac{c \cdot c}{\color{blue}{b \cdot b}} - c}{b} \]
    9. times-frac80.0%

      \[\leadsto \frac{\left(-a\right) \cdot \color{blue}{\left(\frac{c}{b} \cdot \frac{c}{b}\right)} - c}{b} \]
    10. unpow180.0%

      \[\leadsto \frac{\left(-a\right) \cdot \left(\color{blue}{{\left(\frac{c}{b}\right)}^{1}} \cdot \frac{c}{b}\right) - c}{b} \]
    11. pow-plus80.0%

      \[\leadsto \frac{\left(-a\right) \cdot \color{blue}{{\left(\frac{c}{b}\right)}^{\left(1 + 1\right)}} - c}{b} \]
    12. metadata-eval80.0%

      \[\leadsto \frac{\left(-a\right) \cdot {\left(\frac{c}{b}\right)}^{\color{blue}{2}} - c}{b} \]
  10. Simplified80.0%

    \[\leadsto \color{blue}{\frac{\left(-a\right) \cdot {\left(\frac{c}{b}\right)}^{2} - c}{b}} \]
  11. Final simplification80.0%

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

Alternative 8: 81.3% accurate, 5.5× speedup?

\[\begin{array}{l} \\ \frac{a \cdot \frac{-2 \cdot \left(c + a \cdot \left(\frac{c}{b} \cdot \frac{c}{b}\right)\right)}{b}}{2 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (* a (/ (* -2.0 (+ c (* a (* (/ c b) (/ c b))))) b)) (* 2.0 a)))
double code(double a, double b, double c) {
	return (a * ((-2.0 * (c + (a * ((c / b) * (c / b))))) / b)) / (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 = (a * (((-2.0d0) * (c + (a * ((c / b) * (c / b))))) / b)) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (a * ((-2.0 * (c + (a * ((c / b) * (c / b))))) / b)) / (2.0 * a);
}
def code(a, b, c):
	return (a * ((-2.0 * (c + (a * ((c / b) * (c / b))))) / b)) / (2.0 * a)
function code(a, b, c)
	return Float64(Float64(a * Float64(Float64(-2.0 * Float64(c + Float64(a * Float64(Float64(c / b) * Float64(c / b))))) / b)) / Float64(2.0 * a))
end
function tmp = code(a, b, c)
	tmp = (a * ((-2.0 * (c + (a * ((c / b) * (c / b))))) / b)) / (2.0 * a);
end
code[a_, b_, c_] := N[(N[(a * N[(N[(-2.0 * N[(c + N[(a * N[(N[(c / b), $MachinePrecision] * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{a \cdot \frac{-2 \cdot \left(c + a \cdot \left(\frac{c}{b} \cdot \frac{c}{b}\right)\right)}{b}}{2 \cdot a}
\end{array}
Derivation
  1. Initial program 57.3%

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

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

    \[\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 79.9%

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

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

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

    \[\leadsto \frac{\color{blue}{a \cdot \left(-2 \cdot \left(\frac{c}{b} + a \cdot \frac{{c}^{2}}{{b}^{3}}\right)\right)}}{a \cdot 2} \]
  8. Taylor expanded in b around inf 79.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{a \cdot \frac{-2 \cdot \left(c + a \cdot \color{blue}{\left(\frac{c}{b} \cdot \frac{c}{b}\right)}\right)}{b}}{a \cdot 2} \]
  12. Applied egg-rr79.9%

    \[\leadsto \frac{a \cdot \frac{-2 \cdot \left(c + a \cdot \color{blue}{\left(\frac{c}{b} \cdot \frac{c}{b}\right)}\right)}{b}}{a \cdot 2} \]
  13. Final simplification79.9%

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

Alternative 9: 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(c / Float64(-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 57.3%

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

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

    \[\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 62.2%

    \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
  6. Step-by-step derivation
    1. associate-*r/62.2%

      \[\leadsto \color{blue}{\frac{-1 \cdot c}{b}} \]
    2. mul-1-neg62.2%

      \[\leadsto \frac{\color{blue}{-c}}{b} \]
  7. Simplified62.2%

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

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

Reproduce

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