Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In addition to a quadratic formula, there is also a cubic formula for determinin

ID: 3282989 • Letter: I

Question

In addition to a quadratic formula, there is also a cubic formula for determining the three roots of a cubic polynomial. Look up this formula in a book or on a website. Implement a matlab function called XXcubicpolynomialroots.m, The function should take as input b,c,d for the cubic polynomial x3 + bx2 + cx + d and return the three roots of a cubic polynomial using this formula. You may not use any built-in matlab function (roots, solve, etc.) to solve the equation. In addition to a quadratic formula, there is also a cubic formula for determining the three roots of a cubic polynomial. Look up this formula in a book or on a website. Implement a matlab function called XXcubicpolynomialroots.m, The function should take as input b,c,d for the cubic polynomial x3 + bx2 + cx + d and return the three roots of a cubic polynomial using this formula. You may not use any built-in matlab function (roots, solve, etc.) to solve the equation.

Explanation / Answer

function [x] = cubic (a,b,c,d) xN = -b/(3*a); yN = d + xN * (c + xN * (b + a*xN)); two_a = 2*a; delta0 = (b*b-3*a*c)/(9*a*a); h = two_a * two_a * delta0^3; dis = yN*yN - h; pow = 1/3; if dis >= eps % one real root: dis_sqrt = sqrt(dis); rp = yN - dis_sqrt; rq = yN + dis_sqrt; p = -sign(rp) * ( sign(rp)*rp/two_a )^pow; q = -sign(rq) * ( sign(rq)*rq/two_a )^pow; x(1) = xN + p + q; x(2) = xN + p * exp(2*pi*i/3) + q * exp(-2*pi*i/3); x(3) = conj(x(2)); elseif dis < -eps % three distinct real roots: theta = acos(-yN/sqrt(h_sq))/3; delta = sqrt(delta0); two_d = 2*delta; twop3 = 2*pi/3; x = [xN + two_d*cos(theta); ... xN + two_d*cos(twop3-theta); ... xN + two_d*cos(twop3+theta)]; else % abs(dis)
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote