Quadratic roots, narrow range

Percentage Accurate: 55.6% → 99.5%
Time: 20.7s
Alternatives: 12
Speedup: 29.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 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: 55.6% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 1.0× speedup?

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

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

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Applied egg-rr0

    \[\leadsto expr\]
  5. Applied egg-rr0

    \[\leadsto expr\]
  6. Taylor expanded in c around 0 0

    \[\leadsto expr\]
  7. Simplified0

    \[\leadsto expr\]
  8. Taylor expanded in c around inf 0

    \[\leadsto expr\]
  9. Simplified0

    \[\leadsto expr\]
  10. Add Preprocessing

Alternative 2: 99.6% accurate, 1.0× speedup?

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

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

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Applied egg-rr0

    \[\leadsto expr\]
  5. Applied egg-rr0

    \[\leadsto expr\]
  6. Taylor expanded in c around 0 0

    \[\leadsto expr\]
  7. Simplified0

    \[\leadsto expr\]
  8. Add Preprocessing

Alternative 3: 99.4% accurate, 1.0× speedup?

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

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

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Applied egg-rr0

    \[\leadsto expr\]
  5. Applied egg-rr0

    \[\leadsto expr\]
  6. Taylor expanded in c around 0 0

    \[\leadsto expr\]
  7. Simplified0

    \[\leadsto expr\]
  8. Applied egg-rr0

    \[\leadsto expr\]
  9. Add Preprocessing

Alternative 4: 90.7% accurate, 1.8× speedup?

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

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

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Taylor expanded in a around 0 0

    \[\leadsto expr\]
  5. Simplified0

    \[\leadsto expr\]
  6. Applied egg-rr0

    \[\leadsto expr\]
  7. Add Preprocessing

Alternative 5: 88.2% accurate, 4.3× speedup?

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

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

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Applied egg-rr0

    \[\leadsto expr\]
  5. Applied egg-rr0

    \[\leadsto expr\]
  6. Taylor expanded in c around 0 0

    \[\leadsto expr\]
  7. Simplified0

    \[\leadsto expr\]
  8. Taylor expanded in c around 0 0

    \[\leadsto expr\]
  9. Simplified0

    \[\leadsto expr\]
  10. Add Preprocessing

Alternative 6: 88.1% accurate, 4.3× speedup?

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

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

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Applied egg-rr0

    \[\leadsto expr\]
  5. Applied egg-rr0

    \[\leadsto expr\]
  6. Taylor expanded in c around 0 0

    \[\leadsto expr\]
  7. Simplified0

    \[\leadsto expr\]
  8. Taylor expanded in c around 0 0

    \[\leadsto expr\]
  9. Simplified0

    \[\leadsto expr\]
  10. Add Preprocessing

Alternative 7: 88.0% accurate, 4.6× speedup?

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

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

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Applied egg-rr0

    \[\leadsto expr\]
  5. Taylor expanded in a around 0 0

    \[\leadsto expr\]
  6. Simplified0

    \[\leadsto expr\]
  7. Add Preprocessing

Alternative 8: 82.0% accurate, 7.7× speedup?

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

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

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Applied egg-rr0

    \[\leadsto expr\]
  5. Applied egg-rr0

    \[\leadsto expr\]
  6. Taylor expanded in c around 0 0

    \[\leadsto expr\]
  7. Simplified0

    \[\leadsto expr\]
  8. Taylor expanded in c around 0 0

    \[\leadsto expr\]
  9. Simplified0

    \[\leadsto expr\]
  10. Add Preprocessing

Alternative 9: 81.9% accurate, 8.9× speedup?

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

\\
\frac{0.5}{-0.5 \cdot \frac{b}{c} + \frac{a \cdot 0.5}{b}}
\end{array}
Derivation
  1. Initial program 57.3%

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Applied egg-rr0

    \[\leadsto expr\]
  5. Taylor expanded in a around 0 0

    \[\leadsto expr\]
  6. Simplified0

    \[\leadsto expr\]
  7. Add Preprocessing

Alternative 10: 64.2% accurate, 29.0× speedup?

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

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

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Applied egg-rr0

    \[\leadsto expr\]
  5. Taylor expanded in b around inf 0

    \[\leadsto expr\]
  6. Simplified0

    \[\leadsto expr\]
  7. Add Preprocessing

Alternative 11: 1.6% 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 57.3%

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Applied egg-rr0

    \[\leadsto expr\]
  5. Taylor expanded in b around inf 0

    \[\leadsto expr\]
  6. Simplified0

    \[\leadsto expr\]
  7. Applied egg-rr0

    \[\leadsto expr\]
  8. Add Preprocessing

Alternative 12: 1.6% accurate, 38.7× speedup?

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

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

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Taylor expanded in b around -inf 0

    \[\leadsto expr\]
  5. Simplified0

    \[\leadsto expr\]
  6. Applied egg-rr0

    \[\leadsto expr\]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024110 
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :precision binary64
  :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))