Third-order polynomial equation which complex roots

4 次查看(过去 30 天)
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 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by