Quadratic roots, medium range

Percentage Accurate: 31.4% → 99.4%
Time: 15.5s
Alternatives: 9
Speedup: 23.2×

Specification

?
\[\left(\left(1.1102230246251565 \cdot 10^{-16} < a \land a < 9007199254740992\right) \land \left(1.1102230246251565 \cdot 10^{-16} < b \land b < 9007199254740992\right)\right) \land \left(1.1102230246251565 \cdot 10^{-16} < c \land c < 9007199254740992\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: 31.4% 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.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := a \cdot \left(c \cdot -4\right)\\
\frac{\frac{-1}{b + \sqrt{b \cdot b + t\_0}}}{2} \cdot \frac{t\_0}{0 - a}
\end{array}
\end{array}
Derivation
  1. Initial program 28.4%

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

    \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\color{blue}{\left(a \cdot \left(\frac{{b}^{2}}{a} - 4 \cdot c\right)\right)}\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
  4. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \left(\frac{{b}^{2}}{a} - 4 \cdot c\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    2. cancel-sign-sub-invN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \left(\frac{{b}^{2}}{a} + \left(\mathsf{neg}\left(4\right)\right) \cdot c\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \left(\frac{{b}^{2}}{a} + -4 \cdot c\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\left(\frac{{b}^{2}}{a}\right), \left(-4 \cdot c\right)\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\left({b}^{2}\right), a\right), \left(-4 \cdot c\right)\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    6. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\left(b \cdot b\right), a\right), \left(-4 \cdot c\right)\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    7. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(b, b\right), a\right), \left(-4 \cdot c\right)\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(b, b\right), a\right), \left(c \cdot -4\right)\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    9. *-lowering-*.f6428.4%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(b, b\right), a\right), \mathsf{*.f64}\left(c, -4\right)\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
  5. Simplified28.4%

    \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}}}{2 \cdot a} \]
  6. Step-by-step derivation
    1. flip-+N/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(\mathsf{neg}\left(b\right)\right) \cdot \left(\mathsf{neg}\left(b\right)\right) - \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)} \cdot \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}}{\left(\mathsf{neg}\left(b\right)\right) - \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}}\right), \mathsf{*.f64}\left(\color{blue}{2}, a\right)\right) \]
    2. div-invN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\left(\left(\mathsf{neg}\left(b\right)\right) \cdot \left(\mathsf{neg}\left(b\right)\right) - \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)} \cdot \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}\right) \cdot \frac{1}{\left(\mathsf{neg}\left(b\right)\right) - \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}}\right), \mathsf{*.f64}\left(\color{blue}{2}, a\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\left(\mathsf{neg}\left(b\right)\right) \cdot \left(\mathsf{neg}\left(b\right)\right) - \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)} \cdot \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}\right), \left(\frac{1}{\left(\mathsf{neg}\left(b\right)\right) - \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}}\right)\right), \mathsf{*.f64}\left(\color{blue}{2}, a\right)\right) \]
  7. Applied egg-rr29.3%

    \[\leadsto \frac{\color{blue}{\left(b \cdot b - \left(\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)\right)\right) \cdot \frac{1}{0 - \left(b + \sqrt{\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)}\right)}}}{2 \cdot a} \]
  8. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \frac{\frac{1}{0 - \left(b + \sqrt{\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)}\right)} \cdot \left(b \cdot b - \left(\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)\right)\right)}{\color{blue}{2} \cdot a} \]
    2. times-fracN/A

      \[\leadsto \frac{\frac{1}{0 - \left(b + \sqrt{\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)}\right)}}{2} \cdot \color{blue}{\frac{b \cdot b - \left(\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)\right)}{a}} \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\frac{1}{0 - \left(b + \sqrt{\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)}\right)}}{2}\right), \color{blue}{\left(\frac{b \cdot b - \left(\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)\right)}{a}\right)}\right) \]
  9. Applied egg-rr99.4%

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

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

Alternative 2: 99.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := a \cdot \left(c \cdot -4\right)\\
\frac{\frac{t\_0}{b + \sqrt{b \cdot b + t\_0}}}{a \cdot 2}
\end{array}
\end{array}
Derivation
  1. Initial program 28.4%

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

    \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\color{blue}{\left(a \cdot \left(\frac{{b}^{2}}{a} - 4 \cdot c\right)\right)}\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
  4. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \left(\frac{{b}^{2}}{a} - 4 \cdot c\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    2. cancel-sign-sub-invN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \left(\frac{{b}^{2}}{a} + \left(\mathsf{neg}\left(4\right)\right) \cdot c\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \left(\frac{{b}^{2}}{a} + -4 \cdot c\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\left(\frac{{b}^{2}}{a}\right), \left(-4 \cdot c\right)\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\left({b}^{2}\right), a\right), \left(-4 \cdot c\right)\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    6. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\left(b \cdot b\right), a\right), \left(-4 \cdot c\right)\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    7. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(b, b\right), a\right), \left(-4 \cdot c\right)\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(b, b\right), a\right), \left(c \cdot -4\right)\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    9. *-lowering-*.f6428.4%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{neg.f64}\left(b\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(b, b\right), a\right), \mathsf{*.f64}\left(c, -4\right)\right)\right)\right)\right), \mathsf{*.f64}\left(2, a\right)\right) \]
  5. Simplified28.4%

    \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}}}{2 \cdot a} \]
  6. Step-by-step derivation
    1. flip-+N/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(\mathsf{neg}\left(b\right)\right) \cdot \left(\mathsf{neg}\left(b\right)\right) - \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)} \cdot \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}}{\left(\mathsf{neg}\left(b\right)\right) - \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}}\right), \mathsf{*.f64}\left(\color{blue}{2}, a\right)\right) \]
    2. div-invN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\left(\left(\mathsf{neg}\left(b\right)\right) \cdot \left(\mathsf{neg}\left(b\right)\right) - \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)} \cdot \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}\right) \cdot \frac{1}{\left(\mathsf{neg}\left(b\right)\right) - \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}}\right), \mathsf{*.f64}\left(\color{blue}{2}, a\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\left(\mathsf{neg}\left(b\right)\right) \cdot \left(\mathsf{neg}\left(b\right)\right) - \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)} \cdot \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}\right), \left(\frac{1}{\left(\mathsf{neg}\left(b\right)\right) - \sqrt{a \cdot \left(\frac{b \cdot b}{a} + c \cdot -4\right)}}\right)\right), \mathsf{*.f64}\left(\color{blue}{2}, a\right)\right) \]
  7. Applied egg-rr29.3%

    \[\leadsto \frac{\color{blue}{\left(b \cdot b - \left(\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)\right)\right) \cdot \frac{1}{0 - \left(b + \sqrt{\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)}\right)}}}{2 \cdot a} \]
  8. Step-by-step derivation
    1. un-div-invN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{b \cdot b - \left(\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)\right)}{0 - \left(b + \sqrt{\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)}\right)}\right), \mathsf{*.f64}\left(\color{blue}{2}, a\right)\right) \]
    2. frac-2negN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{\mathsf{neg}\left(\left(b \cdot b - \left(\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)\right)\right)\right)}{\mathsf{neg}\left(\left(0 - \left(b + \sqrt{\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)}\right)\right)\right)}\right), \mathsf{*.f64}\left(\color{blue}{2}, a\right)\right) \]
    3. sub0-negN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{\mathsf{neg}\left(\left(b \cdot b - \left(\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(b + \sqrt{\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)}\right)\right)\right)\right)}\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    4. remove-double-negN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{\mathsf{neg}\left(\left(b \cdot b - \left(\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)\right)\right)\right)}{b + \sqrt{\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)}}\right), \mathsf{*.f64}\left(2, a\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(b \cdot b - \left(\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)\right)\right)\right)\right), \left(b + \sqrt{\left(b \cdot b\right) \cdot 1 + a \cdot \left(c \cdot -4\right)}\right)\right), \mathsf{*.f64}\left(\color{blue}{2}, a\right)\right) \]
  9. Applied egg-rr99.4%

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

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

Alternative 3: 95.3% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := c \cdot \left(c \cdot c\right)\\
\frac{\frac{\left(t\_0 \cdot -2\right) \cdot \left(a \cdot a\right)}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + \left(\frac{\frac{\left(c \cdot t\_0\right) \cdot \left(a \cdot \left(a \cdot \left(a \cdot a\right)\right)\right)}{\frac{a}{20}}}{\frac{\left(b \cdot b\right) \cdot \left(b \cdot \left(b \cdot \left(b \cdot b\right)\right)\right)}{-0.25}} - \left(c + a \cdot \left(c \cdot \frac{\frac{c}{b}}{b}\right)\right)\right)}{b}
\end{array}
\end{array}
Derivation
  1. Initial program 28.4%

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

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

    \[\leadsto \color{blue}{\frac{\frac{\left(\left(c \cdot \left(c \cdot c\right)\right) \cdot -2\right) \cdot \left(a \cdot a\right)}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + \left(\left(\left({a}^{4} \cdot {c}^{4}\right) \cdot \frac{20}{a}\right) \cdot \frac{-0.25}{{b}^{6}} - \left(c + a \cdot \left(c \cdot \frac{\frac{c}{b}}{b}\right)\right)\right)}{b}} \]
  5. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, c\right)\right), -2\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(b, b\right)\right)\right), \mathsf{\_.f64}\left(\left(\left(\left({a}^{4} \cdot {c}^{4}\right) \cdot \frac{20}{a}\right) \cdot \frac{1}{\frac{{b}^{6}}{\frac{-1}{4}}}\right), \mathsf{+.f64}\left(c, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(c, \mathsf{/.f64}\left(\mathsf{/.f64}\left(c, b\right), b\right)\right)\right)\right)\right)\right), b\right) \]
    2. un-div-invN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, c\right)\right), -2\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(b, b\right)\right)\right), \mathsf{\_.f64}\left(\left(\frac{\left({a}^{4} \cdot {c}^{4}\right) \cdot \frac{20}{a}}{\frac{{b}^{6}}{\frac{-1}{4}}}\right), \mathsf{+.f64}\left(c, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(c, \mathsf{/.f64}\left(\mathsf{/.f64}\left(c, b\right), b\right)\right)\right)\right)\right)\right), b\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, c\right)\right), -2\right), \mathsf{*.f64}\left(a, a\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(b, b\right)\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left({a}^{4} \cdot {c}^{4}\right) \cdot \frac{20}{a}\right), \left(\frac{{b}^{6}}{\frac{-1}{4}}\right)\right), \mathsf{+.f64}\left(c, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(c, \mathsf{/.f64}\left(\mathsf{/.f64}\left(c, b\right), b\right)\right)\right)\right)\right)\right), b\right) \]
  6. Applied egg-rr95.8%

    \[\leadsto \frac{\frac{\left(\left(c \cdot \left(c \cdot c\right)\right) \cdot -2\right) \cdot \left(a \cdot a\right)}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + \left(\color{blue}{\frac{\frac{\left(c \cdot \left(c \cdot \left(c \cdot c\right)\right)\right) \cdot \left(a \cdot \left(a \cdot \left(a \cdot a\right)\right)\right)}{\frac{a}{20}}}{\frac{\left(b \cdot b\right) \cdot \left(b \cdot \left(b \cdot \left(b \cdot b\right)\right)\right)}{-0.25}}} - \left(c + a \cdot \left(c \cdot \frac{\frac{c}{b}}{b}\right)\right)\right)}{b} \]
  7. Add Preprocessing

Alternative 4: 93.8% accurate, 3.5× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(-1 \cdot c + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}}\right)}{b}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

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

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

Alternative 5: 93.8% accurate, 3.7× speedup?

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

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

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

    \[\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}} + \frac{-1}{4} \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right)} \]
  4. Simplified95.8%

    \[\leadsto \color{blue}{a \cdot \left(a \cdot \left(\frac{\left(c \cdot \left(c \cdot c\right)\right) \cdot -2}{{b}^{5}} + \frac{\left(-0.25 \cdot a\right) \cdot \frac{{c}^{4} \cdot 20}{{b}^{6}}}{b}\right) - \frac{c \cdot \frac{\frac{c}{b}}{b}}{b}\right) - \frac{c}{b}} \]
  5. Taylor expanded in b around inf

    \[\leadsto \mathsf{\_.f64}\left(\color{blue}{\left(\frac{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{2}} + -1 \cdot \left(a \cdot {c}^{2}\right)}{{b}^{3}}\right)}, \mathsf{/.f64}\left(c, b\right)\right) \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{2}} + -1 \cdot \left(a \cdot {c}^{2}\right)\right), \left({b}^{3}\right)\right), \mathsf{/.f64}\left(\color{blue}{c}, b\right)\right) \]
  7. Simplified94.4%

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

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

Alternative 6: 90.7% accurate, 7.7× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{-1 \cdot c + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(-1 \cdot c + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}}\right), \color{blue}{b}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + -1 \cdot c\right), b\right) \]
    3. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(\left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \left(\mathsf{neg}\left(c\right)\right)\right), b\right) \]
    4. unsub-negN/A

      \[\leadsto \mathsf{/.f64}\left(\left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} - c\right), b\right) \]
    5. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}}\right), c\right), b\right) \]
    6. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\mathsf{neg}\left(\frac{a \cdot {c}^{2}}{{b}^{2}}\right)\right), c\right), b\right) \]
    7. neg-sub0N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(0 - \frac{a \cdot {c}^{2}}{{b}^{2}}\right), c\right), b\right) \]
    8. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{\_.f64}\left(0, \left(\frac{a \cdot {c}^{2}}{{b}^{2}}\right)\right), c\right), b\right) \]
    9. associate-/l*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{\_.f64}\left(0, \left(a \cdot \frac{{c}^{2}}{{b}^{2}}\right)\right), c\right), b\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(a, \left(\frac{{c}^{2}}{{b}^{2}}\right)\right)\right), c\right), b\right) \]
    11. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(a, \left(\frac{c \cdot c}{{b}^{2}}\right)\right)\right), c\right), b\right) \]
    12. associate-/l*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(a, \left(c \cdot \frac{c}{{b}^{2}}\right)\right)\right), c\right), b\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(c, \left(\frac{c}{{b}^{2}}\right)\right)\right)\right), c\right), b\right) \]
    14. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(c, \left(\frac{c}{b \cdot b}\right)\right)\right)\right), c\right), b\right) \]
    15. associate-/r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(c, \left(\frac{\frac{c}{b}}{b}\right)\right)\right)\right), c\right), b\right) \]
    16. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(c, \mathsf{/.f64}\left(\left(\frac{c}{b}\right), b\right)\right)\right)\right), c\right), b\right) \]
    17. /-lowering-/.f6491.3%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(c, \mathsf{/.f64}\left(\mathsf{/.f64}\left(c, b\right), b\right)\right)\right)\right), c\right), b\right) \]
  5. Simplified91.3%

    \[\leadsto \color{blue}{\frac{\left(0 - a \cdot \left(c \cdot \frac{\frac{c}{b}}{b}\right)\right) - c}{b}} \]
  6. Final simplification91.3%

    \[\leadsto \frac{\left(c \cdot \frac{\frac{c}{b}}{b}\right) \cdot \left(0 - a\right) - c}{b} \]
  7. Add Preprocessing

Alternative 7: 90.5% accurate, 7.7× speedup?

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

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

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

    \[\leadsto \color{blue}{c \cdot \left(-1 \cdot \frac{a \cdot c}{{b}^{3}} - \frac{1}{b}\right)} \]
  4. Step-by-step derivation
    1. sub-negN/A

      \[\leadsto c \cdot \left(-1 \cdot \frac{a \cdot c}{{b}^{3}} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{b}\right)\right)}\right) \]
    2. distribute-neg-fracN/A

      \[\leadsto c \cdot \left(-1 \cdot \frac{a \cdot c}{{b}^{3}} + \frac{\mathsf{neg}\left(1\right)}{\color{blue}{b}}\right) \]
    3. metadata-evalN/A

      \[\leadsto c \cdot \left(-1 \cdot \frac{a \cdot c}{{b}^{3}} + \frac{-1}{b}\right) \]
    4. associate-*r/N/A

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

      \[\leadsto c \cdot \left(\frac{\left(-1 \cdot a\right) \cdot c}{{b}^{3}} + \frac{-1}{b}\right) \]
    6. associate-*l/N/A

      \[\leadsto c \cdot \left(\frac{-1 \cdot a}{{b}^{3}} \cdot c + \frac{\color{blue}{-1}}{b}\right) \]
    7. associate-*r/N/A

      \[\leadsto c \cdot \left(\left(-1 \cdot \frac{a}{{b}^{3}}\right) \cdot c + \frac{-1}{b}\right) \]
    8. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(c, \color{blue}{\left(\left(-1 \cdot \frac{a}{{b}^{3}}\right) \cdot c + \frac{-1}{b}\right)}\right) \]
    9. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(c, \left(\frac{-1}{b} + \color{blue}{\left(-1 \cdot \frac{a}{{b}^{3}}\right) \cdot c}\right)\right) \]
    10. associate-*r/N/A

      \[\leadsto \mathsf{*.f64}\left(c, \left(\frac{-1}{b} + \frac{-1 \cdot a}{{b}^{3}} \cdot c\right)\right) \]
    11. associate-*l/N/A

      \[\leadsto \mathsf{*.f64}\left(c, \left(\frac{-1}{b} + \frac{\left(-1 \cdot a\right) \cdot c}{\color{blue}{{b}^{3}}}\right)\right) \]
    12. associate-*r*N/A

      \[\leadsto \mathsf{*.f64}\left(c, \left(\frac{-1}{b} + \frac{-1 \cdot \left(a \cdot c\right)}{{\color{blue}{b}}^{3}}\right)\right) \]
    13. associate-*r/N/A

      \[\leadsto \mathsf{*.f64}\left(c, \left(\frac{-1}{b} + -1 \cdot \color{blue}{\frac{a \cdot c}{{b}^{3}}}\right)\right) \]
    14. mul-1-negN/A

      \[\leadsto \mathsf{*.f64}\left(c, \left(\frac{-1}{b} + \left(\mathsf{neg}\left(\frac{a \cdot c}{{b}^{3}}\right)\right)\right)\right) \]
    15. unsub-negN/A

      \[\leadsto \mathsf{*.f64}\left(c, \left(\frac{-1}{b} - \color{blue}{\frac{a \cdot c}{{b}^{3}}}\right)\right) \]
    16. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(c, \mathsf{\_.f64}\left(\left(\frac{-1}{b}\right), \color{blue}{\left(\frac{a \cdot c}{{b}^{3}}\right)}\right)\right) \]
  5. Simplified91.1%

    \[\leadsto \color{blue}{c \cdot \left(\frac{-1}{b} - \frac{a \cdot c}{b \cdot \left(b \cdot b\right)}\right)} \]
  6. Add Preprocessing

Alternative 8: 90.7% accurate, 8.9× speedup?

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

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

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

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

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

    \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left(c \cdot \left(-1 \cdot \frac{a \cdot c}{{b}^{2}} - 1\right)\right)}, b\right) \]
  6. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(c, \left(-1 \cdot \frac{a \cdot c}{{b}^{2}} - 1\right)\right), b\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(c, \left(-1 \cdot \frac{a \cdot c}{{b}^{2}} + \left(\mathsf{neg}\left(1\right)\right)\right)\right), b\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(c, \left(-1 \cdot \frac{a \cdot c}{{b}^{2}} + -1\right)\right), b\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(c, \mathsf{+.f64}\left(\left(-1 \cdot \frac{a \cdot c}{{b}^{2}}\right), -1\right)\right), b\right) \]
  7. Simplified91.2%

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

    \[\leadsto \frac{c \cdot \left(-1 - a \cdot \frac{c}{b \cdot b}\right)}{b} \]
  9. Add Preprocessing

Alternative 9: 81.3% accurate, 23.2× speedup?

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
  4. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{neg}\left(\frac{c}{b}\right) \]
    2. neg-sub0N/A

      \[\leadsto 0 - \color{blue}{\frac{c}{b}} \]
    3. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(\frac{c}{b}\right)}\right) \]
    4. /-lowering-/.f6483.4%

      \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(c, \color{blue}{b}\right)\right) \]
  5. Simplified83.4%

    \[\leadsto \color{blue}{0 - \frac{c}{b}} \]
  6. Step-by-step derivation
    1. sub0-negN/A

      \[\leadsto \mathsf{neg}\left(\frac{c}{b}\right) \]
    2. neg-lowering-neg.f64N/A

      \[\leadsto \mathsf{neg.f64}\left(\left(\frac{c}{b}\right)\right) \]
    3. /-lowering-/.f6483.4%

      \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(c, b\right)\right) \]
  7. Applied egg-rr83.4%

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

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

Reproduce

?
herbie shell --seed 2024192 
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :precision binary64
  :pre (and (and (and (< 1.1102230246251565e-16 a) (< a 9007199254740992.0)) (and (< 1.1102230246251565e-16 b) (< b 9007199254740992.0))) (and (< 1.1102230246251565e-16 c) (< c 9007199254740992.0)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))