Docsity

metodos numericos interpolacion, Diapositivas de Métodos Numéricos

Vista previa parcial del texto

¡Descarga metodos numericos interpolacion y más Diapositivas en PDF de Métodos Numéricos solo en Docsity!

Análisis Numérico

Semana 4:

Aproximación polinomial e

interpolación

Ing. Aquiles Aquino Rivera

Introducción:

Se trata de obtener un polinomio ( polinomio de interpolación ) que cumpla: f(x ) ≈ p(x). en una serie de n puntos x 0 , x 1 , …, xn.

Interpolación de Lagrange:

Propiedad de los coeficientes Lk(x) :

El coeficiente Lk(x) se anula en cada punto x i, excepto en el x k que tiene el valor 1 (valor máximo).

Ejemplo: Se tiene seis puntos, x 0 = 1, x 1 = 3, x 2 = 4, x 3 = 6, x 4 = 8, x 5 = 9.

3 ( ) (^ 1)^ (^ 3)^ (^ 4)^ (^ 8)^ (^ 9) (6 1) (6 3) (6 4) (6 8) (6 9) L x =^ x^ −^ ^ x^ −^ ^ x^ −^ ^ x^ −^ ^ x − −  −  −  −  −

EJEMPLO: Sea la función f(x)= e x. Donde se tiene conocido el valor que toma esta función en los cuatro puntos: x 0 =2, x 1 =2.5, x 2 =3, x 3 =4 , es decir: f(x 0 ) = 7.3890, f(x 1 ) = 12.1825, f(x 2 ) = 20.0855, f(x 3 ) = 54.

Calculo del polinomio de interpolación de Lagrange:

0 3 2

1 3 2

2 3 2

3

( ) (^ 2.5) (^ 3) (^ 4) 9.5 29.5 30 (2 2.5) (2 3) (2 4) ( ) (^ 2) (^ 3) (^ 4) 2.66667 24 69.3333 64 (2.5 2) (2.5 3) (2.5 4) ( ) (^ 2) (^ 2.5) (^ 4) 2 17 46 40 (3 2) (3 2.5) (3 4) ( ) (^ 2) (^2

L x x^ x^ x x x x

L x x^ x^ x x x x

L x x^ x^ x x x x

L x x^ x

= −^ −^ − = − + − + − − − = −^ −^ − = − + − − − − = −^ −^ − = − + − + − − − = −^ − .5) (^ 3)^ 0.3333 3 3.5 2 6.16667 5 (4 2) (4 2.5) (4 3)

x − (^) = x − x + x − − − −

Polinomio de interpolación de Newton.

La fórmula de interpolación de Newton viene dada por:

( )

1 0 1 0 0

( ) , ,...,

n i i j i j

p x f x x x x x

− = =

= (^)   −

Siendo las llamadas diferencias divididas de f para los x 0 , x 1 , …, xn.

f x (^) 0 , x 1 , ..., xi

0 0 0 1 1 1 0 1 2 1 2 0 1 2 3 2 2 1 2 3 2 3 3 3

( ) , ( ) , , , , , , ( ) , , , ( )

x f x f x x x f x f x x x f x x f x x x x x f x f x x x f x x x f x En el caso de 4 puntos

Algunos ejemplos:^0 0 1 1 1 0 1 2 1 2 0 1 2 3 2 2 1 2 3 2 3 3 3

( ) , ( ) , , , , , , ( ) , , , ( )

x f x f x x x f x f x x x f x x f x x x x x f x f x x x f x x x f x

1 2 3 2 3 1 2 3 1

f x , x , x f^ x^^ ,^ x^ f^ x^ , x x x

0 1 2 3 1 2 3 0 1 2 3 0

f x , x , x , x f^ x^^ ,^ x^ ,^ x^ f^ x^ ,^ x^ , x x x = − −

Ejemplo: Para obtener el polinomio de interpolación para la función f(x) = e x , en los puntos {2, 2.5, 3, 4},

por el método de Newton. 0

1

2

3

2.0 7.

2.5 12.1825 6. 15.806 3. 3.0 20.0855 12.

4.0 54.

x

x

x

x

=

=

=

=

p ( x ) = 7.38906 + 9.58688 ( x – 2) + 6.21912 ( x – 2) ( x – 2.5) +

  • 3.1260 ( x – 2) ( x – 2.5) ( x – 3)

p ( x ) = 3.126 x^3 – 17.2259 x^2 + 39.4318 x – 27.

Matemáticamente equivale a un problema de hallar un mínimo para una función de m+1 variables: f ( a, b, …, c )

EJEMPLO: Aplique el método para el caso de un polinomio de grado 2 (función polinómica), es decir, mediante una parábola: y = ax^2 + bx+ c

Al observar la figura anterior, se tiene:

e i = axi^2 + bxi+ c – y i → e i^2 = ( axi^2 + bxi+ c – y i )^2.

Por tanto la suma de los cuadrados de los errores es:

( ) 2 2 2 1 1

( , , )

n n i i i i i i

e ax bx c y f a b c = =

 =^  +^ +^ −^ =

Se trata de minimizar esta función de tres variables, f(a, b, c).

Las condiciones de extremo se dan allí donde se anulan las derivadas primeras de f (x):

( )

( )

( )

2 2 1 2 1 2 1

' 2. 0

' 2. 0

' 2 .1 0

n a (^) i i i i i n b (^) i i i i i n c (^) i i i i

f ax bx c y x

f ax bx c y x

f ax bx c y

=

=

=

= + + − =

= + + − =

= + + − =

( )

( )

( )

2 2 1 2 1 2 1

. 0 . 0

.1 0

n i i i i i n i i i i i n i i i i

ax bx c y x

ax bx c y x

ax bx c y

=

=

=

    • − =
    • − =
    • − =

Condiciones:

Interpolación de datos 1-D con MATLAB.

>> yi = interp1(x, y, xi, método ); >> plot(x, y, 'o', xi, yi);

Sean conocidos una tabla de datos: x = [1, 1.2, 1.3, 1.5, …] y = [4.254, 3.097, 5.671, …]

Métodos.

  • ‘nearest’
  • ‘linear’ (por defecto)
  • ‘spline’ Cubic spline interpola.
  • ‘cubic’

Ejemplo 1:

>> x = 0:10; >> y = exp(x); >> xi = 0:0.2:10; >> yi = interp1(x, y, xi); >> plot(x, y, 'o‘ , xi, yi);