Quadratic roots, full range

Percentage Accurate: 51.7% → 85.0%
Time: 12.0s
Alternatives: 10
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 10 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: 51.7% 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.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -4.6 \cdot 10^{+59}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 8.4 \cdot 10^{-35}:\\ \;\;\;\;\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 -4.6e+59)
   (/ b (- a))
   (if (<= b 8.4e-35)
     (/ (- (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 <= -4.6e+59) {
		tmp = b / -a;
	} else if (b <= 8.4e-35) {
		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 <= (-4.6d+59)) then
        tmp = b / -a
    else if (b <= 8.4d-35) 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 <= -4.6e+59) {
		tmp = b / -a;
	} else if (b <= 8.4e-35) {
		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 <= -4.6e+59:
		tmp = b / -a
	elif b <= 8.4e-35:
		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 <= -4.6e+59)
		tmp = Float64(b / Float64(-a));
	elseif (b <= 8.4e-35)
		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 <= -4.6e+59)
		tmp = b / -a;
	elseif (b <= 8.4e-35)
		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, -4.6e+59], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 8.4e-35], 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 -4.6 \cdot 10^{+59}:\\
\;\;\;\;\frac{b}{-a}\\

\mathbf{elif}\;b \leq 8.4 \cdot 10^{-35}:\\
\;\;\;\;\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 < -4.60000000000000016e59

    1. Initial program 66.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. *-commutative66.0%

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

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

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

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

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

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

    if -4.60000000000000016e59 < b < 8.3999999999999999e-35

    1. Initial program 82.9%

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

    if 8.3999999999999999e-35 < b

    1. Initial program 17.3%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.6 \cdot 10^{+59}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 8.4 \cdot 10^{-35}:\\ \;\;\;\;\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: 80.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.9 \cdot 10^{-78}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 7 \cdot 10^{-40}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot 2} - \frac{\frac{b}{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -2.9e-78)
   (/ b (- a))
   (if (<= b 7e-40)
     (- (/ (sqrt (* a (* c -4.0))) (* a 2.0)) (/ (/ b a) 2.0))
     (/ c (- b)))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.9e-78) {
		tmp = b / -a;
	} else if (b <= 7e-40) {
		tmp = (sqrt((a * (c * -4.0))) / (a * 2.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 <= (-2.9d-78)) then
        tmp = b / -a
    else if (b <= 7d-40) then
        tmp = (sqrt((a * (c * (-4.0d0)))) / (a * 2.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 <= -2.9e-78) {
		tmp = b / -a;
	} else if (b <= 7e-40) {
		tmp = (Math.sqrt((a * (c * -4.0))) / (a * 2.0)) - ((b / a) / 2.0);
	} else {
		tmp = c / -b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -2.9e-78:
		tmp = b / -a
	elif b <= 7e-40:
		tmp = (math.sqrt((a * (c * -4.0))) / (a * 2.0)) - ((b / a) / 2.0)
	else:
		tmp = c / -b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -2.9e-78)
		tmp = Float64(b / Float64(-a));
	elseif (b <= 7e-40)
		tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) / Float64(a * 2.0)) - Float64(Float64(b / 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.9e-78)
		tmp = b / -a;
	elseif (b <= 7e-40)
		tmp = (sqrt((a * (c * -4.0))) / (a * 2.0)) - ((b / a) / 2.0);
	else
		tmp = c / -b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -2.9e-78], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 7e-40], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision] - N[(N[(b / a), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 74.5%

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

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

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

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

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

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

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

    if -2.9000000000000001e-78 < b < 7.0000000000000003e-40

    1. Initial program 79.8%

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

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

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

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

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(a \cdot -4\right) \cdot c}} - b}{a \cdot 2} \]
    8. Step-by-step derivation
      1. div-sub78.7%

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

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

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

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

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

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

    if 7.0000000000000003e-40 < b

    1. Initial program 17.3%

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

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

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

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

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

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

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

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

Alternative 3: 80.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.45 \cdot 10^{-78}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 1.32 \cdot 10^{-37}:\\ \;\;\;\;\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 -1.45e-78)
   (/ b (- a))
   (if (<= b 1.32e-37)
     (/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0))
     (/ c (- b)))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -1.45e-78) {
		tmp = b / -a;
	} else if (b <= 1.32e-37) {
		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 <= (-1.45d-78)) then
        tmp = b / -a
    else if (b <= 1.32d-37) 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 <= -1.45e-78) {
		tmp = b / -a;
	} else if (b <= 1.32e-37) {
		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 <= -1.45e-78:
		tmp = b / -a
	elif b <= 1.32e-37:
		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 <= -1.45e-78)
		tmp = Float64(b / Float64(-a));
	elseif (b <= 1.32e-37)
		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 <= -1.45e-78)
		tmp = b / -a;
	elseif (b <= 1.32e-37)
		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, -1.45e-78], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.32e-37], 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 -1.45 \cdot 10^{-78}:\\
\;\;\;\;\frac{b}{-a}\\

\mathbf{elif}\;b \leq 1.32 \cdot 10^{-37}:\\
\;\;\;\;\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 < -1.45e-78

    1. Initial program 74.5%

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

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

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

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

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

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

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

    if -1.45e-78 < b < 1.3200000000000001e-37

    1. Initial program 79.8%

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

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

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

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

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

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

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

    if 1.3200000000000001e-37 < b

    1. Initial program 17.3%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.45 \cdot 10^{-78}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 1.32 \cdot 10^{-37}:\\ \;\;\;\;\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: 80.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -4.3 \cdot 10^{-78}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 5 \cdot 10^{-37}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -4.3e-78)
   (/ b (- a))
   (if (<= b 5e-37) (/ (sqrt (* a (* c -4.0))) (* a 2.0)) (/ c (- b)))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -4.3e-78) {
		tmp = b / -a;
	} else if (b <= 5e-37) {
		tmp = sqrt((a * (c * -4.0))) / (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 <= (-4.3d-78)) then
        tmp = b / -a
    else if (b <= 5d-37) then
        tmp = sqrt((a * (c * (-4.0d0)))) / (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 <= -4.3e-78) {
		tmp = b / -a;
	} else if (b <= 5e-37) {
		tmp = Math.sqrt((a * (c * -4.0))) / (a * 2.0);
	} else {
		tmp = c / -b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -4.3e-78:
		tmp = b / -a
	elif b <= 5e-37:
		tmp = math.sqrt((a * (c * -4.0))) / (a * 2.0)
	else:
		tmp = c / -b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -4.3e-78)
		tmp = Float64(b / Float64(-a));
	elseif (b <= 5e-37)
		tmp = Float64(sqrt(Float64(a * Float64(c * -4.0))) / 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 <= -4.3e-78)
		tmp = b / -a;
	elseif (b <= 5e-37)
		tmp = sqrt((a * (c * -4.0))) / (a * 2.0);
	else
		tmp = c / -b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -4.3e-78], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 5e-37], N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 74.5%

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

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

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

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

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

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

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

    if -4.29999999999999994e-78 < b < 4.9999999999999997e-37

    1. Initial program 79.8%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt79.1%

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}}{a \cdot 2} \]
    8. Step-by-step derivation
      1. mul-1-neg0.0%

        \[\leadsto \frac{\color{blue}{-\sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)} \cdot {\left(\sqrt{-1}\right)}^{2}}}{a \cdot 2} \]
      2. *-commutative0.0%

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

        \[\leadsto \frac{-\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)}}{a \cdot 2} \]
      4. rem-square-sqrt77.1%

        \[\leadsto \frac{-\color{blue}{-1} \cdot \sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)}}{a \cdot 2} \]
      5. rem-cube-cbrt77.7%

        \[\leadsto \frac{--1 \cdot \sqrt{a \cdot \left(c \cdot \color{blue}{-4}\right)}}{a \cdot 2} \]
      6. *-commutative77.7%

        \[\leadsto \frac{--1 \cdot \sqrt{a \cdot \color{blue}{\left(-4 \cdot c\right)}}}{a \cdot 2} \]
      7. distribute-lft-neg-in77.7%

        \[\leadsto \frac{\color{blue}{\left(--1\right) \cdot \sqrt{a \cdot \left(-4 \cdot c\right)}}}{a \cdot 2} \]
      8. metadata-eval77.7%

        \[\leadsto \frac{\color{blue}{1} \cdot \sqrt{a \cdot \left(-4 \cdot c\right)}}{a \cdot 2} \]
      9. *-lft-identity77.7%

        \[\leadsto \frac{\color{blue}{\sqrt{a \cdot \left(-4 \cdot c\right)}}}{a \cdot 2} \]
      10. *-commutative77.7%

        \[\leadsto \frac{\sqrt{a \cdot \color{blue}{\left(c \cdot -4\right)}}}{a \cdot 2} \]
    9. Simplified77.7%

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

    if 4.9999999999999997e-37 < b

    1. Initial program 17.3%

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

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

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

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

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

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

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

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

Alternative 5: 80.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.45 \cdot 10^{-80}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 9.2 \cdot 10^{-40}:\\ \;\;\;\;\sqrt{c \cdot \left(a \cdot -4\right)} \cdot \frac{0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -1.45e-80)
   (/ b (- a))
   (if (<= b 9.2e-40) (* (sqrt (* c (* a -4.0))) (/ 0.5 a)) (/ c (- b)))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -1.45e-80) {
		tmp = b / -a;
	} else if (b <= 9.2e-40) {
		tmp = sqrt((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 <= (-1.45d-80)) then
        tmp = b / -a
    else if (b <= 9.2d-40) then
        tmp = sqrt((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 <= -1.45e-80) {
		tmp = b / -a;
	} else if (b <= 9.2e-40) {
		tmp = Math.sqrt((c * (a * -4.0))) * (0.5 / a);
	} else {
		tmp = c / -b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -1.45e-80:
		tmp = b / -a
	elif b <= 9.2e-40:
		tmp = math.sqrt((c * (a * -4.0))) * (0.5 / a)
	else:
		tmp = c / -b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -1.45e-80)
		tmp = Float64(b / Float64(-a));
	elseif (b <= 9.2e-40)
		tmp = Float64(sqrt(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 <= -1.45e-80)
		tmp = b / -a;
	elseif (b <= 9.2e-40)
		tmp = sqrt((c * (a * -4.0))) * (0.5 / a);
	else
		tmp = c / -b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -1.45e-80], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 9.2e-40], N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;b \leq 9.2 \cdot 10^{-40}:\\
\;\;\;\;\sqrt{c \cdot \left(a \cdot -4\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 < -1.44999999999999999e-80

    1. Initial program 74.5%

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

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

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

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

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

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

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

    if -1.44999999999999999e-80 < b < 9.2e-40

    1. Initial program 79.8%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt79.1%

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}}{a \cdot 2} \]
    8. Step-by-step derivation
      1. mul-1-neg0.0%

        \[\leadsto \frac{\color{blue}{-\sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)} \cdot {\left(\sqrt{-1}\right)}^{2}}}{a \cdot 2} \]
      2. *-commutative0.0%

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

        \[\leadsto \frac{-\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)}}{a \cdot 2} \]
      4. rem-square-sqrt77.1%

        \[\leadsto \frac{-\color{blue}{-1} \cdot \sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)}}{a \cdot 2} \]
      5. rem-cube-cbrt77.7%

        \[\leadsto \frac{--1 \cdot \sqrt{a \cdot \left(c \cdot \color{blue}{-4}\right)}}{a \cdot 2} \]
      6. *-commutative77.7%

        \[\leadsto \frac{--1 \cdot \sqrt{a \cdot \color{blue}{\left(-4 \cdot c\right)}}}{a \cdot 2} \]
      7. distribute-lft-neg-in77.7%

        \[\leadsto \frac{\color{blue}{\left(--1\right) \cdot \sqrt{a \cdot \left(-4 \cdot c\right)}}}{a \cdot 2} \]
      8. metadata-eval77.7%

        \[\leadsto \frac{\color{blue}{1} \cdot \sqrt{a \cdot \left(-4 \cdot c\right)}}{a \cdot 2} \]
      9. *-lft-identity77.7%

        \[\leadsto \frac{\color{blue}{\sqrt{a \cdot \left(-4 \cdot c\right)}}}{a \cdot 2} \]
      10. *-commutative77.7%

        \[\leadsto \frac{\sqrt{a \cdot \color{blue}{\left(c \cdot -4\right)}}}{a \cdot 2} \]
    9. Simplified77.7%

      \[\leadsto \frac{\color{blue}{\sqrt{a \cdot \left(c \cdot -4\right)}}}{a \cdot 2} \]
    10. Step-by-step derivation
      1. clear-num77.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{a \cdot 2}{\sqrt{a \cdot \left(c \cdot -4\right)}}}} \]
      2. associate-/r/77.5%

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

        \[\leadsto \frac{1}{\color{blue}{2 \cdot a}} \cdot \sqrt{a \cdot \left(c \cdot -4\right)} \]
      4. associate-/r*77.5%

        \[\leadsto \color{blue}{\frac{\frac{1}{2}}{a}} \cdot \sqrt{a \cdot \left(c \cdot -4\right)} \]
      5. metadata-eval77.5%

        \[\leadsto \frac{\color{blue}{0.5}}{a} \cdot \sqrt{a \cdot \left(c \cdot -4\right)} \]
      6. *-commutative77.5%

        \[\leadsto \frac{0.5}{a} \cdot \sqrt{\color{blue}{\left(c \cdot -4\right) \cdot a}} \]
      7. associate-*l*77.5%

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

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

    if 9.2e-40 < b

    1. Initial program 17.3%

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

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

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

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

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

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

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

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

Alternative 6: 70.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.6 \cdot 10^{-118}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 6.2 \cdot 10^{-40}:\\ \;\;\;\;\sqrt{\frac{\frac{c \cdot -4}{a}}{4}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -2.6e-118)
   (/ b (- a))
   (if (<= b 6.2e-40) (sqrt (/ (/ (* c -4.0) a) 4.0)) (/ c (- b)))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.6e-118) {
		tmp = b / -a;
	} else if (b <= 6.2e-40) {
		tmp = sqrt((((c * -4.0) / a) / 4.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.6d-118)) then
        tmp = b / -a
    else if (b <= 6.2d-40) then
        tmp = sqrt((((c * (-4.0d0)) / a) / 4.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.6e-118) {
		tmp = b / -a;
	} else if (b <= 6.2e-40) {
		tmp = Math.sqrt((((c * -4.0) / a) / 4.0));
	} else {
		tmp = c / -b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -2.6e-118:
		tmp = b / -a
	elif b <= 6.2e-40:
		tmp = math.sqrt((((c * -4.0) / a) / 4.0))
	else:
		tmp = c / -b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -2.6e-118)
		tmp = Float64(b / Float64(-a));
	elseif (b <= 6.2e-40)
		tmp = sqrt(Float64(Float64(Float64(c * -4.0) / a) / 4.0));
	else
		tmp = Float64(c / Float64(-b));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -2.6e-118)
		tmp = b / -a;
	elseif (b <= 6.2e-40)
		tmp = sqrt((((c * -4.0) / a) / 4.0));
	else
		tmp = c / -b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -2.6e-118], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 6.2e-40], N[Sqrt[N[(N[(N[(c * -4.0), $MachinePrecision] / a), $MachinePrecision] / 4.0), $MachinePrecision]], $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;b \leq 6.2 \cdot 10^{-40}:\\
\;\;\;\;\sqrt{\frac{\frac{c \cdot -4}{a}}{4}}\\

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


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

    1. Initial program 74.5%

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

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

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

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

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

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

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

    if -2.6e-118 < b < 6.20000000000000021e-40

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified80.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. Step-by-step derivation
      1. add-cube-cbrt79.3%

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}}{a \cdot 2} \]
    8. Step-by-step derivation
      1. mul-1-neg0.0%

        \[\leadsto \frac{\color{blue}{-\sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)} \cdot {\left(\sqrt{-1}\right)}^{2}}}{a \cdot 2} \]
      2. *-commutative0.0%

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

        \[\leadsto \frac{-\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)}}{a \cdot 2} \]
      4. rem-square-sqrt77.2%

        \[\leadsto \frac{-\color{blue}{-1} \cdot \sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)}}{a \cdot 2} \]
      5. rem-cube-cbrt77.8%

        \[\leadsto \frac{--1 \cdot \sqrt{a \cdot \left(c \cdot \color{blue}{-4}\right)}}{a \cdot 2} \]
      6. *-commutative77.8%

        \[\leadsto \frac{--1 \cdot \sqrt{a \cdot \color{blue}{\left(-4 \cdot c\right)}}}{a \cdot 2} \]
      7. distribute-lft-neg-in77.8%

        \[\leadsto \frac{\color{blue}{\left(--1\right) \cdot \sqrt{a \cdot \left(-4 \cdot c\right)}}}{a \cdot 2} \]
      8. metadata-eval77.8%

        \[\leadsto \frac{\color{blue}{1} \cdot \sqrt{a \cdot \left(-4 \cdot c\right)}}{a \cdot 2} \]
      9. *-lft-identity77.8%

        \[\leadsto \frac{\color{blue}{\sqrt{a \cdot \left(-4 \cdot c\right)}}}{a \cdot 2} \]
      10. *-commutative77.8%

        \[\leadsto \frac{\sqrt{a \cdot \color{blue}{\left(c \cdot -4\right)}}}{a \cdot 2} \]
    9. Simplified77.8%

      \[\leadsto \frac{\color{blue}{\sqrt{a \cdot \left(c \cdot -4\right)}}}{a \cdot 2} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt35.6%

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{\sqrt{a \cdot \left(c \cdot -4\right)} \cdot \sqrt{a \cdot \left(c \cdot -4\right)}}{\left(a \cdot 2\right) \cdot \left(a \cdot 2\right)}}} \]
      4. add-sqr-sqrt24.4%

        \[\leadsto \sqrt{\frac{\color{blue}{a \cdot \left(c \cdot -4\right)}}{\left(a \cdot 2\right) \cdot \left(a \cdot 2\right)}} \]
      5. *-commutative24.4%

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

        \[\leadsto \sqrt{\frac{\color{blue}{c \cdot \left(-4 \cdot a\right)}}{\left(a \cdot 2\right) \cdot \left(a \cdot 2\right)}} \]
      7. swap-sqr24.4%

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

        \[\leadsto \sqrt{\frac{c \cdot \left(-4 \cdot a\right)}{\color{blue}{{a}^{2}} \cdot \left(2 \cdot 2\right)}} \]
      9. metadata-eval24.4%

        \[\leadsto \sqrt{\frac{c \cdot \left(-4 \cdot a\right)}{{a}^{2} \cdot \color{blue}{4}}} \]
    11. Applied egg-rr24.4%

      \[\leadsto \color{blue}{\sqrt{\frac{c \cdot \left(-4 \cdot a\right)}{{a}^{2} \cdot 4}}} \]
    12. Step-by-step derivation
      1. associate-/r*24.4%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{c \cdot \left(-4 \cdot a\right)}{{a}^{2}}}{4}}} \]
      2. associate-*r*24.4%

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

        \[\leadsto \sqrt{\frac{\frac{\left(c \cdot -4\right) \cdot a}{\color{blue}{a \cdot a}}}{4}} \]
      4. times-frac32.5%

        \[\leadsto \sqrt{\frac{\color{blue}{\frac{c \cdot -4}{a} \cdot \frac{a}{a}}}{4}} \]
      5. *-inverses32.5%

        \[\leadsto \sqrt{\frac{\frac{c \cdot -4}{a} \cdot \color{blue}{1}}{4}} \]
    13. Simplified32.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{c \cdot -4}{a} \cdot 1}{4}}} \]

    if 6.20000000000000021e-40 < b

    1. Initial program 17.3%

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

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

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

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

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

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

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

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

Alternative 7: 68.4% accurate, 12.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 6.5 \cdot 10^{-301}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 6.5e-301) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 6.5e-301) {
		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 <= 6.5d-301) 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 <= 6.5e-301) {
		tmp = b / -a;
	} else {
		tmp = c / -b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= 6.5e-301:
		tmp = b / -a
	else:
		tmp = c / -b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= 6.5e-301)
		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 <= 6.5e-301)
		tmp = b / -a;
	else
		tmp = c / -b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, 6.5e-301], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 77.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. *-commutative77.2%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified67.9%

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

    if 6.49999999999999991e-301 < b

    1. Initial program 32.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. *-commutative32.7%

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

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

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

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

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

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

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

Alternative 8: 43.1% accurate, 12.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 1000:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c) :precision binary64 (if (<= b 1000.0) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 1000.0) {
		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 <= 1000.0d0) 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 <= 1000.0) {
		tmp = b / -a;
	} else {
		tmp = c / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= 1000.0:
		tmp = b / -a
	else:
		tmp = c / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= 1000.0)
		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 <= 1000.0)
		tmp = b / -a;
	else
		tmp = c / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, 1000.0], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1000:\\
\;\;\;\;\frac{b}{-a}\\

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


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

    1. Initial program 73.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. *-commutative73.0%

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

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

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

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

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

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

    if 1e3 < b

    1. Initial program 14.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. *-commutative14.9%

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cbrt-cube9.9%

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{\sqrt[3]{{\left(a \cdot 2\right)}^{3}}}} \]
    7. Step-by-step derivation
      1. rem-cbrt-cube14.9%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\sqrt{b} \cdot \sqrt{b}} + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{a \cdot 2} \]
      7. add-sqr-sqrt8.8%

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

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

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

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

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

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

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

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

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

Alternative 9: 11.2% 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.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. *-commutative54.4%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
  3. Simplified54.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. Step-by-step derivation
    1. add-cbrt-cube29.1%

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

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

    \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{\sqrt[3]{{\left(a \cdot 2\right)}^{3}}}} \]
  7. Step-by-step derivation
    1. rem-cbrt-cube54.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 2.6% accurate, 38.7× speedup?

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

\\
\frac{b}{a}
\end{array}
Derivation
  1. Initial program 54.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. *-commutative54.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

?
herbie shell --seed 2024136 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))