here is the definition of the function bair
bair[pol_, p0_, m_, p_] := Module[{n, a, r, i, s, j, b, c, tol},
tol = 0.0001;
n = Length[pol] - 1;
(* primer for*)For[i = 0, i <= n, i++,
a[i] = SetPrecision[pol[[n - i + 1]], p]];
r = SetPrecision[p0[[1]], p]; s = SetPrecision[p0[[2]], p];
b[0] = SetPrecision[2 tol, p];
b[1] = SetPrecision[2 tol, p];
(* segundo for*)For[j = 1, j <= m, j++,
b[n] = SetPrecision[a[n], p];
b[n - 1] = SetPrecision[a[n - 1] + r b[n], p];
(* tercer for*)For[i = n - 2, i >= 0, i--,
b[i] = SetPrecision[a[i] + r b[i + 1] + s b[i + 2], p]];
c[n] = SetPrecision[b[n], p];
c[n - 1] = SetPrecision[b[n - 1] + r c[n], p];
(* ultimo for*)For[i = n - 2, i >= 1, i--,
c[i] = SetPrecision[b[i] + r c[i + 1] + s c[i + 2], p]];
r = SetPrecision[r + (-b[1] c[2] + b[0] c[3])/(c[2]^2 - c[1] c[3]),
p];
s = SetPrecision[s + (-b[0] c[2] + b[1] c[1])/(c[2]^2 - c[1] c[3]),
p]];
Print["El factor cuadratico es: x^2", If[-r > 0, "+", ""], -r, "x",
If[-s > 0, "+", ""], -s]]
now make comparisons runtime between the two functions with the same arguments
(* Using the bair function*)
Timing[bair[{1, -7, 14, 2, -20}, {5, 3}, 7, 10]]
(* Using the bairs function*)
Timing[bairs[{1, -7, 14, 2, -20}, {5, 3}, 7]]
(* Using the bair function*)
Timing[bair[{1, -3, -9, -27, -162}, {2, 7}, 7, 10]]
(* Using the bairs function*)
Timing[bairs[{1, -3, -9, -27, -162}, {2, 7}, 7]]
if anyone has any idea of the situation happens for this time difference, please comment on this, because I have not seen what the conflict to have this result, thanks in advance
attached my file so they can make comparisons
Attachments: