Multidimensional Polynomial Root Finding
조회 수: 5 (최근 30일)
이전 댓글 표시
I am trying to write a program to solve for the roots (x) of a 4th order polynomial of the form:
ax^4 + bx^3 + cx^2 + dx + e = 0
However, the coefficients of the above polynomial change over time with n time steps. Each coefficient has it's own equation based on other variables that change in time. So what I've been trying to do is write a 3 dimensional array that is 1 row, 5 columns representing each coefficient and n time steps:
P( 1, 5, n )
Then I was trying to take the root of all the elements in that row for any given time step. But I'm not sure how to create a new array that includes the roots of the polynomial solutions to each time step n. The roots function creates a matrix that is 4 rows by 1 column (only 2 dimensional). nts is the last time step.
For n = 1:nts
Some array ( 4, 1, n ) = roots ( P(1, 5, n )
Once I have this new array, I need to be able to call on the 3rd root in the matrix or Some array ( 3, 1, n ).
I'm not too familiar with Matlab but it's the only way I can solve these roots as Excel Solver is not working.
댓글 수: 0
채택된 답변
Walter Roberson
2012년 6월 8일
4th order polynomials have explicit solutions, so you can construct the solutions symbolically and then use matlabFunction() to convert that to a function handle. Then apply that function handle to grids of the list of values over time, [A, B, C, D, E] = ndgrid([a1 a2... an], [b1 b2 ...bn], [c1..cn], [d1..dn], [e1...en])
I am not certain whether MuPAD knows the algebraic solution to the quartic; whether it does might depend upon the version. In Maple it would be coded as
[allvalues(solve(a*x^4+b*x^3+c*x^2+d*x+e, x))]
I have not yet found any MuPAD equivalent of Maple's allvalues()
댓글 수: 1
Walter Roberson
2012년 6월 9일
You might be able to get the explicit solution for the quartic by using
solve(a*x^4+b*x^3+c*x^2+d*x+e, x, 'MaxDegree', 4)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!