Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
EnglishTI_MZ_CAPR(1ea429)2010.doc
Скачиваний:
20
Добавлен:
28.04.2019
Размер:
2.77 Mб
Скачать

Figire 2.2 - Dependence of the number of iterations on the accuracy of methods for the bisection (upper line) and the Newton method (bottom line)

Example 2.3. Sensitivity of Newton's method to the choice of initial approximation.

1. Function in listing 2.5.

Listing 2.5. File f24.m

function y=f24(x)

y=(x-1.3)./((x-1.3).^2+1);

2. Derivative in listing 2.6.

Listing 2.6. File f241.m

function y=f241(x)

y=(1-(x-1.3).^2)./((x-1.3).^2+1).^2;

3. Script (listing 2.6) to run Newton method with different accuracy.

Listing 2.7. test.m

[root1, iter1] = newton('f24','f241', 1.87,1e-8);

% Check roots

y=f24(root1)

[root2, iter2] = newton('f24','f241', 1.88,1e-8);

y1=f24(root2)

% Compare the number of iterations

iter1

iter2

4. The results of the functions in the command window.

>> test1

y = 0

y1 =4.1016e-030

iter1 = 7

iter2 = 100

We see that the number of iterations in the first case is much smaller than in the second.

2.3.2 The method of simple iteration

To use this method, the original nonlinear equation f(x) = 0 can be written as

x = φ(x).

Let them know the root of the initial approximation x = x0. Substituting this value in the right side of the equation we obtain a new approximation:

x1 = φ(x0).

Repeat this procedure with x1 and obtain x2 = φ(x1). Repeating this procedure, we obtain a sequence

x0, x1, … , xn, … ,

called the iterative sequence.

Iterative sequence can be both convergent and divergent, as determined by the type of function f(x).

A sufficient condition for the convergence of the iterative process

Suppose that the equation x = φ(x) has a unique root on the interval [a, b] and the following conditions:

  1. φ(x) is defined and differentiable on [a, b].

  2. φ(x) € [a,b] for all x € [a, b].

  3. There exists a real number q, that | φ'(x)|≤q<1 for all x € [a, b].

Then the iterative sequence xn = φ(x n-1) (n= 1, 2, …) converges for any initial approximation x0 € [a, b].

Example 2.4. Find the root of the equation

x4 - 11x3 + x2 +x +0.1 = 0

for k iteration using the method of simple iteration.

  1. Let Iter.m file(function Iter) contains a simple iteration method and calculates the accuracy achieved by k iterations. Format function Iter:

[root,accuracy]=Iter(fun_fi,fun_derivative_fi,a,b,count_itarations)

  1. Define function f(x)= x4 - 11x3 + x2 +x +0.1,

function fi(x)= -x4 + 11x3 - x2 -0.1,

and first derivative fi1(x)= -4x3 + 33x2 - 2x,

using the inline command:

>>f=inline(‘x.^4-11*x.^3+x.^2+x+0.1’);

>>fi=inline(‘-x.^4+11*x.^3-x.^2-0.1’);

>>fi1=inline(‘-4*x.^3+33*x.^2-2*x’);

  1. To separate the roots graph of the function by executing the following sequence of operators:

>>x1=-1;

>>x2=1;

>>dx=10^-3;

>>x=x1:dx:x2;

>>plot(x,f(x)); grid on

  1. Select interval localization – [-1,1] and calculate the value of the root of the equation on this interval and accuracy ε for k=6 iterations:

>>k=6;[root,eps]=Iter(fi,fi1,-1,1,k)

    1. Individual tasks

Variants of the tasks are presented in the Appendix A column2(p.77).

  1. Found a roots of the given equations if accuracy is less than  = 10-4. Use:

a) Newton method;

b) Iterative method.

  1. Locate one of the roots with several relative errors. Compare the amount of calculations using these methods for different errors.

  2. Along with the "manual" solution provide solutions obtained by standard means of MatLab (functions fzero and root).

2.5 Control questions

  1. Stages of the decision of the nonlinear equations.

  2. Newton method. Illustrate on the graph. Merits and demerits of a method.

  3. The method of simple itaration. Illustrate on the graph. Merits and demerits of a method.

  4. Input and output arguments of the functions roots and fzero.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]