Third-order polynomial equation which complex roots

4 views (last 30 days)
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

Accepted Answer

Carola Forlini
Carola Forlini on 6 Feb 2024
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.

More Answers (2)

Dyuman Joshi
Dyuman Joshi on 3 Feb 2024
Moved: Matt J on 3 Feb 2024
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 on 3 Feb 2024
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 Comments
Walter Roberson
Walter Roberson on 3 Feb 2024
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 on 3 Feb 2024
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 = 

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!