The quadratic formula (r1)

Percentage Accurate: 52.4% → 85.6%
Time: 12.0s
Alternatives: 7
Speedup: 12.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 52.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: 85.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.3 \cdot 10^{+154}:\\
\;\;\;\;\frac{b}{-a}\\

\mathbf{elif}\;b \leq 2.35 \cdot 10^{-84}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -2.3e154

    1. Initial program 54.9%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified95.6%

      \[\leadsto \color{blue}{\frac{-b}{a}} \]

    if -2.3e154 < b < 2.35e-84

    1. Initial program 87.3%

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

    if 2.35e-84 < b

    1. Initial program 12.2%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    7. Simplified91.0%

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.0%

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

Alternative 2: 85.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.2 \cdot 10^{+143}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 6.6 \cdot 10^{-82}:\\ \;\;\;\;\left(b - \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\right) \cdot \frac{-0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -2.2e+143)
   (/ b (- a))
   (if (<= b 6.6e-82)
     (* (- b (sqrt (+ (* b b) (* c (* a -4.0))))) (/ -0.5 a))
     (/ c (- b)))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.2e+143) {
		tmp = b / -a;
	} else if (b <= 6.6e-82) {
		tmp = (b - sqrt(((b * b) + (c * (a * -4.0))))) * (-0.5 / a);
	} else {
		tmp = c / -b;
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-2.2d+143)) then
        tmp = b / -a
    else if (b <= 6.6d-82) then
        tmp = (b - sqrt(((b * b) + (c * (a * (-4.0d0)))))) * ((-0.5d0) / a)
    else
        tmp = c / -b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.2e+143) {
		tmp = b / -a;
	} else if (b <= 6.6e-82) {
		tmp = (b - Math.sqrt(((b * b) + (c * (a * -4.0))))) * (-0.5 / a);
	} else {
		tmp = c / -b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -2.2e+143:
		tmp = b / -a
	elif b <= 6.6e-82:
		tmp = (b - math.sqrt(((b * b) + (c * (a * -4.0))))) * (-0.5 / a)
	else:
		tmp = c / -b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -2.2e+143)
		tmp = Float64(b / Float64(-a));
	elseif (b <= 6.6e-82)
		tmp = Float64(Float64(b - sqrt(Float64(Float64(b * b) + Float64(c * Float64(a * -4.0))))) * Float64(-0.5 / a));
	else
		tmp = Float64(c / Float64(-b));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -2.2e+143)
		tmp = b / -a;
	elseif (b <= 6.6e-82)
		tmp = (b - sqrt(((b * b) + (c * (a * -4.0))))) * (-0.5 / a);
	else
		tmp = c / -b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -2.2e+143], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 6.6e-82], N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.2 \cdot 10^{+143}:\\
\;\;\;\;\frac{b}{-a}\\

\mathbf{elif}\;b \leq 6.6 \cdot 10^{-82}:\\
\;\;\;\;\left(b - \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\right) \cdot \frac{-0.5}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -2.20000000000000014e143

    1. Initial program 57.0%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified95.8%

      \[\leadsto \color{blue}{\frac{-b}{a}} \]

    if -2.20000000000000014e143 < b < 6.60000000000000045e-82

    1. Initial program 87.1%

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

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

      \[\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. frac-2neg87.1%

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

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

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

        \[\leadsto \left(b - \sqrt{\color{blue}{c \cdot \left(a \cdot -4\right) + {b}^{2}}}\right) \cdot \frac{1}{a \cdot -2} \]
    8. Applied egg-rr86.9%

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

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

        \[\leadsto \left(b - \sqrt{c \cdot \left(a \cdot -4\right) + \color{blue}{b \cdot b}}\right) \cdot \frac{-0.5}{a} \]
    11. Applied egg-rr86.9%

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

    if 6.60000000000000045e-82 < b

    1. Initial program 12.2%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    7. Simplified91.0%

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.2 \cdot 10^{+143}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 6.6 \cdot 10^{-82}:\\ \;\;\;\;\left(b - \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\right) \cdot \frac{-0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -8 \cdot 10^{-114}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\

\mathbf{elif}\;b \leq 7.5 \cdot 10^{-82}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -8.0000000000000004e-114

    1. Initial program 78.9%

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

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

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

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

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

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

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

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

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

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

    if -8.0000000000000004e-114 < b < 7.4999999999999997e-82

    1. Initial program 78.7%

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

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

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

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

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

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

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

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

    if 7.4999999999999997e-82 < b

    1. Initial program 12.2%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    7. Simplified91.0%

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification87.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -8 \cdot 10^{-114}:\\ \;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\ \mathbf{elif}\;b \leq 7.5 \cdot 10^{-82}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 67.7% accurate, 12.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -4e-310) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -4e-310) {
		tmp = b / -a;
	} else {
		tmp = c / -b;
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-4d-310)) then
        tmp = b / -a
    else
        tmp = c / -b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -4e-310) {
		tmp = b / -a;
	} else {
		tmp = c / -b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -4e-310:
		tmp = b / -a
	else:
		tmp = c / -b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -4e-310)
		tmp = Float64(b / Float64(-a));
	else
		tmp = Float64(c / Float64(-b));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -4e-310)
		tmp = b / -a;
	else
		tmp = c / -b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -3.999999999999988e-310

    1. Initial program 79.4%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot b}{a}} \]
      2. mul-1-neg73.5%

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified73.5%

      \[\leadsto \color{blue}{\frac{-b}{a}} \]

    if -3.999999999999988e-310 < b

    1. Initial program 27.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 43.1% accurate, 12.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 1.45 \cdot 10^{+39}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c) :precision binary64 (if (<= b 1.45e+39) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 1.45e+39) {
		tmp = b / -a;
	} else {
		tmp = c / b;
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= 1.45d+39) then
        tmp = b / -a
    else
        tmp = c / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= 1.45e+39) {
		tmp = b / -a;
	} else {
		tmp = c / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= 1.45e+39:
		tmp = b / -a
	else:
		tmp = c / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= 1.45e+39)
		tmp = Float64(b / Float64(-a));
	else
		tmp = Float64(c / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= 1.45e+39)
		tmp = b / -a;
	else
		tmp = c / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, 1.45e+39], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.45 \cdot 10^{+39}:\\
\;\;\;\;\frac{b}{-a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\


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

    1. Initial program 71.1%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot b}{a}} \]
      2. mul-1-neg52.6%

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified52.6%

      \[\leadsto \color{blue}{\frac{-b}{a}} \]

    if 1.45000000000000015e39 < b

    1. Initial program 8.2%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    7. Simplified98.6%

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt49.2%

        \[\leadsto \frac{\color{blue}{\sqrt{-c} \cdot \sqrt{-c}}}{b} \]
      2. sqrt-unprod51.8%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-c\right) \cdot \left(-c\right)}}}{b} \]
      3. sqr-neg51.8%

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

        \[\leadsto \frac{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}{b} \]
      5. add-sqr-sqrt25.2%

        \[\leadsto \frac{\color{blue}{c}}{b} \]
      6. div-inv25.2%

        \[\leadsto \color{blue}{c \cdot \frac{1}{b}} \]
    9. Applied egg-rr25.2%

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

        \[\leadsto \color{blue}{\frac{c \cdot 1}{b}} \]
      2. *-rgt-identity25.2%

        \[\leadsto \frac{\color{blue}{c}}{b} \]
    11. Simplified25.2%

      \[\leadsto \color{blue}{\frac{c}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification45.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.45 \cdot 10^{+39}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 10.4% accurate, 38.7× speedup?

\[\begin{array}{l} \\ \frac{c}{b} \end{array} \]
(FPCore (a b c) :precision binary64 (/ c b))
double code(double a, double b, double c) {
	return c / b;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = c / b
end function
public static double code(double a, double b, double c) {
	return c / b;
}
def code(a, b, c):
	return c / b
function code(a, b, c)
	return Float64(c / 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 54.1%

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-c}}{b} \]
  7. Simplified36.4%

    \[\leadsto \color{blue}{\frac{-c}{b}} \]
  8. Step-by-step derivation
    1. add-sqr-sqrt18.1%

      \[\leadsto \frac{\color{blue}{\sqrt{-c} \cdot \sqrt{-c}}}{b} \]
    2. sqrt-unprod18.6%

      \[\leadsto \frac{\color{blue}{\sqrt{\left(-c\right) \cdot \left(-c\right)}}}{b} \]
    3. sqr-neg18.6%

      \[\leadsto \frac{\sqrt{\color{blue}{c \cdot c}}}{b} \]
    4. sqrt-unprod3.4%

      \[\leadsto \frac{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}{b} \]
    5. add-sqr-sqrt8.8%

      \[\leadsto \frac{\color{blue}{c}}{b} \]
    6. div-inv8.8%

      \[\leadsto \color{blue}{c \cdot \frac{1}{b}} \]
  9. Applied egg-rr8.8%

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

      \[\leadsto \color{blue}{\frac{c \cdot 1}{b}} \]
    2. *-rgt-identity8.8%

      \[\leadsto \frac{\color{blue}{c}}{b} \]
  11. Simplified8.8%

    \[\leadsto \color{blue}{\frac{c}{b}} \]
  12. Add Preprocessing

Alternative 7: 2.5% accurate, 38.7× speedup?

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-b}}{a} \]
  7. Simplified39.1%

    \[\leadsto \color{blue}{\frac{-b}{a}} \]
  8. Step-by-step derivation
    1. neg-sub039.1%

      \[\leadsto \frac{\color{blue}{0 - b}}{a} \]
    2. flip--32.0%

      \[\leadsto \frac{\color{blue}{\frac{0 \cdot 0 - b \cdot b}{0 + b}}}{a} \]
    3. metadata-eval32.0%

      \[\leadsto \frac{\frac{\color{blue}{0} - b \cdot b}{0 + b}}{a} \]
    4. pow232.0%

      \[\leadsto \frac{\frac{0 - \color{blue}{{b}^{2}}}{0 + b}}{a} \]
    5. add-sqr-sqrt1.2%

      \[\leadsto \frac{\frac{0 - {b}^{2}}{0 + \color{blue}{\sqrt{b} \cdot \sqrt{b}}}}{a} \]
    6. sqrt-prod1.1%

      \[\leadsto \frac{\frac{0 - {b}^{2}}{0 + \color{blue}{\sqrt{b \cdot b}}}}{a} \]
    7. sqr-neg1.1%

      \[\leadsto \frac{\frac{0 - {b}^{2}}{0 + \sqrt{\color{blue}{\left(-b\right) \cdot \left(-b\right)}}}}{a} \]
    8. sqrt-unprod0.6%

      \[\leadsto \frac{\frac{0 - {b}^{2}}{0 + \color{blue}{\sqrt{-b} \cdot \sqrt{-b}}}}{a} \]
    9. add-sqr-sqrt2.0%

      \[\leadsto \frac{\frac{0 - {b}^{2}}{0 + \color{blue}{\left(-b\right)}}}{a} \]
    10. sub-neg2.0%

      \[\leadsto \frac{\frac{0 - {b}^{2}}{\color{blue}{0 - b}}}{a} \]
    11. neg-sub02.0%

      \[\leadsto \frac{\frac{0 - {b}^{2}}{\color{blue}{-b}}}{a} \]
    12. add-sqr-sqrt0.6%

      \[\leadsto \frac{\frac{0 - {b}^{2}}{\color{blue}{\sqrt{-b} \cdot \sqrt{-b}}}}{a} \]
    13. sqrt-unprod1.1%

      \[\leadsto \frac{\frac{0 - {b}^{2}}{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}}}}{a} \]
    14. sqr-neg1.1%

      \[\leadsto \frac{\frac{0 - {b}^{2}}{\sqrt{\color{blue}{b \cdot b}}}}{a} \]
    15. sqrt-prod1.2%

      \[\leadsto \frac{\frac{0 - {b}^{2}}{\color{blue}{\sqrt{b} \cdot \sqrt{b}}}}{a} \]
    16. add-sqr-sqrt32.0%

      \[\leadsto \frac{\frac{0 - {b}^{2}}{\color{blue}{b}}}{a} \]
  9. Applied egg-rr32.0%

    \[\leadsto \frac{\color{blue}{\frac{0 - {b}^{2}}{b}}}{a} \]
  10. Step-by-step derivation
    1. neg-sub032.0%

      \[\leadsto \frac{\frac{\color{blue}{-{b}^{2}}}{b}}{a} \]
  11. Simplified32.0%

    \[\leadsto \frac{\color{blue}{\frac{-{b}^{2}}{b}}}{a} \]
  12. Step-by-step derivation
    1. div-inv31.9%

      \[\leadsto \color{blue}{\frac{-{b}^{2}}{b} \cdot \frac{1}{a}} \]
    2. add-sqr-sqrt30.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{-{b}^{2}}{b}} \cdot \sqrt{\frac{-{b}^{2}}{b}}\right)} \cdot \frac{1}{a} \]
    3. add-sqr-sqrt31.9%

      \[\leadsto \color{blue}{\frac{-{b}^{2}}{b}} \cdot \frac{1}{a} \]
    4. distribute-frac-neg31.9%

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

      \[\leadsto \left(-\frac{{b}^{2}}{\color{blue}{{b}^{1}}}\right) \cdot \frac{1}{a} \]
    6. pow-div39.0%

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

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

      \[\leadsto \left(-\color{blue}{b}\right) \cdot \frac{1}{a} \]
    9. add-sqr-sqrt37.6%

      \[\leadsto \color{blue}{\left(\sqrt{-b} \cdot \sqrt{-b}\right)} \cdot \frac{1}{a} \]
    10. sqrt-unprod32.1%

      \[\leadsto \color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}} \cdot \frac{1}{a} \]
    11. sqr-neg32.1%

      \[\leadsto \sqrt{\color{blue}{b \cdot b}} \cdot \frac{1}{a} \]
    12. sqrt-prod1.6%

      \[\leadsto \color{blue}{\left(\sqrt{b} \cdot \sqrt{b}\right)} \cdot \frac{1}{a} \]
    13. add-sqr-sqrt2.2%

      \[\leadsto \color{blue}{b} \cdot \frac{1}{a} \]
  13. Applied egg-rr2.2%

    \[\leadsto \color{blue}{b \cdot \frac{1}{a}} \]
  14. Step-by-step derivation
    1. associate-*r/2.2%

      \[\leadsto \color{blue}{\frac{b \cdot 1}{a}} \]
    2. *-rgt-identity2.2%

      \[\leadsto \frac{\color{blue}{b}}{a} \]
  15. Simplified2.2%

    \[\leadsto \color{blue}{\frac{b}{a}} \]
  16. Add Preprocessing

Developer Target 1: 70.4% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024172 
(FPCore (a b c)
  :name "The quadratic formula (r1)"
  :precision binary64

  :alt
  (! :herbie-platform default (let ((d (- (* b b) (* (* 4 a) c)))) (let ((r1 (/ (+ (- b) (sqrt d)) (* 2 a)))) (let ((r2 (/ (- (- b) (sqrt d)) (* 2 a)))) (if (< b 0) r1 (/ c (* a r2)))))))

  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))