Third-order polynomial equation which complex roots

조회 수: 4 (최근 30일)
Carola Forlini
Carola Forlini 2024년 2월 3일
답변: Carola Forlini 2024년 2월 6일
Hi,
I want to plot the three roots of c (real and imaginary) as a function of k for the following third-order polynomial equation:
I am using fsolve to code it but this requires three initial guesses which are hard to identify for the given equation.
Any suggestions?
Thank you

채택된 답변

Carola Forlini
Carola Forlini 2024년 2월 6일
Thank you for all the answers.
At the end the easiest way was to calculate first the discriminant of thee polynomio for a range of k and then use the roots function to calculate the solution. In this way I have better control on the expected solutions since the discriminant will tell me if I should have all real roots or real and complex conjugates one.

추가 답변 (2개)

Dyuman Joshi
Dyuman Joshi 2024년 2월 3일
이동: Matt J 2024년 2월 3일
Define the polynomial as a function handle of the variable 'k' and use roots for different values of 'k'.
Also, note that you will need to plot the real and imaginary separately.

Walter Roberson
Walter Roberson 2024년 2월 3일
syms c k L
eqn = c^3 ...
- c^2*(2*k*exp(4*k*L) + 2*k*exp(2*k*L) + exp(4*k*L) - 6*k^2*exp(2*k*L) + 1) / (2*exp(2*k*L) * k * (exp(2*k*L)+1)) ...
- c*(-k*exp(4*k*L) + 2*k*exp(2*k*L) - k + 2*exp(4*k*L) - 2) / (2*exp(2*k*L)*k^2*(exp(2*k*L) + 1)) ...
+ (exp(4*k*L) - 2*exp(2*k*L) + 1) / (2*exp(2*k*L)*k^3*(exp(2*k*L) + 1))
eqn = 
solutions = solve(eqn, c, 'maxdegree', 3)
solutions = 
sol= subs(solutions, L, 2); %arbitrary
%vpa(limit(sol(1), k, 0, 'left'))
%vpa(limit(sol(1), k, 0, 'right'))
tiledlayout('flow');
nexttile(); fplot([real(sol(1)), imag(sol(1))], [-3 3]); title('root #1');
nexttile(); fplot([real(sol(2)), imag(sol(3))], [-5 5]); title('root #2');
nexttile(); fplot([real(sol(3)), imag(sol(3))], [-3 3]); title('root #3');
  댓글 수: 3
Walter Roberson
Walter Roberson 2024년 2월 3일
syms c k L
eqn = c^3 ...
- c^2*(2*k*exp(4*k*L) + 2*k*exp(2*k*L) + exp(4*k*L) - 6*k^2*exp(2*k*L) + 1) / (2*exp(2*k*L) * k * (exp(2*k*L)+1)) ...
- c*(-k*exp(4*k*L) + 2*k*exp(2*k*L) - k + 2*exp(4*k*L) - 2) / (2*exp(2*k*L)*k^2*(exp(2*k*L) + 1)) ...
+ (exp(4*k*L) - 2*exp(2*k*L) + 1) / (2*exp(2*k*L)*k^3*(exp(2*k*L) + 1));
solutions = solve(eqn, c, 'maxdegree', 3);
sol= subs(solutions, L, 2); %arbitrary
%vpa(limit(sol(1), k, 0, 'left'))
%vpa(limit(sol(1), k, 0, 'right'))
tiledlayout('flow');
%nexttile(); fplot([real(sol(1)), imag(sol(1))], [-3 3]); title('root #1');
%nexttile(); fplot([real(sol(2)), imag(sol(3))], [-5 5]); title('root #2');
nexttile(); fplot([real(sol(3)), imag(sol(3))], [-1 1]); title('root #3');
Walter Roberson
Walter Roberson 2024년 2월 3일
syms c k L
eqn = c^3 ...
- c^2*(2*k*exp(4*k*L) + 2*k*exp(2*k*L) + exp(4*k*L) - 6*k^2*exp(2*k*L) + 1) / (2*exp(2*k*L) * k * (exp(2*k*L)+1)) ...
- c*(-k*exp(4*k*L) + 2*k*exp(2*k*L) - k + 2*exp(4*k*L) - 2) / (2*exp(2*k*L)*k^2*(exp(2*k*L) + 1)) ...
+ (exp(4*k*L) - 2*exp(2*k*L) + 1) / (2*exp(2*k*L)*k^3*(exp(2*k*L) + 1));
solutions = solve(eqn, c, 'maxdegree', 3);
sol= subs(solutions, L, 2); %arbitrary
vpa(limit(sol(3), k, 0, 'left'))
ans = 
vpa(limit(sol(3), k, 0, 'right'))
ans = 

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

카테고리

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