logo

Assignment 5

   

Added on  2023-04-07

11 Pages858 Words224 Views
Running head: ASSIGNMENT 2
ME108 ENGINEERING ANALYSIS AND NUMERICAL METHODS
ASSIGNMENT 2
Name of the Student
Name of the University
Author Note

1Assignment 5
a.
Given, the equation is,
y(x) = a3x^3 + a2x^2 + a1x + a0
The coefficients are
a3 = 1, a2 = -2, a1 = -5, a0 = 6.
Hence, the equation is
y ( x )=x32 x25 x +6
Now, an analytical method used to find one root of the equation. The initial point is taken as
0.
y(0) = 6. Hence x is increased by 1.
y(1) = 1 – 2 -5 +6 = 0.
Hence, one of the root of the equation is x = 1.
Hence, in factored form the expression of y(x) will be
y(x) = (x-1)(x^2 –x -6)
Now, the remaining roots i.e. the roots of x2 x6 are calculated by Ruffini's rule.
MATLAB code:
a3 = 1; a2 = -2; a1 = -5; a0 = 6; % defining the coeffcient
f = @(x)(a3*x^3 + a2*x^2 +a1*x + a0);
x0 = 0;
while f(x0) ~= 0

2Assignment 5
x0 = x0 + 1;
end
answer_a1 = x0
sprintf('the analytical root is %d',answer_a1)
b1 = 1; b2 = -1; b3 = -6;
rufmat = [b1 b2 b3;0 0 0]; % the Ruffini's table
root2 = 1; % initial leftmost multiplier
rightmostval = (b1*root2 + b2)*root2 + b3; % calculation of right most value in Ruffini table
% Ruffini's method for finding the positive root
while rightmostval ~= 0
root2 = root2 + 1;
rightmostval = (b1*root2 + b2)*root2 + b3;
end
answer_a2 = root2
sprintf('the positive root by Ruffini method is %d',answer_a2)
% Ruffini's method for finding the negative root
root3 = -1; % initial leftmost multiplier

3Assignment 5
rightmostval = (b1*root3 + b2)*root3 + b3;
while rightmostval ~= 0
root3 = root3 - 1;
rightmostval = (b1*root3 + b2)*root3 + b3;
end
answer_a3 = root3
sprintf('the negative root by Ruffini method is %d',answer_a3)
Output:
answer_a1 =
1
ans =
'the analytical root is 1'
answer_a2 =
3
ans =
'the positive root by Ruffini method is 3'
answer_a3 =
-2

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
ANS.1.. x. LOAD y. BR. AR. ADDER. ADDER. ANS.2.. QUADRU
|3
|210
|300

Quadruple Two Into One Multiplier | Assignment
|3
|203
|259

Mixed Integer Programming
|7
|802
|465

Numerical Analysis: Interpolation and Approximation
|2
|692
|377

Linear Algebra Questions and Solutions
|10
|2154
|216

Linear System and Equations Assignment
|12
|2679
|24