Quadratic roots, wide range

Percentage Accurate: 18.1% → 97.6%
Time: 21.8s
Alternatives: 6
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 6 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.6% accurate, 0.1× speedup?

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

\\
-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(\left(-0.25 \cdot \frac{{a}^{3}}{\frac{{b}^{7}}{{c}^{4} \cdot 20}} - \frac{a \cdot {c}^{2}}{{b}^{3}}\right) - \frac{c}{b}\right)
\end{array}
Derivation
  1. Initial program 19.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. *-commutative19.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(\left(-0.25 \cdot \frac{{a}^{3}}{\frac{{b}^{7}}{{c}^{4} \cdot 20}} - \frac{a \cdot {c}^{2}}{{b}^{3}}\right) - \frac{c}{b}\right) \]
  12. Add Preprocessing

Alternative 2: 96.8% accurate, 0.2× speedup?

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

\\
-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} - \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right)
\end{array}
Derivation
  1. Initial program 19.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. *-commutative19.3%

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

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

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

Alternative 3: 96.3% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := -8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)\\
-0.0625 \cdot \frac{{t_0}^{2}}{a \cdot {b}^{3}} + \left(0.03125 \cdot \frac{{t_0}^{3}}{a \cdot {b}^{5}} + 0.25 \cdot \frac{t_0}{a \cdot b}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 19.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. *-commutative19.3%

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

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(\color{blue}{-4} \cdot a\right)\right) + \mathsf{fma}\left(-4 \cdot a, c, \left(4 \cdot a\right) \cdot c\right)}}{a \cdot 2} \]
    7. associate-*r*19.3%

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot -4\right) \cdot a\right) + \mathsf{fma}\left(\color{blue}{a \cdot -4}, c, \left(4 \cdot a\right) \cdot c\right)}}{a \cdot 2} \]
    11. add-sqr-sqrt0.0%

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot -4\right) \cdot a\right) + \mathsf{fma}\left(\sqrt{\color{blue}{16} \cdot \left(a \cdot a\right)}, c, \left(4 \cdot a\right) \cdot c\right)}}{a \cdot 2} \]
    17. metadata-eval2.8%

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot -4\right) \cdot a\right) + \mathsf{fma}\left(\color{blue}{\sqrt{4 \cdot a} \cdot \sqrt{4 \cdot a}}, c, \left(4 \cdot a\right) \cdot c\right)}}{a \cdot 2} \]
    20. add-sqr-sqrt2.8%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot -4\right) \cdot a\right) + \mathsf{fma}\left(4 \cdot a, c, \color{blue}{c \cdot \left(4 \cdot a\right)}\right)}}{a \cdot 2} \]
    22. add-sqr-sqrt2.8%

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

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

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

    \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, \left(c \cdot -4\right) \cdot a\right) + \mathsf{fma}\left(4 \cdot a, c, \left(c \cdot -4\right) \cdot a\right)}}}{a \cdot 2} \]
  7. Step-by-step derivation
    1. +-commutative19.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-0.0625 \cdot \frac{{\left(-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)\right)}^{2}}{a \cdot {b}^{3}} + \left(0.03125 \cdot \frac{{\left(-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)\right)}^{3}}{a \cdot {b}^{5}} + 0.25 \cdot \frac{-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)}{a \cdot b}\right)} \]
  10. Final simplification96.5%

    \[\leadsto -0.0625 \cdot \frac{{\left(-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)\right)}^{2}}{a \cdot {b}^{3}} + \left(0.03125 \cdot \frac{{\left(-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)\right)}^{3}}{a \cdot {b}^{5}} + 0.25 \cdot \frac{-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)}{a \cdot b}\right) \]
  11. Add Preprocessing

Alternative 4: 96.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)\\ \frac{-0.125 \cdot \frac{{t_0}^{2}}{{b}^{3}} + \left(0.0625 \cdot \frac{{t_0}^{3}}{{b}^{5}} + 0.5 \cdot \frac{t_0}{b}\right)}{a \cdot 2} \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (+ (* -8.0 (* a c)) (* 4.0 (* a c)))))
   (/
    (+
     (* -0.125 (/ (pow t_0 2.0) (pow b 3.0)))
     (+ (* 0.0625 (/ (pow t_0 3.0) (pow b 5.0))) (* 0.5 (/ t_0 b))))
    (* a 2.0))))
double code(double a, double b, double c) {
	double t_0 = (-8.0 * (a * c)) + (4.0 * (a * c));
	return ((-0.125 * (pow(t_0, 2.0) / pow(b, 3.0))) + ((0.0625 * (pow(t_0, 3.0) / pow(b, 5.0))) + (0.5 * (t_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
    real(8) :: t_0
    t_0 = ((-8.0d0) * (a * c)) + (4.0d0 * (a * c))
    code = (((-0.125d0) * ((t_0 ** 2.0d0) / (b ** 3.0d0))) + ((0.0625d0 * ((t_0 ** 3.0d0) / (b ** 5.0d0))) + (0.5d0 * (t_0 / b)))) / (a * 2.0d0)
end function
public static double code(double a, double b, double c) {
	double t_0 = (-8.0 * (a * c)) + (4.0 * (a * c));
	return ((-0.125 * (Math.pow(t_0, 2.0) / Math.pow(b, 3.0))) + ((0.0625 * (Math.pow(t_0, 3.0) / Math.pow(b, 5.0))) + (0.5 * (t_0 / b)))) / (a * 2.0);
}
def code(a, b, c):
	t_0 = (-8.0 * (a * c)) + (4.0 * (a * c))
	return ((-0.125 * (math.pow(t_0, 2.0) / math.pow(b, 3.0))) + ((0.0625 * (math.pow(t_0, 3.0) / math.pow(b, 5.0))) + (0.5 * (t_0 / b)))) / (a * 2.0)
function code(a, b, c)
	t_0 = Float64(Float64(-8.0 * Float64(a * c)) + Float64(4.0 * Float64(a * c)))
	return Float64(Float64(Float64(-0.125 * Float64((t_0 ^ 2.0) / (b ^ 3.0))) + Float64(Float64(0.0625 * Float64((t_0 ^ 3.0) / (b ^ 5.0))) + Float64(0.5 * Float64(t_0 / b)))) / Float64(a * 2.0))
end
function tmp = code(a, b, c)
	t_0 = (-8.0 * (a * c)) + (4.0 * (a * c));
	tmp = ((-0.125 * ((t_0 ^ 2.0) / (b ^ 3.0))) + ((0.0625 * ((t_0 ^ 3.0) / (b ^ 5.0))) + (0.5 * (t_0 / b)))) / (a * 2.0);
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-8.0 * N[(a * c), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(-0.125 * N[(N[Power[t$95$0, 2.0], $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.0625 * N[(N[Power[t$95$0, 3.0], $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(t$95$0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)\\
\frac{-0.125 \cdot \frac{{t_0}^{2}}{{b}^{3}} + \left(0.0625 \cdot \frac{{t_0}^{3}}{{b}^{5}} + 0.5 \cdot \frac{t_0}{b}\right)}{a \cdot 2}
\end{array}
\end{array}
Derivation
  1. Initial program 19.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. *-commutative19.3%

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

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(\color{blue}{-4} \cdot a\right)\right) + \mathsf{fma}\left(-4 \cdot a, c, \left(4 \cdot a\right) \cdot c\right)}}{a \cdot 2} \]
    7. associate-*r*19.3%

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot -4\right) \cdot a\right) + \mathsf{fma}\left(\color{blue}{a \cdot -4}, c, \left(4 \cdot a\right) \cdot c\right)}}{a \cdot 2} \]
    11. add-sqr-sqrt0.0%

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot -4\right) \cdot a\right) + \mathsf{fma}\left(\sqrt{\color{blue}{16} \cdot \left(a \cdot a\right)}, c, \left(4 \cdot a\right) \cdot c\right)}}{a \cdot 2} \]
    17. metadata-eval2.8%

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot -4\right) \cdot a\right) + \mathsf{fma}\left(\color{blue}{\sqrt{4 \cdot a} \cdot \sqrt{4 \cdot a}}, c, \left(4 \cdot a\right) \cdot c\right)}}{a \cdot 2} \]
    20. add-sqr-sqrt2.8%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot -4\right) \cdot a\right) + \mathsf{fma}\left(4 \cdot a, c, \color{blue}{c \cdot \left(4 \cdot a\right)}\right)}}{a \cdot 2} \]
    22. add-sqr-sqrt2.8%

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

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

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

    \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, \left(c \cdot -4\right) \cdot a\right) + \mathsf{fma}\left(4 \cdot a, c, \left(c \cdot -4\right) \cdot a\right)}}}{a \cdot 2} \]
  7. Step-by-step derivation
    1. +-commutative19.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{-0.125 \cdot \frac{{\left(-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)\right)}^{2}}{{b}^{3}} + \left(0.0625 \cdot \frac{{\left(-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)\right)}^{3}}{{b}^{5}} + 0.5 \cdot \frac{-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)}{b}\right)}}{a \cdot 2} \]
  10. Final simplification96.5%

    \[\leadsto \frac{-0.125 \cdot \frac{{\left(-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)\right)}^{2}}{{b}^{3}} + \left(0.0625 \cdot \frac{{\left(-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)\right)}^{3}}{{b}^{5}} + 0.5 \cdot \frac{-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)}{b}\right)}{a \cdot 2} \]
  11. Add Preprocessing

Alternative 5: 95.1% accurate, 0.5× speedup?

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

\\
\frac{-c}{b} - {c}^{2} \cdot \frac{a}{{b}^{3}}
\end{array}
Derivation
  1. Initial program 19.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. *-commutative19.3%

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

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

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

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

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

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

      \[\leadsto \frac{-c}{b} - \color{blue}{\frac{a}{\frac{{b}^{3}}{{c}^{2}}}} \]
    6. associate-/r/95.1%

      \[\leadsto \frac{-c}{b} - \color{blue}{\frac{a}{{b}^{3}} \cdot {c}^{2}} \]
  7. Simplified95.1%

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

    \[\leadsto \frac{-c}{b} - {c}^{2} \cdot \frac{a}{{b}^{3}} \]
  9. Add Preprocessing

Alternative 6: 90.2% accurate, 29.0× speedup?

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

\\
\frac{-c}{b}
\end{array}
Derivation
  1. Initial program 19.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. *-commutative19.3%

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

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

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

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
  7. Simplified89.5%

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

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

Reproduce

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