P1.2.11 Consider the cubic function q(x)=ax^3+ bx2 +bx^2 +cx+d a not equal to 0.
ID: 2990258 • Letter: P
Question
P1.2.11 Consider the cubic function q(x)=ax^3+ bx2 +bx^2 +cx+d a not equal to 0. We say that q is simple if its three roots are real and distinct. We say that q is monotone if it is either always increasing or always decreasing. If q1(x) = (x ? 1)(x ? 2)(x ? 3) = x^3 ? 6x^2 + 11 x ? 6 q2(x)= (x ?1)(x ? 2)(x ? 3) +100 = x3 ? 6x^2 + 1lx + 94 q3(x) = ?x(x^2 +1) = ?x^3 ? x then q1 is simple but not monotone, q2 is neither simple nor monotone, and q3 is monotone but not simple. In this problem you are to write a script that can be used to check for these situations. It turns out that the derivative q1(x) and its roots r1 and r2 are important. The script should start by prompting the user for the four coefficients a, b, c, and d. These four values should then be printed using 10 .6f format. If q(x) does not have distinct real roots, then q is monotone and the message monotone should be printed. Otherwise, the values of n, q(n), rl, and q(n) should be printed. In this latter case q is not monotone and we can deduce from the output whether or not it is simple. In particular, q is simple if and only if q(r1)q(r2)Explanation / Answer
clear all
clc
syms x
a=input('Enter value of a ');
b=input('Enter value of b ');
c=input('Enter value of c ');
d=input('Enter value of d ');
q(x)=a*x^3+b*x^2+c*x+d;
qdash=diff(q);
if(~isreal(solve(qdash==0)))
disp('Monotone');
else
r=solve(qdash==0);
r1=eval(r(1))
r2=eval(r(2))
qr1=eval(q(r1))
qr2=eval(q(r2))
if (qr1*qr2<0)
disp('q is Simple');
end
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.