Use \"Function\" in the code Consider the cubic equation: f(x)-ABr +ar+D. The in
ID: 3877185 • Letter: U
Question
Use "Function" in the code
Consider the cubic equation: f(x)-ABr +ar+D. The inflections (turning points) of the curve will occur where the deaivative ofjis zero. The locations of these zeros can be found by finding the roots (zeros) of the quadratic equation: g(x)-3Ax +2Bx+C that the roots of a general quadratic equation e(x) =ar +br + care: /b -4ac 2a 2a a. [6 points] Using the expressions above, write a MATLAB function that will take as input the coefficients A, B and C, and provide as output the locations of the turning points of f(x). Remember that there may be zero, one or two turning points, so your function will need to work intelligently for each case.Explanation / Answer
% finds the roots of the equation
function arr = CubicEquation(A, B, C)
% Assign parameters of g(x) to Q(x)
a = 3*A;
b = 2*B;
c = C;
% roots finds the solution of the equation
arr = roots([a b c]);
end
============================================
OUTPUT:
>> CubicEquation(3, -2, -4)
ans =
0.9250
-0.4805
>> CubicEquation(3, 0, -4)
ans =
0.6667
-0.6667
>> CubicEquation(0, -2, -4)
ans =
-1
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.