How to solve a fourth order algebraic equation?

조회 수: 187 (최근 30일)
R7 DR
R7 DR 2015년 2월 12일
댓글: Walter Roberson 2020년 8월 21일
How to solve the value of x for the equation 2x^4+x=34.
Can we solve the fourth order algebraic equations using solve command?
Thanks
  댓글 수: 2
Jaan Raa
Jaan Raa 2020년 8월 20일
How to solve the value of x for the equations: a_0*x^n + a_1*x^(n-1) +...+ a_(n-1)*x + a_n = 0
Can we solve the nth degree using solve commands?
Walter Roberson
Walter Roberson 2020년 8월 21일
For degree 5 or higher, solve() will typically return a data structure the "stands in" for the roots. There are some polynomials of degree 5 or higher that solve() is able to provide exact solutions for, but most of them it cannot handle. This is not due to a limitation of solve() : it has been mathematically proven that degree 5 and higher is not certain to have solutions that are "algebraic numbers"
For degree 3 and degree 4, solve() will sometimes return exact solutions, and other times it will returns the kind of data structure mentioned above that "stands in" for the roots. In the cases where it does not return exact roots, you can pass 'MaxDegree', 3 or 'MaxDegree', 4 to solve() to get exact solutions. However exact solutions for degree 4 are long and there are very few humans that can make sense of the resulting expressions just by reading them.
For degree 2, solve() nearly always returns exact solutions, but every once in a while returns the kind of data structure mentioned above.
In most cases, the data structure "standing in" for the roots is more useful to carry around, at least until you need final answers.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2015년 2월 12일
It’s easier than that. Create a vector of its coefficients and use the roots function:
% 2x^4+x=18 -> 2x^4 + x -18 = 0
coefvct = [2 0 0 1 -18]; % Coefficient Vector
x = roots(coefvct) % Solution
produces:
x =
-1.7732e+000 + i
41.6666e-003 + 1.7326e+000i
41.6666e-003 - 1.7326e+000i
1.6899e+000 + i
Two real and two complex roots.
  댓글 수: 6
Star Strider
Star Strider 2015년 2월 13일
R7 DR’s ‘Answer’ moved here...
Hi Thanks for the reply.
My equation got changed, now I have to solve two varying constants.
For example
ax^4+x=C
C=20,22,24,26,28,30........50
a=1,2,3...16
Could you please tell me, how to find the 'x' value at different 'C' and 'a' values.
I wrote the code like this...
C = [20:2:50]; % Define ‘C’
X = nan(4, length(C));
a=[1:1:length(C)] % Define ‘a’
for i = 1:length(C)
X(:,i) = roots([a(i) 0 0 1 -C(i)]); % Coefficient Matrix
end
Thanks
Star Strider
Star Strider 2015년 2월 13일
My pleasure.
Don’t use ‘i’ and ‘j’ as variables. MATLAB uses them for its imaginary operators, and using them as variables will cause confusion.
This is easy. You need two nested loops and a redefined preallocation:
C = [20:2:50]; % Define ‘C’
a = 1:16; % Define ‘a’
X = nan(4, length(C), length(a)); % Preallocate ‘X’
for k1 = 1:length(C)
for k2 = 1:length(a)
X(:,k1,k2) = roots([a(k2) 0 0 1 -C(k1)]); % Coefficient Matrix
end
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by