Programa

Páginas: 5 (1020 palabras) Publicado: 11 de marzo de 2013
FUNCION ALGEBRAICA 2*X^2-X+5

| |
| |
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
|
| |
f(x) | g(x) | x1 | xi+1 | E |
8.62981 | 1.62019 | 0.25 | 1.62019 | -1.370919 |
9.80082 | 1.81937 | 1.62019 | 1.81937 | -0.199181 |
10 | 1.84653 | 1.81937 | 1.84653 | -0.027166 |
10.0272 |1.85021 | 1.84653 | 1.85021 | -0.003674 |
| |
| |
| |
| |
| |
| |
| |
CODIGO FUENTE
include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<dos.h>
#include<conio.h>
#include<windows.h>
#include<amp_graphics.h>
//#define DETECT
using namespace std;

int main()
{

float a,f,g,v,h,l,p,r,k,u=0.25;cout<<"La siguiente funcion algebraica es la que se va calcular:f(x)= 2*x^2-x-5\n"<<endl;
cout<<"g(x)=x^2=(x+5)/2\n";//<<"Introduce el valor de x :\n\n"<<endl;cin>>a;
g=sqrt((u+5)/2);
f=2*(g*g)-g+5;
v=sqrt((g+5)/2);
h=2*(v*v)-v+5;
l=sqrt((v+5)/2);
p=2*(l*l)-v+5;
r=sqrt((l+5)/2);
k=2*(r*r)-v+5;cout<<"f(x)"<<setw(9)<<"g(x)"<<setw(13)<<"x1"<<setw(19)<<"xi+1\n"<<endl;
cout<<f<<setw(9)<<g<<setw(10)<<u<<setw(22)<<g<<"\n"
<<h<<setw(9)<<v<<setw(13)<<v<<setw(19)<<v<<"\n"
<<p<<setw(13)<<l<<setw(13)<<l<<setw(19)<<l<<"\n"<<k<<setw(9)<<r<<setw(13)<<r<<setw(19)<<r<<endl;






cout<<"\n";

system("pause");
}

DIAGRAMA DE FLUJO

INICIO
INICIO

x,x1,x2,f(X),g(x)
x,x1,x2,f(X),g(x)

x!=0
x!=0

f(x)<-2(x1)(x1)-x1-5
f(x)<-2(x1)(x1)-x1-5
g(x)<-sqrt((x+5)/2)
g(x)<-sqrt((x+5)/2)
x1<-g(x)
x1<-g(x)
FIN
FIN
x1,E
x1,E
E<-x-x2E<-x-x2
x2<-f(x)
x2<-f(x)

ALGORITMO
1) INICIO
2) LEER x1,x2,f(x),g(x),x
3) Mientras x!=0
4) g(x)<-sqrt((x+5)/2)
5) x1<-g(x)
6) f(x)<-2(x1)(x1)-x1-5
7) x2<-f(x)
8) Si no
9) E<-x-x2
10) Mostrar x1
11) Mostrar E
12) Fin

CODIGO FUENTE
#include<iostream>
#include<iomanip>
#include<stdlib.h>#include<dos.h>
#include<conio.h>
#include<windows.h>
using namespace std;
int main()
{
float f,g,v,h,l,p,r,k,x=0;
cout<<" Programa el cual calcula funcion f(x)=cos(x)-3*x y la funcion g(x)=(cos(x)/3)\n";//<<"Introduce el valor de x :\n\n"<<endl;cin>>a;
g=(cos(x)/3);
f=cos(g)-3*g;
v=(cos(g)/3);
h=cos(v)-3*v;
l=(cos(v)/3);
p=cos(l)-3*l;r=(cos(l)/3);
k=cos(r)-3*r;
float e1,e2,e3,e4;
e1=x-g;e2=g-v;e3=v-l;e4=l-r;

cout<<"f(x)"<<setw(15)<<"g(x)"<<setw(17)<<"x1"<<setw(22)<<"xi+1"<<setw(21)<<"E\n"<<endl;
cout<<f<<setw(14)<<g<<setw(15)<<x<<setw(22)<<g<<setw(20)<<e1<<"\n"<<h<<setw(14)<<v<<setw(15)<<g<<setw(19)<<v<<setw(22)<<e2<<"\n"
<<p<<setw(12)<<l<<setw(15)<<v<<setw(19)<<l<<setw(21)<<e3<<"\n"
<<k<<setw(12)<<r<<setw(15)<<l<<setw(19)<<r<<setw(21)<<e4<<endl;cout<<"\n";

system("pause");
}

f(x) | g(x) | x1 | xi+1 | E |
-0.055043 | 0.333333 | 0 | 0.333333 | -0.333333 |
0.00584382 | 0.314986 | 0.333333 | 0.314986 | 0.0183477 |
-0.00060523 | 0.316934 | 0.314986 | 0.316934 | -0.0019794 |
6.28E-05 | 0.316732 | 0.316934 | 0.316732 | 0.00020176 |

Valores X | Valores Y |
0 | 1 |
1 | -2 |
2 | -5 |
3 | -8 |
0...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Programa
  • Program
  • Un Programa
  • Programas
  • Programas
  • Programa
  • Programador
  • Program

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS