lunes, 24 de noviembre de 2008

Imágenes

IMAGEN DIGITAL

Una imagen digital en escala de grises es un matriz de MxN elementos numéricos cuyos valores posibles van del 0 (negro) al 255 (blanco), siendo este número la intensidad luminosa en el determinado punto o pixel (picture element), por convención el origen de la imagen se encuentra en el extremo izquierdo superior.

Una imagen digital a colores esta formada por 3 matrices de MxN elementos numéricos cuyos valores posibles van del 0 (negro) al 255 (blanco), siendo este número la intensidad luminosa en cada una de las bandas espectrales del RGB (Rojo, Verde, Azul), de cada punto o pixel (picture element), a diferencia de las imágenes en escala de grises, las imágenes a color requiren de la combinación de las 3 bandas de color, para representar el color de un pixel.

Por ejemplo, un determinado punto blanco de una imagen en escala de grises se describiría: P(x, y) = 255, sin embargo en una imagen a colores para describir el color del mismo punto se realizaría así: P(x, y) = (255, 255,255), esto debido a que el (0, 0,0) corresponde al negro absoluto y el (255, 255,255) al blanco absoluto).

PROCESAMIENTO DIGITAL DE IMÁGENES

El procesamiento digital de imágenes es el conjunto de técnicas que se aplican a las imágenes digitales con el objetivo de mejorar la calidad o facilitar la búsqueda de información.
Las operaciones que se pueden realizar con imágenes se dividen en :
Operaciones de punto
Operaciones de entorno
Operaciones con dos o más imágenes

viernes, 7 de noviembre de 2008

PRONOSTICOS DEL PIB (PATRICIO TAPIA)

--PRONOSTICO DEL PIB PARA EL 1998
--TOMANDO COMO VALORES REFERENCIALES LOS ANTERIORES AÑOS DESDE EL 1993 HASTA EL 1997
zt=[18573 20195 21268 23635 23255]';
n=length(zt)
zt1=[10056;zt(1:n-1)]
zt2=[0;10056;zt(1:n-2)]
x=[zt1,zt2]
b=inv(x'*x)*(x'*zt)
s=poly(0,'s')
s=s^2-b(1)*s-b(2)
raiz=roots(s)
t=[1:n]'
z1=(raiz(1).^t)
z2=(raiz(2).^t)
x=[z1 z2]
a=inv(x'*x)*(x'*zt)
z=a(1)*z1+a(2)*z2
error1=zt-z
sqrt(error1'*error1)
plot(t,error1)
--EN LA SIGUIENTE LINEA SE DA EL PRONOSTICO DEL VALOR PARA EL 1998
t=[1:n+1]';
z1=(raiz(1).^t)

--EN CONCLUSION : EN VALOR RESULTADO DEL PRONOSTICO ES MUY ELEVADO Y DIFERENTE DEL VALOR –
--QUE SE ANUNCIO POR LA PRENSA.EN AQUELLA EPOCA DEBIDO A LOS FACTORES ADVERSOS POR TODOS
--CONOCIDOS .

===============================================

--PRONOSTICO DEL PIB PARA EL 2008
--TOMANDO COMO VALORES REFERENCIALES LOS ANTERIORES AÑOS DESDE EL 2000 HASTA EL 2007
zt=[21250 24899 28636 32642 37187 41763 45789 48508]';
n=length(zt)
zt1=[0;zt(1:n-1)]
zt2=[0;0;zt(1:n-2 )]
x=[zt1,zt2]
b=inv(x'*x)*(x'*zt)
s=poly(0,'s')
s=s^2-b(1)*s-b(2)
raiz=roots(s)
t=[1:n]'
z1=(raiz(1).^t)
z2=(raiz(2).^t)
x=[z1 z2]
a=inv(x'*x)*(x'*zt)
z=a(1)*z1+a(2)*z2
error1=zt-z
sqrt(error1'*error1)
plot(t,error1)
--EN LA SIGUIENTE LINEA SE DA EL PRONOSTICO DEL VALOR PARA EL 2008
t=[1:n+1]';
z1=(raiz(1).^t)
z2=(raiz(2).^t)
z=a(1)*z1+a(2)*z2
plot(t,z)


==================================================================
==================================================================

OPERACIONES CON MATRICES (PATRICIO TAPIA)

PRIMER TRABAJO
1.1- ELABORAR UN PROGRAMA PARA OBTENER LA TRANSPUESTA, INVERSA Y EL DETERMINANTE DE UNA MATRIZ
1.2- ELABORAR UN PROGRAMA PARA REALIZAR OPERACIONES SUMA RESTA Y MULTIPLICACION ENTRE MATRICES


DESARROLLO

ELABORAR UN PROGRAMA PARA OBTENER LA TRANSPUESTA, INVERSA Y EL DETERMINANTE DE UNA MATRIZ

import java.io.*;

class lectura // para sacar la matriz transpuesta, inversa y el determinante
{

int mat[][], trans[][], f, c;
double deter=1.0;
double inv[][];
double n1,n2,n3,n4,n5,n6,n7,n8,n9;
double ind1,ind2,ind3;
double ecu[][], ecu2[],ecu3[][];
int op;

BufferedReader h;
void ini(){
h=new BufferedReader(new InputStreamReader(System.in));
}

int entero (String x) throws IOException{
int a=0;
System.out.print(x);
try {
a=Integer.parseInt(h.readLine());
} catch(NumberFormatException e) {
System.out.println("\tERROR: NO ES UN NUMERO");
}
return a;
}

double doble (String x) throws IOException{
double a=0;
System.out.print(x);
try {
a=Double.parseDouble(h.readLine());
} catch(NumberFormatException e) {
System.out.println("\tERROR: NO ES UN NUMERO");
}
return a;
}

void menu(int op) throws IOException {
matrices m=new matrices();
ini();
do {
System.out.println("\n\t\t\t M E N U ");
System.out.println(" ================================================================");
System.out.println(" [1] Matriz transpuesta");
System.out.println(" [2] Determinante de una matriz");
System.out.println(" [3] Matriz inversa");
System.out.println(" [4] Salir");
System.out.println();
op=entero("\tElige una opcion: ");
System.out.println();
switch(op) {
case 1:
//Matriz transpuesta
System.out.println("\tMatriz transpuesta");
f=entero("\tIngrese el numero de filas==> ");
c=entero("\tIngrese el numero de columnas==> ");
System.out.println();

mat=m.lee_M(f,c);
System.out.println("\tMATRIZ ORIGINAL");
System.out.println();
m.imp_M(mat);

System.out.println();
trans=m.transpuesta(mat,f,c);
System.out.println();
System.out.println("\tMATRIZ TRANSPUESTA");
System.out.println();
m.imp_M(trans);
/****************************************************/
break;

case 2:
//Determinante de una matriz
System.out.println();
System.out.println();
System.out.println("\tDeterminante de una matriz");
f=entero("\tIngrese el numero de filas y columnas==> ");
System.out.println();

mat=m.lee_M(f,f);
System.out.println("\tMATRIZ ORIGINAL");
System.out.println();
m.imp_M(mat);

System.out.println();
deter=m.determinate(mat,f);
System.out.println("\tDeterminante==> "+deter);
/****************************************************/
break;

case 3:
//Matriz inversa
System.out.println();
System.out.println();
System.out.println("\tMatriz inversa");
f=entero("\tIngrese el numero de filas y columnas==> ");
System.out.println();

mat=m.lee_M(f,f);
System.out.println("\tMATRIZ ORIGINAL");
System.out.println();
m.imp_M(mat);

System.out.println();
inv=m.inversa2(mat,f);
System.out.println("\tMATRIZ INVERSA");
System.out.println();
m.imp_M2(inv);


/****************************************************/
break;

case 4:
System.out.println("\tFin del programa");
break;

default:
System.out.println("\tOpcion errada!!!");
}
}
while(op!=4);
}
}







import java.io.*;

class matrices // para sacar la matriz transpuesta, inversa y el determinante
{

int[][] lee_M(int f, int c) throws IOException
{
lectura o4=new lectura();
o4.ini();
int matriz[][]=new int[1][1];
try {
matriz=new int[f][c];
for(int i=0; i {
for (int j=0; j {
matriz[i][j]=o4.entero("\tIngrese el elemento ["+i+"] ["+j+"]==> ");
}
System.out.println();
}
} catch (NegativeArraySizeException e)
{
System.out.println("\tERROR: TAMANO DE LA MATRIZ NEGATIVO");
}
return matriz;
}

void imp_M(int x[][])
{
try {
for(int i=0; i {
for (int j=0; j {
System.out.print("\t"+x[i][j]+" ");
}
System.out.println();
}
}catch(NegativeArraySizeException e)
{
System.out.println("\tERROR: TAMANO DE LA MATRIZ NEGATIVO");
}
}

void imp_M2(double x[][])
{
try {
for(int i=0; i {
for (int j=0; j {
System.out.print("\t"+x[i][j]+" ");
}
System.out.println();
}
}catch(NegativeArraySizeException e)
{
System.out.println("\tERROR: TAMANO DE LA MATRIZ NEGATIVO");
}
}

void imp_V(double x[])
{
try {
for(int i=0; i {
System.out.print("\t"+x[i]+" ");
}
System.out.println();
}catch(NegativeArraySizeException e)
{
System.out.println("\tERROR: TAMANO DE LA MATRIZ NEGATIVO");
}
}

//Matriz transpuesta

int[][] transpuesta(int x[][], int f, int c)
{
int resp[][]=new int[1][1];
try {
resp=new int[c][f];
for(int i=0; i {
for(int j=0; j {
resp[i][j]=x[j][i];
}
}
} catch (NegativeArraySizeException e)
{
System.out.println("\tERROR: TAMANO DEL VECTOR NEGATIVO");
}
return resp;
}
/****************************************************/


//Determinante de una matriz

double determinate(int x[][], int f)
{
try {
for(int k=0; k {
for(int i=k+1; i {
for(int j=k+1; j {
x[i][j]-=x[i][k]*x[k][j]/x[k][k];
}
}
}
}catch (NegativeArraySizeException e)
{
System.out.println("\tERROR: TAMANO DE LA MATRIZ NEGATIVO");
}
}


double deter=1.0;
for(int i=0; i {
deter*=x[i][i];
}
return deter;
}
/****************************************************/


//Matriz inversa double
double[][] inversa(double x[][], int f) {
double resp[][]=new double[1][1];
double resp2[][]=new double[1][1];

try {
resp=new double [f][f];
resp2=new double[f][f];

for(int i=0; i resp[i][i]=1.0;
}

for(int k=0; k for(int i=k+1; i for(int s=0; s resp[i][s]-=x[i][k]*resp[k][s]/x[k][k];
}
for(int j=k+1; j x[i][j]-=x[i][k]*x[k][j]/x[k][k];
}
}
}

for(int s=0; s resp2[f-1][s]=resp[f-1][s]/x[f-1][f-1];
for(int i=f-2; i>=0; i--){
resp2[i][s]=resp[i][s]/x[i][i];
for(int k=f-1; k>i; k--){
resp2[i][s]-=x[i][k]*resp2[k][s]/x[i][i];
}
}
}
}catch (NegativeArraySizeException e) {
System.out.println("\tERROR: TAMANO DE LA MATRIZ NEGATIVO");
}
return resp2;
}
/****************************************************/


public static void main(String args[]) throws IOException
{
matrices o=new matrices();
lectura o2=new lectura();

o2.ini();

o2.menu(o2.op);
}
}


==================================
==================================

//1.2 ELABORAR UN PROGRAMA PARA REALIZAR OPERACIONES SUMA RESTA Y MULTIPLICACION ENTRE MATRICES

public class MenuMatriz // para operaciones de suma y resta y multiplicación de matrices del orden que se escoja.

{
public static void main(String args[])
{
Operaciones obj= new Operaciones();
Leer Lee = new Leer();
int op;
do
{
System.out.println("\n M E N U ");
System.out.println("=========================");
System.out.println(" [1] SUMA");
System.out.println(" [2] RESTA");
System.out.println(" [3] MULTIPLICACCION");
System.out.println(" [4] SALIR");
System.out.print("\n ESCOJA UNA OPCION : ");
op=Lee.datoInt();
switch (op)
{
case 1: obj.Suma(); break;
case 2: obj.Resta(); break;
case 3: obj.Multiplicacion(); break;
case 4: System.out.println("\nFin del programa."); break;
default: System.out.println("\n¡¡¡Error de seleccion!!!");
}
}while(op!=4);
}
}

class Leer //para operaciones de suma y resta y multiplicación de matrices del orden que se escoja.
{
public static String dato()
{
String sdato="";
try
{
InputStreamReader isr = new InputStreamReader (System.in);
BufferedReader flujo =new BufferedReader (isr);
sdato=flujo.readLine();
}
catch (IOException e)
{
System.err.println("Error"+ e.getMessage());
}
return sdato;
}
public static int datoInt()
{
try
{
return Integer.parseInt (dato());
}
catch(NumberFormatException e)
{
return Integer.MIN_VALUE;
}
}
public static float datoFloat()
{
try
{
Float f = new Float(dato());
return f.floatValue();
}
catch(NumberFormatException e)
{
return Float.NaN; // No es un Número; valor float.
}
}
}

class Operaciones // //para operaciones de suma y resta y multiplicación de matrices del orden que se escoja.

{
void Muestra(float M[][],int F,int C)
{
for(int y=0; y {
System.out.print("\n");
for(int x=0; x System.out.print(M[x][y]+" ");
}
}
void Muestra(int M[][],int F,int C)
{
for(int y=0; y {
System.out.print("\n");
for(int x=0; x System.out.print(M[x][y]+" ");
}
}

boolean Compara(int AX,int AY,int BX,int BY)
{
if ((AX==BX && AY==BY))
return true;
return false;
}

boolean Compara(int AX,int BY)
{
if ((AX==BY))
return true;
return false;
}

void Suma() // suma de matrices
{
Leer Lee = new Leer();
Operaciones Obj= new Operaciones();
int FA=0;
int FB=0;
int CA=0;
int CB=0;
System.out.println("\n Teclee el número de Filas y Columnas para las matrices.");
System.out.print("\n Filas de A:"); FA=Lee.datoInt();
System.out.print("\n Filas de B:"); FB=Lee.datoInt();
System.out.print("\n Columnas de A:"); CA=Lee.datoInt();
System.out.print("\n Columnas de B:"); CB=Lee.datoInt();
int A[][] = new int[CA][FA];
int B[][] = new int[CB][FB];
int S[][] = new int[CA][FB];
if (Obj.Compara(CA,FA,CB,FB))
{
System.out.println("\nElementeos para A:");
for(int y=0; y for(int x=0; x {
System.out.print("A["+(x+1)+"]["+(y+1)+"] = "); A[x][y]= Lee.datoInt();
}
System.out.println("\nElementeos para B:");
for(int y=0; y for(int x=0; x {
System.out.print("B["+(x+1)+"]["+(y+1)+"] = "); B[x][y]= Lee.datoInt();
}

System.out.println("\nMatriz A:\n");
Obj.Muestra(A,FA,CA);
System.out.println("\nMatriz B:\n");
Obj.Muestra(B,FB,CB);
for(int y=0; y for(int x=0; x S[x][y]=A[x][y]+B[x][y];
System.out.println("\nLa suma es:\n");
Obj.Muestra(S,FA,CB);
}
else
{
System.out.println("\n Para sumarce las matrices tienen que tener las mismas dimenciones");
}
}

void Resta()
{
Leer Lee = new Leer();
Operaciones Obj= new Operaciones();
int FA=0;
int FB=0;
int CA=0;
int CB=0;
System.out.println("\n Teclee el número de Filas y Columnas para las matrices.");
System.out.print("\n Filas de A:"); FA=Lee.datoInt();
System.out.print("\n Filas de B:"); FB=Lee.datoInt();
System.out.print("\n Columnas de A:"); CA=Lee.datoInt();
System.out.print("\n Columnas de B:"); CB=Lee.datoInt();
int A[][] = new int[CA][FA];
int B[][] = new int[CB][FB];
int S[][] = new int[CA][FB];
if (Obj.Compara(CA,FA,CB,FB))
{
System.out.println("\nElementeos para A:");
for(int y=0; y for(int x=0; x {
System.out.print("A["+(x+1)+"]["+(y+1)+"] = "); A[x][y]= Lee.datoInt();
}
System.out.println("\nElementeos para B:");
for(int y=0; y for(int x=0; x {
System.out.print("B["+(x+1)+"]["+(y+1)+"] = "); B[x][y]= Lee.datoInt();
}

System.out.println("\nMatriz A:\n");
Obj.Muestra(A,FA,CA);
System.out.println("\nMatriz B:\n");
Obj.Muestra(B,FB,CB);
for(int y=0; y for(int x=0; x S[x][y]=A[x][y]+(B[x][y]*-1);
System.out.println("\nLa resta es:\n");
Obj.Muestra(S,FA,CB);
}
else
{
System.out.println("\n Para restarse las matrices tienen que tener las mismas dimenciones");
}
}

void Multiplicacion()
{
Leer Lee = new Leer();
Operaciones Obj= new Operaciones();
int FA=0;
int FB=0;
int CA=0;
int CB=0;
int suma=0;
int h=0;
System.out.println("\n Teclee el número de Filas y Columnas para las matrices.");
System.out.print("\n Filas de A:"); FA=Lee.datoInt();
System.out.print("\n Filas de B:"); FB=Lee.datoInt();
System.out.print("\n Columnas de A:"); CA=Lee.datoInt();
System.out.print("\n Columnas de B:"); CB=Lee.datoInt();
int A[][] = new int[CA][FA];
int B[][] = new int[CB][FB];
int S[][] = new int[CA][FB];
if (Obj.Compara(CA,FB))
{
System.out.println("\nElementeos para A:");
for(int y=0; y for(int x=0; x {
System.out.print("A["+(x+1)+"]["+(y+1)+"] = "); A[x][y]= Lee.datoInt();
}
System.out.println("\nElementeos para B:");
for(int y=0; y for(int x=0; x {
System.out.print("B["+(x+1)+"]["+(y+1)+"] = "); B[x][y]= Lee.datoInt();
}

System.out.println("\nMatriz A:\n");
Obj.Muestra(A,FA,CA);
System.out.println("\nMatriz B:\n");
Obj.Muestra(B,FB,CB);
for(int y=0; y for(int x=0; x {
h=0;
suma=0;
while(h {
suma+=A[h][y]*B[x][h];
h++;
}
S[x][y]=suma;
}
System.out.println("\nLa multiplicacion es:\n");
Obj.Muestra(S,FA,CB);
}
else
{
System.out.println("\n Para multiplicarse el numero de columnas de la matriz A tiene que ser igual \nal numero de filas de la matriz B");
}
}
}





PIB Ecuador

//PRONOSTICO DEL AÑO 2008
vector=[21250 24899 28636 32642 37187 41763 45789 48508]';
n=length(vector)
vector1=[0;vector(1:n-1)]
vector2=[0;0;vector(1:n-2)]
x=[vector1,vector2]
b=inv(x'*x)*(x'*vector)
s=poly(0,'s')
s=s^2-b(1)*s-b(2)
raiz=roots(s)
t=[1:n]'
vector1=(raiz(1).^t)
vector2=(raiz(2).^t)
x=[vector1 vector2]
a=inv(x'*x)*(x'*vector)
z=a(1)*vector1+a(2)*vector2
plot(t,[vector z])
//error1=vector-z
//sqrt(error1'*error1)
//plot(error1)
t=[1:n+1]';
vector1=(raiz(1).^t)
vector2=(raiz(2).^t)
z=a(1)*vector1+a(2)*vector2
plot(t,z)


//PRONOSTICO DEL AÑO 98
vector=[18573 20195 21268 23635 23255]';
n=length(vector)
vector1=[0;vector(1:n-1)]
vector2=[0;0;vector(1:n-2)]
x=[vector1,vector2]
b=inv(x'*x)*(x'*vector)
s=poly(0,'s')
s=s^2-b(1)*s-b(2)
raiz=roots(s)
t=[1:n]'
vector1=(raiz(1).^t)
vector2=(raiz(2).^t)
x=[vector1 vector2]
a=inv(x'*x)*(x'*vector)
z=a(1)*vector1+a(2)*vector2
plot(t,vector)
//error1=vector-z
//sqrt(error1'*error1)
//plot(error1)
t=[1:n+1]';
vector1=(raiz(1).^t)
vector2=(raiz(2).^t)
z=a(1)*vector1+a(2)*vector2
plot(t,z)

jueves, 6 de noviembre de 2008

Pronostico del PIB

-Pronostico del 2008
zt=[21250 24899 28636 32642 37187 41763 45789 48508]';
n=length(zt)
zt1=[0;zt(1:n-1)]
zt2=[0;0;zt(1:n-2)]
x=[zt1,zt2]
b=inv(x'*x)*(x'*zt)
s=poly(0,'s')
s=s^2-b(1)*s-b(2)
raiz=roots(s)
alfa=real(raiz(1))
beta=imag(raiz(1))
r=sqrt(alfa^2+beta^2)
teta=acos(alfa/r)
t=[1:n]'
z1=(raiz(1).^t)
z2=(raiz(2).^t)
x=[z1 z2]
a=inv(x'*x)*(x'*zt)
z=a(1)*z1+a(2)*z2
plot(t,[zt z])
plot(t,zt)
e=zt-z
sqrt(e'*e)
plot(t,e)
t=[1:n+1]';
z1=(raiz(1).^t)
z2=(raiz(2).^t)
z=a(1)*z1+a(2)*z2
plot(t,z)


-Pronostico de PIB 1998
vector=[18573 20195 21268 23635 23255]';
n=length(V)
v1=[0;V(1:n-1)]
v2=[0;0;V(1:n-2)]
x=[v1,v2]b=inv(x'*x)*(x'*V)
s=poly(0,'s')
s=s^2-b(1)*s-b(2)
raiz=roots(s)t=[1:n]'
v1=(raiz(1).^t)
v2=(raiz(2).^t)
x=[v1 v2]
a=inv(x'*x)*(x'* V)
z=a(1)*v1+a(2)*v2
plot(t, V)
e=V-z
sqrt(e'*e)
plot(e)
t=[1:n+1]';
v1=(raiz(1).^t)
v2=(raiz(2).^t)
z=a(1)*v1+a(2)*v2
plot(t,z)

miércoles, 5 de noviembre de 2008

Pronóstico del PIB en el Ecuador

//PRONOSTICO DEL AÑO 2008
vector=[21250 24899 28636 32642 37187 41763 45789 48508]';
n=length(vector)
vector1=[0;vector(1:n-1)]
vector2=[0;0;vector(1:n-2)]
x=[vector1,vector2]
b=inv(x'*x)*(x'*vector)
s=poly(0,'s')
s=s^2-b(1)*s-b(2)
raiz=roots(s)
t=[1:n]'
vector1=(raiz(1).^t)
vector2=(raiz(2).^t)
x=[vector1 vector2]
a=inv(x'*x)*(x'*vector)
z=a(1)*vector1+a(2)*vector2
plot(t,[vector z])
//error1=vector-z
//sqrt(error1'*error1)
//plot(error1)
t=[1:n+1]';
vector1=(raiz(1).^t)
vector2=(raiz(2).^t)
z=a(1)*vector1+a(2)*vector2
plot(t,z)


//PRONOSTICO DEL AÑO 98
vector=[18573 20195 21268 23635 23255]';
n=length(vector)
vector1=[0;vector(1:n-1)]
vector2=[0;0;vector(1:n-2)]
x=[vector1,vector2]
b=inv(x'*x)*(x'*vector)
s=poly(0,'s')
s=s^2-b(1)*s-b(2)
raiz=roots(s)
t=[1:n]'
vector1=(raiz(1).^t)
vector2=(raiz(2).^t)
x=[vector1 vector2]
a=inv(x'*x)*(x'*vector)
z=a(1)*vector1+a(2)*vector2
plot(t,vector)
//error1=vector-z
//sqrt(error1'*error1)
//plot(error1)
t=[1:n+1]';
vector1=(raiz(1).^t)
vector2=(raiz(2).^t)
z=a(1)*vector1+a(2)*vector2
plot(t,z)

Pronóstico del PIB

//******* 2000 AL 2007*********
///************************************************************
zt=[21250 24899 28636 32642 37187 41763 45789 48508]';
n=length(zt)
zt1=[0;zt(1:n-1)]
zt2=[0;0;zt(1:n-2)]
x=[zt1,zt2]
b=inv(x'*x)*(x'*zt)
s=poly(0,'s')
s=s^2-b(1)*s-b(2)
raiz=roots(s)
t=[1:n]'
z1=(raiz(1).^t)
z2=(raiz(2).^t)
x=[z1 z2]
a=inv(x'*x)*(x'*zt)
z=a(1)*z1+a(2)*z2

plot(t,[zt z])


error1=zt-z
sqrt(error1'*error1)

t=[1:n+1]';
z1=(raiz(1).^t)
z2=(raiz(2).^t)
z=a(1)*z1+a(2)*z2
plot(t,z)


//******* 1993 AL 1997*************************************
//*********************************************************
zt=[18573 20195 21268 23635 23255]';
n=length(zt)
zt1=[10056;zt(1:n-1)]
zt2=[0;10056;zt(1:n-2)]
x=[zt1,zt2]
b=inv(x'*x)*(x'*zt)
s=poly(0,'s')
s=s^2-b(1)*s-b(2)
raiz=roots(s)
t=[1:n]'
z1=(raiz(1).^t)
z2=(raiz(2).^t)
x=[z1 z2]
a=inv(x'*x)*(x'*zt)
z=a(1)*z1+a(2)*z2

//plot(t,[zt z])

plot(t,zt)
error1=zt-z
sqrt(error1'*error1)

t=[1:n+1]';
z1=(raiz(1).^t)
z2=(raiz(2).^t)
z=a(1)*z1+a(2)*z2
plot(t,z)