Powered By Blogger

martes, 11 de diciembre de 2012

"INTERPOLACION DE N-ESIMO ORDEN DE NEWTON"


//Torres Martinez Gustavo Alan
//Grupo:4CM1
//Programa que realiza diferencias divididas para determinar el valor de
//de una funcion conocida en base al valor de la funcion evaluada en puntos
//equidistantes por medio de "INTERPOLACION DE N-ESIMO ORDEN DE NEWTON"

#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
#include<stdlib.h>
#include<iostream.h>

void main(void)
{
double fx,fx0,fx1,fx2,fx3,fx10,fx21,fx32,fx210,fx321,fx3210,f3x,b0,b1,b2,b3,x,x0,x1,x2,x3,erv;
clrscr();
x=2;
x0=1;
x1=3;
x2=4;
x3=5;
fx=log(x);
fx0=log(x0);
fx1=log(x1);
fx2=log(x2);
fx3=log(x3);
cout<<"Calculando el ln(2) por medio del polinomio de interpolacion de n-Çsimo"<<endl<<"oden de Newton con x=1,3,4,5."<<endl<<endl;
b0=fx0;
b1=(fx1-fx0)/(x1-x0);  fx10=b1;
b2=(fx2-fx1)/(x2-x1);  fx21=b2;
b3=(fx3-fx2)/(x3-x2);     fx32=b3;
b2=(fx21-fx10)/(x2-x0);   fx210=b2;
b2=(fx32-fx21)/(x3-x1);   fx321=b2;
b3=(fx321-fx210)/(x3-x0); fx3210=b3;
f3x=b0+fx10*(x-x0)+fx210*(x-x0)*(x-x1)+fx3210*(x-x0)*(x-x1)*(x-x2);
erv=(fx-f3x)/fx*100;
printf("bo=%1.8f  b1=%1.8f  b2=%1.8f   b3=%1.8f\n\n",b0,b1,fx210,fx3210);
printf("f3(x)=%1.8f Erv=%2.2f%",f3x,fabs(erv));
cout<<endl<<endl;
textcolor(10+128);
cprintf("             Presiona cualquier tecla....");
getch();
}

No hay comentarios:

Publicar un comentario