Business

Wednesday, 1 July 2015

Pemrograman ( Metode Titik Tetap )

Metode Titik Tetap


#include<iostream.h>
#include<iomanip.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define epsilon 1E-13

main()
{
int it;
long double x=0.921, g_x ,fs;


textcolor(12);cprintf("                     METODE TITIK TETAP                       ");cout<<endl;
textcolor(2);cprintf("==============================================================");cout<<endl;

printf(" Eror         : ");cout<<epsilon<<endl;
printf(" Nilai X awal : %2.1Le\n",x);
textcolor(10);cprintf("==============================================================");cout<<endl;
textcolor(10);cprintf("|");
printf(" Iterasi ");
textcolor(10);cprintf("|");
printf("     x     ");
textcolor(10);cprintf("|");
printf("    g(x)   ");
textcolor(10);cprintf("|");
printf("    g(x)-x   ");
textcolor(10);cprintf("|");
printf(" KETERANGAN ");
textcolor(10);cprintf("|");cout<<endl;
textcolor(10);cprintf("==============================================================");cout<<endl;

it=-1;
do
{
it+=1;
g_x = log(2)-log(sin(x));
fs=fabs(g_x -x);

textcolor(10);cprintf("|");
printf(" %4d    ",it);
 textcolor(10);cprintf("|");
printf("%10.2Le ",x);
 textcolor(10);cprintf("|");
printf("%10.2Le ",g_x);
 textcolor(10);cprintf("|");
printf("%12.5Le ",fs);
 textcolor(10);cprintf("|");

x=g_x;

if(fs>=epsilon)
{
printf("   LANJUT   ");
}
else
{
textcolor(12);cprintf("  SELESAI   ");
}
textcolor(10);cprintf("|");cout<<endl;

if(it==3)                                                                    
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==6)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==9)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==12)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==15)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==18)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==21)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==24)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==27)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==30)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==33)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==36)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==39)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==42)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==45)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==48)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==51)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==54)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==57)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==60)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==63)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}

else if(it==66)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==69)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==72)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==75)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==78)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==81)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==84)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==87)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==90)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==93)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==96)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==99)
{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
else if(it==102)

{
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;
getche();
}
}
while(it<=200 && fs>=epsilon);
textcolor(10);cprintf("==============================================================");cout<<endl;
cout<<endl<<endl;
printf("   Selesai Pada Iterasi Ke- %d",it);cout<<endl;
textcolor(12);cprintf("   Nilai X sementara =  %20.16Le",g_x);cout<<endl;

}

0 komentar:

Post a Comment