MatsGranvik

More rigorous root finding algorithm

Sep 11th, 2016
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. (* korrekt mera rigorös algoritm men den hittar inte alla noll \
  2. ställen *)
  3. Do[
  4. (*start*)
  5. (*Mathematica 8*)
  6. Clear[x, polynomial, X, y, polynomialdegree];
  7. (*a är polynomets koefficienter*)
  8. a = {3628800, -10628640, 12753576, -8409500, 3416930, -902055,
  9. 157773, -18150, 1320, -55, 1};
  10. polynomialdegree = Length[a] - kk;
  11. polynomials =
  12. Table[Sum[a[[n]]*x^(n - 1), {n, 1, Length[a]}] - a[[k]]*x^(k - 1) +
  13. a[[k]]*y^(k - 1), {k, 2, Length[a]}];
  14. polynomial = polynomials[[polynomialdegree]];
  15. Print["The polynomial is: ", polynomial]
  16. nn = 8000;
  17. Do[Clear[x, X, y];
  18. X = y /. Solve[polynomial == 0, y, WorkingPrecision -> 100][[i]];
  19. x = 0;
  20. Table[x = N[Round[X, 10^-30], 30], {n, 1, nn}];
  21. y = x;
  22. Print["x", i, " = ", x, " polynomial value at x", i, " is: ",
  23. polynomial];, {i, 1, polynomialdegree}]
  24. (*end*), {kk, 1, Length[a] - 1}]
Advertisement
Add Comment
Please, Sign In to add comment