Matlab code to find the roots of cubic equation and the code has to be written in script file:-
The code is explained in the form of comments i.e followed by the symbol %
prompt='enter the values of a3,a2,a1,a0 respectively \n'; % to
display the message to user
x=input(prompt); % input entered by the user will be stored in x in
the form of vector
a3=x(1); % initializing a3
a2=x(2); % initializing a2
a1=x(3); % initializing a1
a0=x(4); % initializing a0
A=a2/a3; % assigning the value of A as given by the formula for A
in the given problem
B=a1/a3; % assigning the value of B as given by the formula for B
in the given problem
C=a0/a3; % assigning the value of C as given by the formula for C
in the given problem
Q=(3*B-A*A)/9; % assigning the value of Q as given by the formula
for Q in the given problem
R=(9*A*B-27*C-2*A*A*A)/54; % assigning the value of R as given by
the formula for R in the given problem
D=(Q*Q*Q)+(R*R); % assigning the value of D as given by the formula
for D in the given problem
formatspec='The equation %4.2fx^3+%4.2fx^2+%4.2fx+%4.2f has complex
roots \n';
% formatspecifier to set the format for complex roots
formatspec1='The roots of the equation %4.2fx^3 + %4.2fx^2 + %4.2fx
+ %4.2f are %4.2f , %4.2f and %4.2f \n';
% formatspecifier to set the format for other than complex
roots
if D>0 % for D>0
fprintf(formatspec,x); % print that there are complex roots
end
if D==0 % for D==0
x1=(2*R^(1/3))-(A/3); % caluculate x1
x2= -(R^(1/3))-(A/3); % caluculate x2
x3=x2; % x2 and x3 are equal
fprintf(formatspec1,a3,a2,a1,a0,x1,x2,x3); % print the roots
end
if D<0
t=acosd(R/((-Q)^(3/2))); % caluculate theta
x1=2*((-Q)^(1/2))*(cosd(t/3))-(A/3); % caluculate x1
x2=2*((-Q)^(1/2))*(cosd(t/3+120))-(A/3); % caluculate x2
x3=2*((-Q)^(1/2))*(cosd(t/3+240))-(A/3); % caluculate x3
fprintf(formatspec1,a3,a2,a1,a0,x1,x2,x3); % print the roots
end
Output:-
After writing the above code run the program and enter the values for a3,a2,a1 and a0 in the command prompt for the given respective 3 equations to get the following output.
The following procedure can be used to determine the roots of a cubic equation a_3x^3 +...
1(a) Find the square roots of the complex number z -3 + j4, expressing your answer in the form a + jb. Hence find the roots for the quadratic equation: x2-x(1- 0 giving your answer in the form p+ q where p is a real number and q is a complex number. I7 marks] (b) Express: 3 + in the form ω-reje (r> 0, 0 which o is real and positive. θ < 2π). Hence find the smallest value of...
The roots of the quadratic equation ax2 + bx + c = 0, a following formula: 0 are given by the In this formula, the term i2 - 4ac is called the discriminant. If b4ac 0 then the equation has a single (repeated) root. If -4ac > 0, th equation complex roots. Write a program that prompts the user to input the value of a (the coefficient of ), b (the coefficient of x), and c (the n has two...
The purpose of this question is to calculate the three cubic roots of a complex number. A complex number is of the form a + ib where i is v-1. The magnitude r of a complex number is Vab. The complex number a + ib can be written as r(cos θ + i sin θ). Therefore a -r cose and b rsin0 and b/a (r sin0)/(r cos0) - tane e- arctan(b/a). The 3 cubic roots of a complex number are...
C++ The roots of the quadratic equation ax² + bx + c = 0, a ≠ 0 are given by the following formula: In this formula, the term b² - 4ac is called the discriminant. If b² - 4ac = 0, then the equation has a single (repeated) root. If b² - 4ac > 0, the equation has two real roots. If b² - 4ac < 0, the equation has two complex roots. Instructions Write a program that prompts the...
Please solve this using reduction of order and find a second solution in case 3. Euler Equation abyg bet r- soume x o ar(rbrco in dicia) equation Case 1. distinet , realroots rr Case Q. Complex roots r#Aty; . y; c.xx cos ( μ hlx)) + da Asin (μ In(x) Case3. equal rools r a. VJseducion Use reduchion d order to lind secand 5olution ar(r- br +CO has two ea ual roots Cin 0 Euler Equation abyg bet r- soume...
Visual Basic You are asked to develop a Visual Basic Net application that can determine roots of a requirements of this project are as follows: 1) Design a form to allow users to define a quadratic equation and to find the roots of the equation. The form should have a label that shows this message: Solving a quadratic equation ax2+bx+c=0 The form should have three textboxes in which users enter the values of a, b, and c The form should...
1) Using Matlab, find all real and complex roots of the following polynomial equation: (x-1)(x-2)(x-3)(x-4)(x-5)(x-6)(x-7)=8 2) Using Matlab, find the root for the following system of equations. Both x and y are positive. a: (x^2)cos(y)=1 b: e^(-4x)+1
Find the probability that the three roots of the cubic equation x ^ 3-3ax + 2b = 0 are real for all values of the coefficients a, b such that | a | <= 3 and | b | <= 6 de que las tres raices de la ecuacion cubica Encontrar la probabilidad c3 -3 ax + 2b 0 sean reales para todos los valores de los oeficientes a, b tales que lal s 3 y lbl s 6.
NAME Q1. (30pts) Solve the quadratic equation z2-(3+3i)z +6+2i = 0 by realizing the following plan: (i) find the discriminant A of the equation; (ii) write a program for a scientific calculator to obtain the polar form r(cos 0 + i sin 0) of A and the 'first' root + isin COS 2 of degree two of A; (iii) execute the program, fix the results, find another root A2 of A of degree two (before executing the program, make sure...
A quadratic equation is generally represented as, ax^2 + bx + c The root(s) of the above quadratic equation is computed using the following formula, root1 = (-b + sqrt(D))/ 2a root2 = (-b - sqrt(D))/2a Where D is the discriminant of the quadratic equation and is computed as, D = b^2 - 4ac Given the value of D, the roots of a quadratic equation can be categorized as follows, D > 0 : Two distinct real roots D =...