Está en la página 1de 7

UNIVERSIDAD NACIONAL DE

CHIMBORAZO

FACULTAD DE INGENIERÍA

CARRERA DE INGENIERÍA EN ELECTRÓNICA Y


TELECOMUNICACIONES

Curva de Lorentz en C

ASIGNATURA: MICROPROCESADORES

ESTUDIANTE:

Franklin Geovanny Saes Tene

PROFESOR DE CÁTEDRA: Ing. Leonardo Rentería, Ph.D

RIOBAMBA, 23 JUNIO DE 2020


7.-Realizar un programa que resuelva la siguiente ecuación para a=10,b=28,c=8/3, el
resultado de x,y,z se imprime respectivamente para tres columnas para un intervalo de
tiempo definido.

El siguiente código es el método de Euler explicado en clase por el docente, se aplicó para sacar
datos de 0 a 13.

* File: lorentzs.c
* Author: SaesPc
*
* Created on 21 de junio de 2020, 20:17
*/

#include <stdio.h>
#include <stdlib.h>
float a=10,b=28,c=8/3;
float tf,t0,h,x0,y0,z0;
float f1_xyz,f2_xyz,f3_xyz,n=10;
int main()
{
t0=0.011;
tf=0.54;
x0=0.10;
y0=0.22;
z0=0.55;
h=(tf-t0)/n;
printf( "x0=%f y0=%f z0=%f t0=%f tf=%f h=%f\n\n", x0, y0, z0,
t0, tf, h);
printf( "_________________________________________________\n ");
printf( "t | x | y | z\n");
printf( "------------------------------------------------\n ");
printf( " | %f | %f | %f\n",x0,y0,z0);
float t1 = t0 + h;
f1_xyz=a*(y0-x0);
float x1= y0+h*f1_xyz;
f2_xyz=x0*(b-z0)-y0;
float y1= y0+h*f2_xyz;
f3_xyz=(x0*y0)-(c*z0);
float z1= y0 + h*f3_xyz;
printf( "%f | %f | %f | %f\n",t1,x1,y1,z1);
float t2=t1 + h;
f1_xyz=a*(y1-x1);
float x2= y1+h*f1_xyz;
f2_xyz=x1*(b-z1)-y1;
float y2= y1+h*f2_xyz;
f3_xyz=(x0*y1)-(c*z1);
float z2= y1+h*f3_xyz;
printf( "%f | %f | %f | %f\n",t2,x2,y2,z2);
float t3=t2 + h;
f1_xyz=a*(y2-x2);
float x3= y2+h*f1_xyz;
f2_xyz=x2*(b-z2)-y2;
float y3= y2+h*f2_xyz;
f3_xyz=(x2*y2)-(c*z2);
float z3= y2+h*f3_xyz;
printf( "%f | %f | %f | %f\n",t3,x3,y3,z3);
float t4=t3 + h;
f1_xyz=a*(y3-x3);
float x4= y3+h*f1_xyz;
f2_xyz=x3*(b-z3)-y3;
float y4= y3+h*f2_xyz;
f3_xyz=(x3*y3)-(c*z3);
float z4= y3+h*f3_xyz;
printf( "%f | %f | %f | %f\n",t4,x4,y4,z4);
float t5=t4 + h;
f1_xyz=a*(y4-x4);
float x5= y4+h*f1_xyz;
f2_xyz=x4*(b-z4)-y4;
float y5= y4+h*f2_xyz;
f3_xyz=(x4*y4)-(c*z4);
float z5= y4+h*f3_xyz;
printf( "%f | %f | %f | %f\n",t5,x5,y5,z5);
float t6=t5 + h;
f1_xyz=a*(y5-x5);
float x6= y5+h*f1_xyz;
f2_xyz=x5*(b-z5)-y5;
float y6= y5+h*f2_xyz;
f3_xyz=(x5*y5)-(c*z5);
float z6= y5+h*f3_xyz;
printf( "%f | %f | %f | %f\n",t6,x6,y6,z6);
float t7=t6 + h;
f1_xyz=a*(y6-x6);
float x7= y6+h*f1_xyz;
f2_xyz=x6*(b-z6)-y6;
float y7= y6+h*f2_xyz;
f3_xyz=(x6*y6)-(c*z6);
float z7= y6+h*f3_xyz;
printf( "%f | %f | %f | %f\n",t7,x7,y7,z7);
float t8=t7 + h;
f1_xyz=a*(y7-x7);
float x8= y7+h*f1_xyz;
f2_xyz=x7*(b-z7)-y7;
float y8= y7+h*f2_xyz;
f3_xyz=(x7*y7)-(c*z7);
float z8= y7+h*f3_xyz;
printf( "%f | %f | %f | %f\n",t8,x8,y8,z8);
float t9=t8 + h;
f1_xyz=a*(y8-x8);
float x9= y8+h*f1_xyz;
f2_xyz=x8*(b-z8)-y8;
float y9= y8+h*f2_xyz;
f3_xyz=(x8*y8)-(c*z8);
float z9= y8+h*f3_xyz;
printf( "%f | %f | %f | %f\n",t9,x9,y9,z9);
float t10=t9 + h;
f1_xyz=a*(y9-x9);
float x10= y9+h*f1_xyz;
f2_xyz=x9*(b-z9)-y9;
float y10= y9+h*f2_xyz;
f3_xyz=(x9*y9)-(c*z9);
float z10= y9+h*f3_xyz;
printf( "%f | %f | %f | %f\n",t10,x10,y10,z10);

float t11=t10 + h;
f1_xyz=a*(y10-x10);
float x11= y10+h*f1_xyz;
f2_xyz=x10*(b-z10)-y10;
float y11= y10+h*f2_xyz;
f3_xyz=(x10*y10)-(c*z10);
float z11= y10+h*f3_xyz;
printf( "%f | %f | %f | %f\n",t11,x11,y11,z11);
float t12=t11 + h;
f1_xyz=a*(y11-x11);
float x12= y11+h*f1_xyz;
f2_xyz=x11*(b-z11)-y11;
float y12= y11+h*f2_xyz;
f3_xyz=(x11*y11)-(c*z11);
float z12= y11+h*f3_xyz;
printf( "%f | %f | %f | %f\n",t12,x12,y12,z12);
float t13=t12 + h;
f1_xyz=a*(y12-x12);
float x13= y12+h*f1_xyz;
f2_xyz=x12*(b-z12)-y12;
float y13= y12+h*f2_xyz;
f3_xyz=(x12*y12)-(c*z12);
float z13= y12+h*f3_xyz;
printf( "%f | %f | %f | %f\n",t13,x13,y13,z13);
}
7.2. Resultado

x0=0.100000 y0=0.220000 z0=0.550000 t0=0.011000 tf=0.540000


h=0.052900

_________________________________________________
t | x | y | z
-------------------------------------------------
| 0.100000 | 0.220000 | 0.550000
0.063900 | 0.283480 | 0.353573 | 0.162974
0.116800 | 0.390651 | 0.752315 | 0.338200
0.169700 | 0.943635 | 1.284162 | 0.732081
0.222600 | 1.464300 | 2.577398 | 1.270811
0.275500 | 3.166227 | 4.511536 | 2.642595
0.328400 | 5.223205 | 8.520074 | 4.987602
0.381300 | 10.264118 | 14.427862 | 10.346546
0.434200 | 16.630484 | 23.249958 | 21.167122
0.487100 | 26.751661 | 28.031277 | 41.464691
0.540000 | 28.708193 | 7.493689 | 63.313141
0.592900 | -3.728786 | -46.531509 | 12.175550
0.645800 | -69.174149 | -47.191410 | -38.641212

RUN SUCCESSFUL (total time: 3s)

7.3 . Gráfico de los valores


#include<graphics.h>
#include<conio.h>
#include<dos.h>

int main() {
int gd,gm;
float x=0.01,y,z,dx,dy,dz,dt=0.0002,t;
// Resolveremos para los valores siguientes
float a=10,b=28,c=8/3.0;
char text[80] ;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,NULL);
settextstyle(0,0,5);
setcolor(4);
sprintf(text,"XY");
outtextxy(155,50,text);
setcolor (2) ;
sprintf(text, "XZ");
outtextxy(590,50,text);
setcolor (1);
sprintf(text,"YZ");
outtextxy(1015,50,text);
delay(2000);
for(t=0;t<100,t=t+dt){
dx=a*(y-x)*dt;
dy=(x*(b-z)-y)*dt;
dz= (x*y-c*z)*dt;
x=x+dx;
y=y+dy;
z=z+dz;
// Para poder apreciar las graficas en 3d, en tres planos
putpixel(200+8*x,350-8*y,4);
putpixel(625+8*x,525-8*z,2);
putpixel(1050+8*y,525-8*z,1);
}
getch();
closegraph();
return 0;
}

Captura de la Salida:

También podría gustarte