How to solve forth order Polynomial (equation) with one independent variable and two constants.

조회 수: 7 (최근 30일)
Dear MATLAB experts,
I have an forth order polynomial (equation) as follow:
(A^2*y^4) + (4*x*A^2*y^3) + ((4*B-4-2*A^2)*y^2) + ((8-8*x-4*A^2*x)*y) + (8*x-4+A^2-4*x^2*B) = 0;
Where, A and B are constants and y is function of x. The independent variable x varies between 0 and 1 (0<=x<=1).
My questions are:
  1. Is there any way to define A and B as a constants instead of set them as a numbers since the equation is to be used in iterative code and thus A and B change from time to time.
  2. Need to find the function y=f(x).
I have tried
Equation=((A^2*y^4)+(4*x*A^2*y^3)+(((4*B)-4-(2*A^2))*y^2)+((8-(8*x)-(4*A^2*x))*y)+((8*x)-4+(A^2)-(4*x^2*B)));
solve(Equation,y);
The MATLAB version i have is 7.10.0 (R2010a), but not an issue if answers in newer version.
I really appreciate any suggestions
Thank you
Aziz

답변 (1개)

Walter Roberson
Walter Roberson 2016년 2월 1일
If you have the Symbolic Toolbox, you can use
syms A B x y
Equation=((A^2*y^4)+(4*x*A^2*y^3)+(((4*B)-4-(2*A^2))*y^2)+((8-(8*x)-(4*A^2*x))*y)+((8*x)-4+(A^2)-(4*x^2*B)));
sol := solve(Equation, y);
The solution you get will be a RootOf() a quartic (polynomial of order 4), so there are 4 solutions, some of which might be imaginary at portions of the range x = 0 to 1. You can convert this to a function by using
Y = matlabFunction(sol, 'vars', [x A B]);
after which Y will be a function handle of a function that takes 3 parameters in the order x, A, B, and which should accept a vector of x values.
  댓글 수: 2
Abdulaziz Abutunis
Abdulaziz Abutunis 2016년 2월 2일
편집: Abdulaziz Abutunis 2016년 2월 2일
Thank you Walter for the help. If I keep the semicolon after sol then I will have this error ??? Undefined function or method 'sol' for input arguments of type 'char'.
Error in ==> Blocjage_Equations at 13 sol := solve(Equation, y); If i delete the semicolon then I have this Error shown ??? Undefined function or method 'sol' for input arguments of type 'char'.
Error in ==> Blocjage_Equations at 13 sol := solve(Equation, y);
Thanks, Aziz

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by