0% found this document useful (0 votes)
24 views

Tp4: Roots of Equation: 1. Find The Roots of The Equation Below by Graphical Method F (X) X - 4x + 1 Code

1. The roots of the equation x3 - 4x + 1 were found graphically to be -2.1, 0.1, and 1.7. 2. Using the bisection method, the root of the equation x3 - 4x + 1 was found to be -3. 3. Given initial values of -3 and 0, the bisection method found the root of x3 - 4x + 1 to be -2.114092. 4. Given initial values of 1 and 20, the bisection method found the drag coefficient C needed to reach a velocity of 40 m/s in 10 seconds with a mass of 68.1kg to be 16.654

Uploaded by

Borith pang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Tp4: Roots of Equation: 1. Find The Roots of The Equation Below by Graphical Method F (X) X - 4x + 1 Code

1. The roots of the equation x3 - 4x + 1 were found graphically to be -2.1, 0.1, and 1.7. 2. Using the bisection method, the root of the equation x3 - 4x + 1 was found to be -3. 3. Given initial values of -3 and 0, the bisection method found the root of x3 - 4x + 1 to be -2.114092. 4. Given initial values of 1 and 20, the bisection method found the drag coefficient C needed to reach a velocity of 40 m/s in 10 seconds with a mass of 68.1kg to be 16.654

Uploaded by

Borith pang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

TP4 : ROOTS OF EQUATION

1. Find the roots of the equation below by graphical method


F(x) = x3 - 4x + 1
Code
x=-5:0.1:5
y=x.^3-4*x+1
plot(x,y)
grid on ; hold on
plot(x,zeros(size(x)),'m')

Figure

From the figure the roots of equation are X1 = -2.1 ; X2 = 0.1 ; X3 = 1.7

2. Find the roots of the equation below by bisection method


F(x) = x3 - 4x + 1
Code
f=@(x) x.^3-4.*x+1
x1=-4
x2=0
xr=(x1+x2)/2
while f(xr)>0.001
if f(x1)*f(xr)<0
x2=xr
else x1=xr
end
xr=(x1+x2)/2
end
fprintf('the root of equation is :%f',xr)

The root of equation is : -3.000000

3. Find the roots of the equation below by bisection method


F(x) = x3 - 4x + 1
Code
f=@(x) x.^3-4.*x+1
x1=input('value x1:')
x2=input('value x2:')
if f(x1)*f(x2)>0
fprintf('no roots')
return
end
if f(x1)==0
fprintf('x1 is one of the roots')
return
elseif f(x2)==0
fprintf('x2 is one of the roots')
return
end
for i=0:100
xr=[x2*f(x1)-x1*f(x2)]./(f(x1)-f(x2))
if f(x1)*f(x2)<0
x2=xr
else x1=xr
end
if abs (f(xr))<0.01
break
end
end
fprintf ('the root is :%f',xr)
Suppose X1 = -3 ; X2 = 0

So The root of this equation is -2.114092

𝐦𝐦𝐦𝐦
4. The parachute velocity is V = 𝐜𝐜 (1-e-ct/m) . what is the drag coefficient of
“ C ” needed to reach velocity of 40 m/s if m=68.1 kg; t=10s ;g=9.8m/s2.

Code
f=@(x)40-(((68.1)*(9.8))./x)+exp(-10*x./68.1)
x1=input('value x1:')
x2=input('value x2:')
if f(x1)*f(x2)>0
fprintf('no roots')
return
end
if f(x1)==0
fprintf('x1 is one of the roots')
return
elseif f(x2)==0
fprintf('x2 is one of the roots')
return
end
for i=0:100
xr=[x2*f(x1)-x1*f(x2)]./(f(x1)-f(x2))
if f(x1)*f(x2)<0
x2=xr
else x1=xr
end
if abs (f(xr))<0.01
break
end
end
fprintf ('the root is :%f',xr)

Suppose X1 = 1 ; X2 = 20

So The root of this equation is 16.654990

You might also like