Hi friends, i have written a C-prog,for implementing the equation in the attached file.. plz see the attachment!
assume tau(0)=0
tau(1)=0.1
T=0.1
X(tau(0))=1 as we know X = e^-t
X(tau(1))= X(0.1)= e^-0.1
n=2,3...20.
Code:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float x[20]={0},tau[20]={0},A,B,C,D,e=2.718;
int n,T=0.1;
tau[0]=0;
tau[1]=0.1;
x[0]=pow(e,0);
x[1]=pow(e,-0.1);
clrscr();
for(n=1;n<=20;n++)
{
x[tau[n]]=pow(e,-tau[n]);
x[tau[n-1]]=pow(e,-tau[n-1]);
A=x[tau[n]]-x[tau[n-1]];
B=tau[n]-tau[n-1];
C=A/B;
if(C<0)
C=-C;
D=C+1;
tau[n+1]=tau[n]+T/D;
printf("tau[n+1]=%f\n",tau[n+1]);
}
getch();
}
This prog is giving some error,if anyone debugs it plz let me know
thnx in advance!