Methods used inside "roots" and "solve" functions to solve polynomial equations.

5 views (last 30 days)
I am wondering to know which mathematical methods is used inside the Matlab "roots" and "solve" functions to solve for polynomial equations. I read their descriptions and there are no references to methods or papers used to build these functions.

Answers (1)

Torsten
Torsten on 17 Jan 2023
Edited: Torsten on 17 Jan 2023
For numerial computation of polynomial roots, see
For symbolic computation of polynomial roots, see the analytical formula for polynomials up to degree 4.
In short: numerically, the roots of a polynomial are computed as the eigenvalues of the companion matrix.
  4 Comments
Mahrad Sharifvaghefi
Mahrad Sharifvaghefi on 17 Jan 2023
I see. Many thanks. So the difference between the solutions given by "solve" vs "roots" in the example below should be related to numerical accuracy rather than difference in methods.
syms f(x)
f(x) = (x-20)*(x-19)*(x-18)*(x-17)*(x-16)*(x-15)*(x-14)*(x-13)*(x-12)*(x-11)*...
(x-10)*(x-9)*(x-8)*(x-7)*(x-6)*(x-5)*(x-4)*(x-3)*(x-2)*(x-1);
fs = collect(f);
c = double(coeffs(fs,'All'));
tic
roots(c)
ans = 20×1
19.9998 19.0019 17.9909 17.0254 15.9463 15.0755 13.9148 13.0743 11.9533 11.0250
toc
Elapsed time is 0.242319 seconds.
tic
double(solve(fs,x))
ans = 20×1
1 2 3 4 5 6 7 8 9 10
toc
Elapsed time is 0.309659 seconds.

Sign in to comment.

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!