Quadratic roots, wide range

Percentage Accurate: 18.1% → 97.8%
Time: 8.1s
Alternatives: 7
Speedup: 29.0×

Specification

?
\[\left(\left(4.930380657631324 \cdot 10^{-32} < a \land a < 2.028240960365167 \cdot 10^{+31}\right) \land \left(4.930380657631324 \cdot 10^{-32} < b \land b < 2.028240960365167 \cdot 10^{+31}\right)\right) \land \left(4.930380657631324 \cdot 10^{-32} < c \land c < 2.028240960365167 \cdot 10^{+31}\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 7 alternatives:

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

Initial Program: 18.1% 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: 97.8% accurate, 0.2× speedup?

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

\\
\left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\frac{{c}^{4}}{{b}^{6}} \cdot \left(-5 \cdot {a}^{3}\right)}{b}\right) - \frac{c}{b}\right) - a \cdot \frac{c}{\frac{{b}^{3}}{c}}
\end{array}
Derivation
  1. Initial program 17.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Taylor expanded in a around 0 96.9%

    \[\leadsto \color{blue}{-1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(-1 \cdot \frac{c}{b} + \left(-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} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right)} \]
  3. Simplified96.9%

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

    \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\left(-0.25 \cdot {a}^{3}\right) \cdot \color{blue}{\left(20 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
  5. Step-by-step derivation
    1. *-commutative96.9%

      \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\left(-0.25 \cdot {a}^{3}\right) \cdot \color{blue}{\left(\frac{{c}^{4}}{{b}^{6}} \cdot 20\right)}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
    2. associate-*l/96.9%

      \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\left(-0.25 \cdot {a}^{3}\right) \cdot \color{blue}{\frac{{c}^{4} \cdot 20}{{b}^{6}}}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
    3. associate-/l*96.9%

      \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\left(-0.25 \cdot {a}^{3}\right) \cdot \color{blue}{\frac{{c}^{4}}{\frac{{b}^{6}}{20}}}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
  6. Simplified96.9%

    \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\left(-0.25 \cdot {a}^{3}\right) \cdot \color{blue}{\frac{{c}^{4}}{\frac{{b}^{6}}{20}}}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
  7. Step-by-step derivation
    1. pow196.9%

      \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\color{blue}{{\left(\left(-0.25 \cdot {a}^{3}\right) \cdot \frac{{c}^{4}}{\frac{{b}^{6}}{20}}\right)}^{1}}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
    2. *-commutative96.9%

      \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{{\color{blue}{\left(\frac{{c}^{4}}{\frac{{b}^{6}}{20}} \cdot \left(-0.25 \cdot {a}^{3}\right)\right)}}^{1}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
    3. associate-/r/96.9%

      \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{{\left(\color{blue}{\left(\frac{{c}^{4}}{{b}^{6}} \cdot 20\right)} \cdot \left(-0.25 \cdot {a}^{3}\right)\right)}^{1}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
  8. Applied egg-rr96.9%

    \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\color{blue}{{\left(\left(\frac{{c}^{4}}{{b}^{6}} \cdot 20\right) \cdot \left(-0.25 \cdot {a}^{3}\right)\right)}^{1}}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
  9. Step-by-step derivation
    1. unpow196.9%

      \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\color{blue}{\left(\frac{{c}^{4}}{{b}^{6}} \cdot 20\right) \cdot \left(-0.25 \cdot {a}^{3}\right)}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
    2. associate-*l*96.9%

      \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\color{blue}{\frac{{c}^{4}}{{b}^{6}} \cdot \left(20 \cdot \left(-0.25 \cdot {a}^{3}\right)\right)}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
    3. associate-*r*96.9%

      \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\frac{{c}^{4}}{{b}^{6}} \cdot \color{blue}{\left(\left(20 \cdot -0.25\right) \cdot {a}^{3}\right)}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
    4. metadata-eval96.9%

      \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\frac{{c}^{4}}{{b}^{6}} \cdot \left(\color{blue}{-5} \cdot {a}^{3}\right)}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
  10. Simplified96.9%

    \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\color{blue}{\frac{{c}^{4}}{{b}^{6}} \cdot \left(-5 \cdot {a}^{3}\right)}}{b}\right) - \frac{c}{b}\right) - \frac{c}{\frac{{b}^{3}}{c}} \cdot a \]
  11. Final simplification96.9%

    \[\leadsto \left(\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{\frac{{c}^{4}}{{b}^{6}} \cdot \left(-5 \cdot {a}^{3}\right)}{b}\right) - \frac{c}{b}\right) - a \cdot \frac{c}{\frac{{b}^{3}}{c}} \]

Alternative 2: 97.0% accurate, 0.4× speedup?

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

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

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Taylor expanded in b around inf 96.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{-2 \cdot \left(a \cdot \left(a \cdot {c}^{3}\right)\right)}{{b}^{5}} - \frac{c}{b}\right) - \color{blue}{\frac{{c}^{2}}{\frac{{b}^{3}}{a}}} \]
    12. associate-/r/96.2%

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

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

    \[\leadsto \left(\frac{-2 \cdot \left(a \cdot \left({c}^{3} \cdot a\right)\right)}{{b}^{5}} - \frac{c}{b}\right) - a \cdot \frac{c}{\frac{{b}^{3}}{c}} \]

Alternative 3: 95.6% accurate, 0.4× speedup?

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

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

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Taylor expanded in b around inf 12.3%

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

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

    \[\leadsto \frac{\left(-b\right) + \color{blue}{\left(b + \frac{-2 \cdot \left(c \cdot a\right)}{b}\right)}}{2 \cdot a} \]
  5. Step-by-step derivation
    1. flip-+12.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\left(-a\right) \cdot \left(c \cdot c\right)}{{b}^{3}} - \left(\frac{c}{b} + \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right)\right)} \]
  13. Final simplification95.0%

    \[\leadsto \frac{a \cdot \left(c \cdot \left(-c\right)\right)}{{b}^{3}} - \left(\frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right) + \frac{c}{b}\right) \]

Alternative 4: 95.4% accurate, 1.0× speedup?

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

\\
\frac{-c}{b} - a \cdot \frac{c}{\frac{{b}^{3}}{c}}
\end{array}
Derivation
  1. Initial program 17.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Taylor expanded in b around inf 94.8%

    \[\leadsto \color{blue}{-1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + -1 \cdot \frac{c}{b}} \]
  3. Step-by-step derivation
    1. +-commutative94.8%

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}} \]
    2. mul-1-neg94.8%

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

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

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

      \[\leadsto \left(-\frac{c}{b}\right) - \color{blue}{\frac{{c}^{2}}{\frac{{b}^{3}}{a}}} \]
    6. associate-/r/94.8%

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

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

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

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

    \[\leadsto \frac{-c}{b} - a \cdot \frac{c}{\frac{{b}^{3}}{c}} \]

Alternative 5: 95.2% accurate, 5.5× speedup?

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

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

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Taylor expanded in b around inf 12.3%

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

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

    \[\leadsto \frac{\left(-b\right) + \color{blue}{\left(b + \frac{-2 \cdot \left(c \cdot a\right)}{b}\right)}}{2 \cdot a} \]
  5. Step-by-step derivation
    1. flip-+12.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{c \cdot \left(a \cdot 4\right)}{2 \cdot \frac{c \cdot a}{b} + -2 \cdot b}}{a \cdot 2} \]

Alternative 6: 90.3% 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 17.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Taylor expanded in b around inf 90.3%

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

      \[\leadsto \color{blue}{-\frac{c}{b}} \]
  4. Simplified90.3%

    \[\leadsto \color{blue}{-\frac{c}{b}} \]
  5. Final simplification90.3%

    \[\leadsto \frac{-c}{b} \]

Alternative 7: 1.6% accurate, 38.7× speedup?

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

\\
\frac{b}{a}
\end{array}
Derivation
  1. Initial program 17.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Taylor expanded in b around inf 12.3%

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

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

    \[\leadsto \frac{\left(-b\right) + \color{blue}{\left(b + \frac{-2 \cdot \left(c \cdot a\right)}{b}\right)}}{2 \cdot a} \]
  5. Step-by-step derivation
    1. flip-+12.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{b}{a}} \]
  11. Final simplification1.6%

    \[\leadsto \frac{b}{a} \]

Reproduce

?
herbie shell --seed 2023264 
(FPCore (a b c)
  :name "Quadratic roots, wide range"
  :precision binary64
  :pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))