How do i input this on MATLAB

8 次查看(过去 30 天)
Nate
Nate 2022-7-5
How can i input x^3+px+q=0 on MATLAB and find x in terms of p & q?
  1 个评论
Image Analyst
Image Analyst 2022-7-13
Original question in case he edits this one away:
How can i input x^3+px+q=0 on MATLAB and find x in terms of p & q?

请先登录,再进行评论。

回答(1 个)

John D'Errico
John D'Errico 2022-7-5
Assuming that p and q are real numbers, do you understand there will ALWAYS be three solutions to the problem, and that for many values of p and q, exactly two of those solutions will be complex valued?
cubicroots = @(p,q) roots([1 0 p q]);
format long
cubicroots(2,3)
ans =
0.500000000000000 + 1.658312395177701i 0.500000000000000 - 1.658312395177701i -1.000000000000000 + 0.000000000000000i

类别

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