How to solve a fourth order algebraic equation?

205 views (last 30 days)
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 Comments
Jaan Raa
Jaan Raa on 20 Aug 2020
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 on 21 Aug 2020
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.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 12 Feb 2015
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 Comments
Star Strider
Star Strider on 13 Feb 2015
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 on 13 Feb 2015
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

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!