Está en la página 1de 6

Universidad Nacional Autónoma de México

Facultad de Estudios Superiores Cuautitlán. Campus #1


Métodos numéricos Grupo: 1351 Carrera: Ingeniería Química
Integrantes: Hernández Jiménez Aidee Yudith, Luna González Ricardo, Morales Calva José Benjamín,
Nápoles Reyes Gerardo, Rueda Tlapala Estefani Ariadna, Vázquez Sánchez José Antonio, Zamora Flores
Diana Alejandra

Caso de estudio: Método de interpolación


“Spline”
Para el conjunto de datos mostrado, determine las piezas de polinomios que
corresponden a cada uno de los segmentos dados.
x 2 3 4 5 6 7
y = f(x) 5 23 59 119 209 335
Con condiciones finales o de frontera:

➢ y´´(2) = 0(M0 )
➢ y´´(7) = 0(M5 )

o Intervalos considerados: [2,3] [3,4] [4,5] [5,6] [6,7]


o Intervalo completo: [2,7]
o Los espaciamientos establecidos son: h1 = h2 = h3 = h4 = h5 = 1.0
o Se aplica la ecuación (15):
yi+1 − yi yi − yi−1
6[ − ] = hi Mi-1 + 2(hi + hi+1 )Mi + hi+1 Mi+1
hi+1 h1
o Obteniendo:
y2 − y1 y1 − y0
6[− ] = h1 M0 + 2(h1 + h2 )M1 + h2 M2
h2 h1
y3 − y2 y2 − y1
6[ − ] = h2 M1 + 2(h2 + h3 )M2 + h3 M3
h3 h2
y4 − y3 y3 − y2
6[ − ] = h3 M2 + 2(h3 + h4 )M3 + h4 M4
h4 h3
y5 − y4 y4 − y3
6[ − ] = h4 M3 + 2(h4 + h5 )M4 + h5 M5
h5 h4
o Sustituyendo los valores de las h, las ecuaciones se reducen a:

6[(y2 − y1 ) − (y1 − y0 )] = M0 + 4M1 + M2

6[(y3 − y2 ) − (y2 − y1 )] = M1 + 4M2 + M3

6[(y4 − y3 ) − (y3 − y2 )] = M2 + 4M3 + M4

6[(y5 − y4 ) − (y4 − y3 )] = M3 + 4M4 + M5

o Sustituyendo los valos de las ordenadas “y”, estas ecuaciones se reducen a:


6[(59 − 23) − (23 − 5)] = M0 + 4M1 + M2
6[(119 − 59) − (59 − 23)] = M1 + 4M2 + M3

Fecha de entrega: 10/11/2020


Universidad Nacional Autónoma de México
Facultad de Estudios Superiores Cuautitlán. Campus #1
Métodos numéricos Grupo: 1351 Carrera: Ingeniería Química
Integrantes: Hernández Jiménez Aidee Yudith, Luna González Ricardo, Morales Calva José Benjamín,
Nápoles Reyes Gerardo, Rueda Tlapala Estefani Ariadna, Vázquez Sánchez José Antonio, Zamora Flores
Diana Alejandra
6[(209 − 119) − (119 − 59)] = M2 + 4M3 + M4
6[(335 − 209) − (209 − 119)] = M3 + 4M4 + M5
o Al considerar las condiciones iniciales:
y´´(2) = 0(M0 )
y´´(7) = 0(M5 )
o Finalmente se llega al sistema de ecuaciones:

4M1 + M2 = 108

M1 + 4M2 + M3 = 144

M2 + 4M3 + M4 = 180

4M4 + M3 = 216

o Al resolver se obtienen los siguientes valores:

M1 = 21.0143

M2 = 23.9425

M3 = 27.2153

M4 = 47.1961

o Con los valores de las “M” se podrá determinar cada uno de los valores para
los coeficientes de las piezas de polinomios, esto es:
Mi+1 − Mi Mi yi+1 − yi 2hi+1 Mi + hi+1 Mi+1
ai = ; bi = ; ci = − ; di = y1
6hi+1 2 hi+1 6

• Cuando i = 1
M2 − M1
a1 = = 0.48
6h2
M1
b1 = = 10.5
2
y2 − y1 2h2 M1 + h2 M2
c1 = − = 25.004
h2 6

d1 = y1 = 23

Fecha de entrega: 10/11/2020


Universidad Nacional Autónoma de México
Facultad de Estudios Superiores Cuautitlán. Campus #1
Métodos numéricos Grupo: 1351 Carrera: Ingeniería Química
Integrantes: Hernández Jiménez Aidee Yudith, Luna González Ricardo, Morales Calva José Benjamín,
Nápoles Reyes Gerardo, Rueda Tlapala Estefani Ariadna, Vázquez Sánchez José Antonio, Zamora Flores
Diana Alejandra
• Cuando i = 2
M 3 − M2
a2 = = 0.5454
6h3
M2
b2 = = 11.97
2
y3 − y2 2h3 M2 + h3 M3
c2 = − = 47.483
h3 6

d2 = y2 = 59

• Cuando i = 3
M 4 − M3
a3 = = 3.3301
6h4
M3
b3 = = 13.6076
2
y4 − y3 2h4 M3 + h4 M4
c3 = − = 73.0622
h4 6

d3 = y3 = 119

• Cuando i = 4
M 5 − M4
a4 = = −7.8610
6h5
M4
b4 = = 23.583
2
y5 − y4 2h5 M4 + h5 M5
c4 = − = 110.277
h5 6

d4 = y4 = 209

• Ordenados quedan:
d0 = 5 ; c0 = 14.5 ; b0 = 0 ; a0 = 3.50
d1 = 23 ; c1 = 24 ; b1 = 10.51 ; a1 = 0.49
d2 = 59 ; c2 = 47.48 ; b2 = 11.97 ; a0 = 0.55
d3 = 119 ; c3 = 73.06 ; b3 = 13.61 ; a3 = 3.33
d4 = 209 ; c4 = 110.27 ; b0 = 23.60 ; a4 = −7.87

Fecha de entrega: 10/11/2020


Universidad Nacional Autónoma de México
Facultad de Estudios Superiores Cuautitlán. Campus #1
Métodos numéricos Grupo: 1351 Carrera: Ingeniería Química
Integrantes: Hernández Jiménez Aidee Yudith, Luna González Ricardo, Morales Calva José Benjamín,
Nápoles Reyes Gerardo, Rueda Tlapala Estefani Ariadna, Vázquez Sánchez José Antonio, Zamora Flores
Diana Alejandra
o Luego al utilizar estos resultados de los coeficientes para cada polinomio; y al
considerar el modelo del polinomio:
(5). . . y(x) = ai (x − xi )3 + bi (x − xi )2 + ci (x − xi ) + di en [xi − xi+1 ]

P2 (x) = 0.55(x − 4)3 + 11.97(x − 4)2 + 47.48(x − 4) + 59 en [4,5]

Código en lenguaje c++

#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <locale.h>
using namespace std;
int main()
{
setlocale(LC_ALL, "");
/** Step 0 */
int n, i, j;
cout<<" SPLINE CUBICO"<<endl;
cout <<" Calcula el polinomio cubico de un conjunto de puntos" << endl;
cout << "\nIngrese el numero de puntos: ";
cin >> n;
n--;
float x[n + 1], a[n + 1], h[n], A[n], l[n + 1],
u[n + 1], z[n + 1], c[n + 1], b[n], d[n];
for (i = 0; i < n + 1; ++i) scanf("%f", &x[i]);
for (i = 0; i < n + 1; ++i) scanf("%f", &a[i]);

/** Step 1 */
for (i = 0; i <= n - 1; ++i) h[i] = x[i + 1] - x[i];

/** Step 2 */
for (i = 1; i <= n - 1; ++i)
A[i] = 3 * (a[i + 1] - a[i]) / h[i] - 3 * (a[i] - a[i - 1]) / h[i - 1];

Fecha de entrega: 10/11/2020


Universidad Nacional Autónoma de México
Facultad de Estudios Superiores Cuautitlán. Campus #1
Métodos numéricos Grupo: 1351 Carrera: Ingeniería Química
Integrantes: Hernández Jiménez Aidee Yudith, Luna González Ricardo, Morales Calva José Benjamín,
Nápoles Reyes Gerardo, Rueda Tlapala Estefani Ariadna, Vázquez Sánchez José Antonio, Zamora Flores
Diana Alejandra

/** Step 3 */
l[0] = 1;
u[0] = 0;
z[0] = 0;

/** Step 4 */
for (i = 1; i <= n - 1; ++i) {
l[i] = 2 * (x[i + 1] - x[i - 1]) - h[i - 1] * u[i - 1];
u[i] = h[i] / l[i];
z[i] = (A[i] - h[i - 1] * z[i - 1]) / l[i];
}
/** Step 5 */
l[n] = 1;
z[n] = 0;
c[n] = 0;

/** Step 6 */
for (j = n - 1; j >= 0; --j) {
c[j] = z[j] - u[j] * c[j + 1];
b[j] = (a[j + 1] - a[j]) / h[j] - h[j] * (c[j + 1] + 2 * c[j]) / 3;
d[j] = (c[j + 1] - c[j]) / (3 * h[j]);
}
/** Step 7 */
cout<<"\nLos valores de los coeficientes para los polinomios son: "<< endl;
cout<<"\n";
printf("%2s %8s %8s %8s %8s\n", "i", "di", "ci", "bi", "ai");
for (i = 0; i < n; ++i)
printf("%2d %8.2f %8.2f %8.2f %8.2f\n", i, a[i], b[i], c[i], d[i]);
return 0;
cout<<"\n\n\n";
system("pause");
}

Fecha de entrega: 10/11/2020


Universidad Nacional Autónoma de México
Facultad de Estudios Superiores Cuautitlán. Campus #1
Métodos numéricos Grupo: 1351 Carrera: Ingeniería Química
Integrantes: Hernández Jiménez Aidee Yudith, Luna González Ricardo, Morales Calva José Benjamín,
Nápoles Reyes Gerardo, Rueda Tlapala Estefani Ariadna, Vázquez Sánchez José Antonio, Zamora Flores
Diana Alejandra

Prueba de escritorio

Fecha de entrega: 10/11/2020

También podría gustarte