| Alternative 1 | |
|---|---|
| Error | 3.1 |
| Cost | 53376 |
\[\left(-\left(\frac{c}{b} + a \cdot \frac{{c}^{2}}{{b}^{3}}\right)\right) + \left({c}^{3} \cdot \left(\frac{{a}^{2}}{{b}^{5}} \cdot -2\right) + -5 \cdot \frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}}\right)
\]
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
:precision binary64
(+
(*
-0.25
(/
(+
(pow (* -2.0 (* (pow c 2.0) (pow a 2.0))) 2.0)
(* 16.0 (* (pow c 4.0) (pow a 4.0))))
(* a (pow b 7.0))))
(+
(* -1.0 (/ c b))
(+
(* -2.0 (* (pow a 2.0) (/ (pow c 3.0) (pow b 5.0))))
(* -1.0 (* a (/ (pow c 2.0) (pow b 3.0))))))))double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
double code(double a, double b, double c) {
return (-0.25 * ((pow((-2.0 * (pow(c, 2.0) * pow(a, 2.0))), 2.0) + (16.0 * (pow(c, 4.0) * pow(a, 4.0)))) / (a * pow(b, 7.0)))) + ((-1.0 * (c / b)) + ((-2.0 * (pow(a, 2.0) * (pow(c, 3.0) / pow(b, 5.0)))) + (-1.0 * (a * (pow(c, 2.0) / pow(b, 3.0))))));
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = ((-0.25d0) * (((((-2.0d0) * ((c ** 2.0d0) * (a ** 2.0d0))) ** 2.0d0) + (16.0d0 * ((c ** 4.0d0) * (a ** 4.0d0)))) / (a * (b ** 7.0d0)))) + (((-1.0d0) * (c / b)) + (((-2.0d0) * ((a ** 2.0d0) * ((c ** 3.0d0) / (b ** 5.0d0)))) + ((-1.0d0) * (a * ((c ** 2.0d0) / (b ** 3.0d0))))))
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);
}
public static double code(double a, double b, double c) {
return (-0.25 * ((Math.pow((-2.0 * (Math.pow(c, 2.0) * Math.pow(a, 2.0))), 2.0) + (16.0 * (Math.pow(c, 4.0) * Math.pow(a, 4.0)))) / (a * Math.pow(b, 7.0)))) + ((-1.0 * (c / b)) + ((-2.0 * (Math.pow(a, 2.0) * (Math.pow(c, 3.0) / Math.pow(b, 5.0)))) + (-1.0 * (a * (Math.pow(c, 2.0) / Math.pow(b, 3.0))))));
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
def code(a, b, c): return (-0.25 * ((math.pow((-2.0 * (math.pow(c, 2.0) * math.pow(a, 2.0))), 2.0) + (16.0 * (math.pow(c, 4.0) * math.pow(a, 4.0)))) / (a * math.pow(b, 7.0)))) + ((-1.0 * (c / b)) + ((-2.0 * (math.pow(a, 2.0) * (math.pow(c, 3.0) / math.pow(b, 5.0)))) + (-1.0 * (a * (math.pow(c, 2.0) / math.pow(b, 3.0))))))
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 code(a, b, c) return Float64(Float64(-0.25 * Float64(Float64((Float64(-2.0 * Float64((c ^ 2.0) * (a ^ 2.0))) ^ 2.0) + Float64(16.0 * Float64((c ^ 4.0) * (a ^ 4.0)))) / Float64(a * (b ^ 7.0)))) + Float64(Float64(-1.0 * Float64(c / b)) + Float64(Float64(-2.0 * Float64((a ^ 2.0) * Float64((c ^ 3.0) / (b ^ 5.0)))) + Float64(-1.0 * Float64(a * Float64((c ^ 2.0) / (b ^ 3.0))))))) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
function tmp = code(a, b, c) tmp = (-0.25 * ((((-2.0 * ((c ^ 2.0) * (a ^ 2.0))) ^ 2.0) + (16.0 * ((c ^ 4.0) * (a ^ 4.0)))) / (a * (b ^ 7.0)))) + ((-1.0 * (c / b)) + ((-2.0 * ((a ^ 2.0) * ((c ^ 3.0) / (b ^ 5.0)))) + (-1.0 * (a * ((c ^ 2.0) / (b ^ 3.0)))))); 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]
code[a_, b_, c_] := N[(N[(-0.25 * N[(N[(N[Power[N[(-2.0 * N[(N[Power[c, 2.0], $MachinePrecision] * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(16.0 * N[(N[Power[c, 4.0], $MachinePrecision] * N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(N[(-2.0 * N[(N[Power[a, 2.0], $MachinePrecision] * N[(N[Power[c, 3.0], $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 * N[(a * N[(N[Power[c, 2.0], $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
-0.25 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-1 \cdot \frac{c}{b} + \left(-2 \cdot \left({a}^{2} \cdot \frac{{c}^{3}}{{b}^{5}}\right) + -1 \cdot \left(a \cdot \frac{{c}^{2}}{{b}^{3}}\right)\right)\right)
Results
Initial program 43.7
Simplified43.7
[Start]43.7 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\] |
|---|---|
rational.json-simplify-2 [=>]43.7 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}}
\] |
Applied egg-rr43.7
Taylor expanded in b around inf 3.1
Simplified3.1
[Start]3.1 | \[ -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(-0.25 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right)
\] |
|---|---|
rational.json-simplify-41 [=>]3.1 | \[ \color{blue}{-0.25 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(\left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right) + -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)}
\] |
rational.json-simplify-1 [<=]3.1 | \[ -0.25 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \color{blue}{\left(-1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right)}
\] |
rational.json-simplify-41 [=>]3.1 | \[ -0.25 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \color{blue}{\left(-1 \cdot \frac{c}{b} + \left(-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right)}
\] |
rational.json-simplify-49 [=>]3.1 | \[ -0.25 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-1 \cdot \frac{c}{b} + \left(-2 \cdot \color{blue}{\left({a}^{2} \cdot \frac{{c}^{3}}{{b}^{5}}\right)} + -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right)
\] |
rational.json-simplify-49 [=>]3.1 | \[ -0.25 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-1 \cdot \frac{c}{b} + \left(-2 \cdot \left({a}^{2} \cdot \frac{{c}^{3}}{{b}^{5}}\right) + -1 \cdot \color{blue}{\left(a \cdot \frac{{c}^{2}}{{b}^{3}}\right)}\right)\right)
\] |
Final simplification3.1
| Alternative 1 | |
|---|---|
| Error | 3.1 |
| Cost | 53376 |
| Alternative 2 | |
|---|---|
| Error | 4.1 |
| Cost | 33664 |
| Alternative 3 | |
|---|---|
| Error | 4.1 |
| Cost | 33472 |
| Alternative 4 | |
|---|---|
| Error | 6.1 |
| Cost | 13568 |
| Alternative 5 | |
|---|---|
| Error | 11.2 |
| Cost | 7556 |
| Alternative 6 | |
|---|---|
| Error | 11.3 |
| Cost | 7556 |
| Alternative 7 | |
|---|---|
| Error | 12.1 |
| Cost | 256 |
| Alternative 8 | |
|---|---|
| Error | 62.0 |
| Cost | 64 |
herbie shell --seed 2023064
(FPCore (a b c)
:name "Quadratic roots, medium range"
:precision binary64
:pre (and (and (and (< 1.1102230246251565e-16 a) (< a 9007199254740992.0)) (and (< 1.1102230246251565e-16 b) (< b 9007199254740992.0))) (and (< 1.1102230246251565e-16 c) (< c 9007199254740992.0)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))