Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use all the methods that we have learned to solve this problem: Find the root of

ID: 664818 • Letter: U

Question

Use all the methods that we have learned to solve this problem:

Find the root of

f(x) = 0.95x3-5.9 x2+10.9x-6

For the numerical methods, stop doing the iterations if either you have done 5 iterations or the error is below 0.05%.

Summarize your results in the tables provided below. Notice the initial values already given to you in the table for the brackets and starting points for the numerical methods.

Graphical method:

Plot of the function (copy and paste the figure here):

MATLAB code to plot the function (copy and paste the code here):

Estimate of the root:

Bisection:

Iteration

xl

f(xl)

xu

f(xu)

xr

f(xr)

f(xl)*f(xr)

|ea|

0

3

4

1

2

3

4

5

False Position:

Iteration

xl

f(xl)

xu

f(xu)

xr

f(xr)

f(xl)*f(xr)

|ea|

0

3

4

1

2

3

4

5

Simple fixed point Iteration:

Iteration

x0

xr

f(xl)

f(xr)

f(xl)*f(xr)

|ea|

0

3.5

1

2

3

4

5

Newton-Raphson:

Iteration

xi

f(xi)

f’(xi)

|ea|

0

3.5

1

2

3

4

5

Secant:

Iteration

xi-1

f(xi-1)

xi

f(xi)

|ea|

0

2.5

3.5

1

2

3

4

5

Solution using MATLAB “fzero”:

X=

Code to create solution in MATLAB (please copy and paste here the MATLAB code):

Iteration

xl

f(xl)

xu

f(xu)

xr

f(xr)

f(xl)*f(xr)

|ea|

0

3

4

1

2

3

4

5

Explanation / Answer


f = @(x) 0.95*x*x*x - 5.9*x*x + 10.9*x - 6;

eps_step = 1e-5;
eps_abs = 1e-5;
N = 5;
xi1 = 1.0;
xi = 1.1;

fprintf('%-12s%12s%12s%12s%12s%12s ', 'Iteration', 'x(i-1)', 'f(x(i-1))', 'x(i)', 'f(x(i)', '|e(a)|');

for i=1:N
  
    xn = (xi * f(xi1) - xi1 * f(xi)) / (f(xi1) - f(xi));

    if abs(xi - xn) < eps_step && abs(f(xn)) < 0.0005
       break;
    elseif i == N
       error('error');
    end

    fprintf('%-12d%12f%12f%12f%12f%12f ', i, xi1, f(xi1), xi, f(xi), xn);

    xi1 = xi;
    xi = xn;

end

xn

title('Plot of error')
plot(xn)
xlabel('Number of iterations')
ylabel('Error')
grid on;