elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


  Mostrar Temas
Páginas: [1]
1  Programación / Programación C/C++ / Ayuda a completar el Codigo de Minimos cuadrados en: 22 Abril 2012, 19:21 pm
http://www.monografias.com/trabajos16/metodos-lineales/metodos-lineales.shtml

Cual seria el siguiente paso a Programar?

http://www.monografias.com/trabajos16/metodos-lineales/metodos-lineales.shtml
Algun tip para salir de este estanqueamiento de las ecuaciones para encontrar a y b

Citar
#include<stdio.h>
#include<math.h>
#include<conio.h>
float Ecuacion(float temp,float temp1,float temp2,float temp3,float N);
float Sustitucion(float temp,float temp1,float b,float N);

int main()

{
float Matriz[50][51]={0},X[50],Y[50],tm=0,temp=0,temp1=0,temp2=0,temp3=0,N,a,b;
int i,j,k,l,x,y,w,n,o=0,p=0;
printf("Metodo de Minimos Cuadrados\n\n");
printf("Ingrese el Numero de iteraciones");
scanf("%d",&n);
N=n;
for(x=0;x<n;x++)
{
    o=o+1;
    printf("Ingrese datos: X(%d)",o);
    scanf("%f",&X
  • );
}
for(y=0;y<n;y++)
{
    p=p+1;
    printf("Ingrese datos: Y(%d)",p);
    scanf("%f",&Y[y]);
}

system("cls");
printf("Sus Datos son:\n\n\tXi\tYi\tXiYi\tXi2\n");
for(w=0;w<n;w++)
{
    tm=X[w];
    tm=pow(tm,2);
    Matriz[w][1]=tm;
    Matriz[w][0]=X[w]*Y[w];
    printf("\n\t%.2f \t%.2f \t%.2f \t%.2f\n",X[w],Y[w],Matriz[w][0],Matriz[w][1]);

}

printf("\n\t+Xi\t+Yi\t+XiYi\t+Xi2\n");

for(i=0;i<n;i++)
{
    temp=temp+X;
}
for(j=0;j<n;j++)
{
    temp1=temp1+Y[j];
}
for(k=0;k<n;k++)
{
    temp2=temp2+Matriz[k][0];
}
for(l=0;l<n;l++)
{
    temp3=temp3+Matriz[l][1];
}
printf("\n\t%.2f\t%.2f\t%.2f\t%.2f\n\n",temp,temp1,temp2,temp3);
printf("Ec.1 ∑y=na+b∑x\nEc.2 ∑xy=a∑x+b∑x²\n\n");
printf("b=%.5f\n",Ecuacion(temp,temp1,temp2,temp3,N));
b=Ecuacion(temp,temp1,temp2,temp3,N);
printf("a=%.5f",Sustitucion(temp,temp1,b,N));
}


float Ecuacion(float temp,float temp1,float temp2,float temp3,float N)
{
    float a,b,c,d,e,f,g;

    a=(temp)*(-temp);
    b=(temp1)*(-temp);
    c=(temp3)*(N);
    d=(temp2)*(N);
    e=b+d;
    f=a+c;
    g=e/f;

    return g;
}
float Sustitucion(float temp,float temp1,float b,float N)
{
    float a;

    a=((b*temp)-temp1)/N;

    return a;
}

Hay vamos hay vamos!!! jaja disculpen si me la paso modificando el codigo pero creo que voy progresando Espero sus recomendaciones saludos y Buena vibra!
2  Programación / Programación C/C++ / Programacion del polinomio de Newton Ayuda!! en: 4 Abril 2012, 07:51 am
Que tal Esta es mi primera Publicacion asi que un saludo a tod@s Por aqui..

Veran en la escuela me pidieron programar en la clase de metodos numericos, El metodo de polinomio de newton. y ya tengo una semana itentandolo y nomas no doy
Aun no puedo lograr obtener mi tabla Bien

Y despues de la tabla faltan los resultados para las incognitas pff... quien podria ayudarme echandole un vistazo a lo que llevo Saludos

Datos a ingresar
Para iteraciones=5
X(x)=0,1,2,3,4
F(x,0)=-1,-1,1,5,11

La tabla deberia de salir mas omenos asi

0   -1   0   1   0   0
1   -1   2   1   0  
2    1   4   1
3    5   6
4   11
http://s3.subirimagenes.com:81/otros/previo/thump_7595768nuevo1.jpg
Adjunto una imagen con la formula y la tabla mas detallada
http://s2.subirimagenes.com/imagen/previo/thump_7595718sin-ttul2o.png
Tampoco eh solucionado como aparecer la primera Columna ya que esa la ingrese como un arreglo unidimencional(vector) y lo demas si es matriz nxn

Por cierto Uso CODE BLOCKS 10.05


#include<stdio.h>
#include <conio.h>

int main()
{

int o=-1,n,i,j,k=-1;
printf("Ingrese el numero de iteraciones");
scanf("%d",&n);
printf("\n\nIngrese los valores de Xi & F(xi)\n\n");
float Tabla[n][n],Xi[n];
int l=n,m=n;

for(i=0;i<n;i++)
   {
    o=o+1;
    printf("Ingrese datos: X(%d)",o);
    scanf("%f",&Xi);
   }
for(j=0;j<n;j++)
   {
    k=k+1;
    printf("Ingrese datos:F(%d,0)",k);
    scanf("%f",&Tabla[j][0]);
   }
for(i=1;i<=n-1;i++)
   {
    for(j=0;j<m;j++)
        {
         Tabla[j]=((Tabla[i+1][j-1])-(Tabla[j-1]))/((Xi[i+j])-(Xi));
        }
     m=((m)-(1));
   }
for(i=0;i<n;i++)
    {
     for(j=0;j<=l;j++)
         {
          printf("%.2f\t",Tabla[j]);
         }
     printf("\n");
     l=((l)-(1));
    }
return 0;
}
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines