Raíces de ecuaciones: Método de Steffensen, código C | Roots of equations: Steffensen's method, code C
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
#define F(x)(x*x)-4
#define FD(x)(2*x)
#define FP(x)(x*x)+x-4
#define FE(x,y)(x*y)+1
void main()
{
clrscr();
float x0,x1,a,fx1,fx2;
int i,j;
gotoxy(10,6); printf(" METODO DE STEFFENSEN ");
gotoxy(10,7);printf("------------------------------------------------------------");
gotoxy(10,8);printf(" Este codigo fue hecho por Jair Beltran USCO Garzon ");
gotoxy(10,9);printf("Se hallara la raiz de la funcion f(x)=x^2-4 tol=10^-5 iter max=9");
gotoxy(10,10);printf("Digite el primer valor: ");
scanf("%f",&x0);
gotoxy(10,11); printf("-----------------------------------------------");
gotoxy(10,12); printf("| No | x0 | f(x0) | x1 |");
gotoxy(10,13); printf("-----------------------------------------------");
i=14;
j=1;
while (fabs(F(x0))>0.00001 && (j<10))
{
a=x0+F(x0);
fx1=F(x0);
fx2=F(a);
x1=x0-((fx1*fx1)/(fx2-fx1));
gotoxy(10,i++);printf("%3d %12.5f %12.5f %12.5f ",i-14,x0,F(x0),x1);
x0=x1;
j=j+1;
}
gotoxy(10,23); printf("La raiz encontrada es igual a %10.5f",x0);
gotoxy(10,24); printf("Presione una tecla para volver al menu de ecuaciones de raices");
getch();
}
viernes, 20 de diciembre de 2013
Raíces de ecuaciones: Método de Steffensen, código C | Roots of equations: Steffensen's method, code C
Etiquetas:
Borland C,
code C,
método de Steffensen,
Métodos numéricos,
programación,
raíces de ecuaciones,
roots of equations,
Steffensen's method,
UNIVERSIDAD SURCOLOMBIANA,
yamil cerquera
Raíces de ecuaciones: Método de la falsa posición, código C | Roots of equations: False position method, code C
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
#define F(x)(x*x)-4
#define FD(x)(2*x)
#define FP(x)(x*x)+x-4
#define FE(x,y)(x*y)+1
void main()
{
clrscr();
float x0,x1,x2,f1,f2,f0;
int i,j;
clrscr();
do
{
gotoxy(10,6); printf(" METODO DE LA FALSA POSICION ");
gotoxy(10,7);printf("------------------------------------------------------------");
gotoxy(10,8);printf(" Este codigo fue hecho por Jair Beltran USCO Garzon ");
gotoxy(10,9);printf("Se hallara la raiz de la funcion f(x)=x^2-4 tol=10^-5 iter max=9");
gotoxy(10,10);printf("Digite el primer valor hasta cuando el programa le permita seguir: ");
scanf("%f",&x0);
}
while(F(x0)>0);
do
{
gotoxy(10,11); printf("Digite el segundo valor hasta cuando el programa le permita seguir: ");
scanf("%f",&x1);
}
while(F(x1)<0);
gotoxy(10,11); printf("----------------------------------------------------------------------");
gotoxy(10,12); printf("| No | x0 | f(x0) | x1 | f(x1) | x2 |");
gotoxy(10,13); printf("----------------------------------------------------------------------");
i=14;
j=1;
do
{
f0=F(x0);
f1=F(x1);
x2=x0-((f0*(x1-x0))/(f1-f0));
f2=F(x2);
gotoxy(10,i++);printf("%3d %12.6f %12.6f %12.6f %12.6f %12.6f",i-14,x0,f0,x1,f1,x2);
if(f0*f2<0)
{
x1=x2;
}
else
{
x0 = x2;
}
j=j+1;
}
while(fabs(f2)>0.00001 && (j<10));
{
gotoxy(10,23); printf("La raiz encontrada es igual a %10.5f",x2);
gotoxy(10,24); printf("Presione una tecla para continuar");
getch();
}
}
Etiquetas:
Borland C,
code C,
False position method,
método de Newton,
Métodos numéricos,
programación,
raíces de ecuaciones,
roots of equations,
UNIVERSIDAD SURCOLOMBIANA,
yamil cerquera
Raíces de ecuaciones: Método de Newton, código C | Roots of equations: Newton's method, code C
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
#define F(x)(x*x)-4
#define FD(x)(2*x)
#define FP(x)(x*x)+x-4
#define FE(x,y)(x*y)+1
void main()
{
clrscr();
int i,j;
float x0,x1,fx,fdx;
gotoxy(10,6); printf(" METODO DE NEWTON-RAPHSON ");
gotoxy(10,7);printf("------------------------------------------------------------");
gotoxy(10,8);printf(" Este codigo fue hecho por Jair Beltran USCO Garzon ");
gotoxy(10,9);printf("Se hallara la raiz de la funcion f(x)=x^2-4 tol=10^-5 iter max=9");
gotoxy(10,10);printf("Digite el primer valor diferente a cero: ");
scanf("%f",&x0);
gotoxy(10,11); printf("------------------------------------------------------------");
gotoxy(10,12); printf("| No | x0 | f(x0) | df(x0) | x1 |");
gotoxy(10,13); printf("------------------------------------------------------------");
i=14;
j=1;
do
{
fx=F(x0);
fdx=FD(x0);
x1=(x0-(fx/fdx));
gotoxy(10,i++);printf("%3d %12.5f %12.5f %12.5f %12.5f ",i-14,x0,F(x0),FD(x0),x1);
x0=x1;
j=j+1;
}
while (fabs(F(x0)>=0.00001) && (j<10));
{
gotoxy(10,23); printf("La raiz encontrada es igual a %10.5f",x0);
gotoxy(10,24); printf("Presione una tecla para volver al menu de ecuaciones de raices");
getch();
}
}
Etiquetas:
Borland C,
code C,
método de Newton,
Métodos numéricos,
Newtons method,
programación,
raíces de ecuaciones,
roots of equations,
UNIVERSIDAD SURCOLOMBIANA,
yamil cerquera
Integración numérica: trapecios, código C++ | Numerical integration: trapezoids, code C++
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
float fun (float x);
int main() {
float a,b,n,dx,suma,i,xi,c;
printf ("Este codigo fue hecho por Jair Beltran USCO Garzon");
printf ("Digite el punto inferior ");
scanf ("%f",&a);
printf ("Digite el punto superior ");
scanf ("%f",&b);
printf ("Digite el numero de sub-areas ");
scanf ("%f",&n);
dx=(b-a)/n;
suma=0;
i=1;
while (i<=n-1)
{
xi=a+i*dx;
suma=suma+fun(xi);
i=i+1;
}
c=(b-a)*((fun(a)+2*suma+fun(b))/(2*n));
printf ("El area es:%f \n",c);
return 0;
}
float fun(float x)
{float f;
f=x*x-4;
return f;
}
Etiquetas:
C++,
integracion numerica,
Métodos numéricos,
Numerical integration,
programación,
trapecios,
trapezoids,
UNIVERSIDAD SURCOLOMBIANA,
yamil cerquera,
zinjai
Raíces de ecuaciones: Método de Steffensen, código C++ | Roots of equations: Steffensen's method, code C++
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
float fun (float x);
int main() {
float error=0.0005,x0,x1;
printf ("Este codigo fue hecho por Jair Beltran USCO Garzon");
printf ("Digite el primer valor ");
scanf ("%f",&x0);
while (fabs (fun(x0))>error)
{x1=x0-((fun(x0)*fun(x0))/(fun(x0+fun(x0))-fun(x0)));
printf ("%f \n",x1);
x0=x1;
}
x0=x1;
printf ("la raiz es:%f \n",x1);
return 0;
}
float fun(float x)
{float f;
f=x*x-4;
return f;
}
Etiquetas:
C++,
método de Steffensen,
Métodos numéricos,
programación,
raíces de ecuaciones,
roots of equations,
Steffensen's method,
UNIVERSIDAD SURCOLOMBIANA,
yamil cerquera,
zinjai
Raíces de ecuaciones: Método de la secante, código C++ | Roots of equations: Secant's method, code C++
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
float fun (float x);
int main() {
float error=0.00001,x0,x1,x2,Ea;
printf ("Este codigo fue hecho por Jair Beltran USCO Garzon");
printf ("Digite el primer valor ");
scanf ("%f",&x0);
printf ("Digite el segundo valor ");
scanf ("%f",&x1);
Ea=error+1;
while (Ea>error)
{x2=(x1-((x0-x1)/(fun(x0)-fun(x1))*fun(x1)));
printf ("%f \n",x2);
Ea=(fabs (x1-x2));
x0=x1;
x1=x2;
}
printf ("la raiz es:%f \n",x2);
return 0;
}
float fun(float x)
{float f;
f=x*x-4;
return f;
}
Etiquetas:
C++,
método de la Secante,
Métodos numéricos,
programación,
raíces de ecuaciones,
roots of equations,
Secant's method,
UNIVERSIDAD SURCOLOMBIANA,
yamil cerquera,
zinjai
Integración numérica: rectángulos, código C++ | Numerical integration: rectangles, code C++
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
float fun (float x);
int main() {
float s,a,b,n,dx,i,xi,AT;
printf ("Este codigo fue hecho por Jair Beltran USCO Garzon");
printf ("Digite el punto inferior ");
scanf ("%f",&a);
printf ("Digite el punto superior ");
scanf ("%f",&b);
printf ("Digite el numero de sub-areas ");
scanf ("%f",&n);
dx=(b-a)/n;
s=0;
i=1;
while (i<=n)
{
xi=a+(2*i-1)*(dx/2);
s=s+fun(xi);
i=i+1;
}
AT=dx*s;
printf ("El area es:%f \n",AT);
return 0;
}
float fun(float x)
{float f;
f=(x*x)-4;
return f;
}
Etiquetas:
C++,
integracion numerica,
Métodos numéricos,
Numerical analysis,
Numerical integration,
programación,
rectangles,
rectangulos,
UNIVERSIDAD SURCOLOMBIANA,
yamil cerquera,
zinjai
Suscribirse a:
Entradas (Atom)