Business

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Wednesday, 1 July 2015

Pemrograman (Metode Pembuatan Matriks)

#include<conio.h>
#include<stdio.h>
#include<iomanip.h>
#include<iostream.h>
#include<math.h>
main()
{
int A[10][10];
int B[10][10];
int C[10][10];
int temp;
int a1,b1,a,b,c;
char P;
cout<<endl;

cout<<endl;
cout<<endl;
cout<<"====================================================";cout<<endl;
cout<<"                 TUGAS ANALISIS NUMERIK             ";cout<<endl;
cout<<"                    OPERASI MATRIKS                 ";cout<<endl;
cout<<"=====================================================";cout<<endl;
cout<<endl;

textcolor(9);cprintf("   TAMPILAN MATRIKS A DAN MATRIK B   ");cout<<endl;
cout<<endl;
cout<<" Masukkan jumlah kolom matriks=";cin>>a1;
cout<<" Masukkan jumlah baris matriks=";cin>>b1;
cout<<endl;
cout<<"\n Input Elemen Martriks A : \n";
for( a=1;a<=a1;a++)
    {
for( b=1;b<=b1;b++)
    {
cout<<" masukkan elemen ke ("<<a<<","<<b<<")= ";
cin>>A[a][b];
}
}
textcolor(13);cprintf("\n Martriks A \n");cout<<endl;
for( a=1;a<=a1;a++)
    {
for( b=1;b<=b1;b++)
    {
cout<<A[a][b];
cout<<"     ";
}
cout<<endl;
}
cout<<endl;
cout<<" Masukkan jumlah kolom matriks=";cin>>a1;
cout<<" Masukkan jumlah baris matriks=";cin>>b1;
cout<<endl;
cout<<"\n Input Elemen Martriks B : \n";
for( a=1;a<=a1;a++)
    {
for( b=1;b<=b1;b++)
    {
cout<<" masukkan elemen ke ("<<a<<","<<b<<")= ";
cin>>B[a][b];
}
}
textcolor(12);cprintf("\n Martriks B \n");cout<<endl;
for( a=1;a<=a1;a++)
    {
for( b=1;b<=b1;b++)
    {
cout<<A[a][b];
cout<<"     ";
}
cout<<endl;
}
cout<<endl;
textcolor(15);cprintf(" Pilihan Operasi Matriks : ");cout<<endl;
textcolor(15);cprintf(" 1. (+) Penjumlahan ");cout<<endl;
textcolor(15);cprintf(" 2. (-) Pengurangan ");cout<<endl;
textcolor(15);cprintf(" 3. (T) Transpose ");cout<<endl;
textcolor(15);cprintf(" 4. (*) Perkalian ");cout<<endl;
textcolor(15);cprintf(" Ingin operasi matriks dengan simbol yang mana?  ");cin>>P;
if(P=='+')
{
cout<<endl;
textcolor(9);cprintf("   Penjumlahan Matriks (A + B) : ");cout<<endl;
textcolor(9);cprintf("\n Matriks C \n");cout<<endl;
for ( a=1;a<=a1;a++)
    {
for ( b=1;b<=b1;b++)
   {
   C[a][b]=(A[a][b])+(B[a][b]);
    printf(" %4d ",C[a][b]);
}
cout<<endl;
}
}
else if(P=='-')
{
cout<<endl;
textcolor(11);cprintf("   Pengurangan Matriks (A - B) : ");cout<<endl;
textcolor(11);cprintf("\n   Matriks C \n");cout<<endl;
for ( a=1;a<=a1;a++)
    {
for ( b=1;b<=b1;b++)
   {
    C[a][b]=(A[a][b])-(B[a][b]);
    printf(" %4d ",C[a][b]);
}
cout<<endl;
}
}
else if (P=='T')
{
cout<<endl;
textcolor(12);cprintf("      TRANSPOSE Martriks A : ");cout<<endl;
for( a=1;a<=b1;a++)
    {
for( b=1;b<=a1;b++)
    {
    cout<<A[b][a];
    cout<<"     ";
}
cout<<endl;
}
cout<<endl;
textcolor(12);cprintf("     TRANSPOSE Martriks B : ");cout<<endl;
for( a=1;a<=b1;a++)
    {
for( b=1;b<=a1;b++)
    {
    cout<<B[b][a];
    cout<<"     ";
}
cout<<endl;
}
}
else if(P=='*')
{
cout<<endl;
textcolor(13);cprintf("   Perkalian Matriks (A x B) : ");cout<<endl;
cout<<endl;
cout<<"\Matriks C \n";
for ( a=1;a<=a1;a++)
    {
for ( b=1;b<=b1;b++)
    {
C[a][b]=0;
for ( c=1;c<=b1;c++)
    {
temp=A[a][c]*B[c][b];
C[a][b]=C[a][b]+temp;
}
}
}
cout<<endl;
for ( a=1;a<=a1;a++)
    {
for ( b=1;b<=b1;b++)
    {
    cout<<C[a][b];
    cout<<"  ";
}
cout<<endl;
}
}
getche();
}

Pemrograman (Metode Secant)

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

main()
{
int it;
long double x[100],fx[100],fs;

textcolor(10);cprintf(" Nama  : Asrul Maiwa");cout<<endl;
textcolor(10);cprintf(" NIM   : 1312140015");cout<<endl;
textcolor(10);cprintf(" Kelas : SAINS(C)");cout<<endl;
textcolor(2);cprintf("================================================");cout<<endl;
textcolor(12);cprintf("               METODE   SECANT                 ");cout<<endl;
textcolor(2);cprintf("================================================");cout<<endl;
cout<<endl;
textcolor(12);cprintf("  1.  1+x-tan(x)= 0");cout<<endl;
cout<<endl;
textcolor(10);cprintf("================================================");cout<<endl;
textcolor(10);cprintf("|");
printf(" Iterasi ");
textcolor(10);cprintf("|");
printf("     x     ");
textcolor(10);cprintf("|");
printf("    f(x)   ");
textcolor(10);cprintf("|");
printf(" KETERANGAN ");
textcolor(10);cprintf("|");cout<<endl;
textcolor(10);cprintf("================================================");cout<<endl;
it=0;
x[it]=1;
fx[it]=1+x[it]-tan(x[it]*3.14/180);

textcolor(10);cprintf("|");
printf(" %4d    ",it);
textcolor(10);cprintf("|");
printf("%10.2Le ",x[it]);
textcolor(10);cprintf("|");
printf("%10.2Le ",fx[it]);
textcolor(10);cprintf("|");
printf("            ");
textcolor(10);cprintf("|");cout<<endl;
it=1;
x[it]=2;
fx[it]=1+x[it]-tan(x[it]*3.14/180);
textcolor(10);cprintf("|");
printf(" %4d    ",it);
textcolor(10);cprintf("|");
printf("%10.2Le ",x[it]);
textcolor(10);cprintf("|");
printf("%10.2Le ",fx[it]);
textcolor(10);cprintf("|");
printf("            ");
textcolor(10);cprintf("|");cout<<endl;
do
{
it+=1;
x[it]=x[it-1]-((fx[it-1]*(x[it-1]-x[it-2]))/(fx[it-1]-fx[it-2]));
fx[it]=1+x[it]-tan(x[it]*3.14/180);
fs=fabs(x[it]-x[it-1]) ;
textcolor(10);cprintf("|");
printf(" %4d    ",it);
textcolor(10);cprintf("|");
printf("%10.2Le ",x[it]);
textcolor(10);cprintf("|");
printf("%10.2Le ",fx[it]);
textcolor(10);cprintf("|");

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

if(it % 2 == 0 )
{
textcolor(10);cprintf("|");
textcolor(2);cprintf("      Nilai Akar : %20.13Le", x[it]);
textcolor(10);cprintf("       |");cout<<endl;

}
}
while(it<=90 && fs>=epsilon);
textcolor(10);cprintf("================================================");cout<<endl;
cout<<endl;

textcolor(12);cprintf(" Nilai Akar : %20.13Le", x[it]);cout<<endl;
printf("   Selesai Pada Iterasi Ke- %d",it);cout<<endl;

getche();
}

Pemrograman (Metode Newton Rapshon)

#include<iostream.h>
#include<iomanip.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define epsilon 1E-15
main()
{
int p,it;
char lagi;
long double x, fx, f_x,fs,xl,fxl,f_xl;
awal:
clrscr();

textcolor(10);cprintf("========================================================================");cout<<endl;
textcolor(12);cprintf("                            NEWTON RAPHSON                              ");cout<<endl;
textcolor(10);cprintf("========================================================================");cout<<endl;
cout<<endl;
cout<<endl;
printf("Soal-soal dengan penyelesaian Metode Newton Repson : ");cout<<endl;
cout<<endl;
textcolor(12);cprintf("1. 3x-cos(x)=0");cout<<endl;
textcolor(12);cprintf("2. tan(x)=1-x");cout<<endl;
cout<<endl;
cout<<endl;
textcolor(10);cprintf("Ingin Jawaban Nomer Berapa ? ");cin>>p;cout<<endl;

if(p==1)
{
   clrscr();
    textcolor(2);cprintf("============================================================");cout<<endl;
    textcolor(12);cprintf("                     NEWTON  RAPHSON                       ");cout<<endl;
    textcolor(2);cprintf("============================================================");cout<<endl;
    cout<<endl;
    textcolor(12);cprintf("  Soal No. 1. 3x-cos(x)=0");cout<<endl;
   cout<<endl;
    textcolor(10);cprintf("==============================================================");cout<<endl;
    textcolor(10);cprintf("|");
    printf(" Iterasi ");
    textcolor(10);cprintf("|");
    printf("     x     ");
    textcolor(10);cprintf("|");
    printf("    f(x)   ");
    textcolor(10);cprintf("|");
    printf("   f'(x)   ");
    textcolor(10);cprintf("|");
    printf(" KETERANGAN ");
    textcolor(10);cprintf("|");cout<<endl;
    textcolor(10);cprintf("============================================================");cout<<endl;

    it=0;
    x=1;
    fx=(3*x)-cos(x*3.14/180);
    f_x=(3+sin(x*3.14/180));
    textcolor(10);cprintf("|");
    printf(" %4d    ",it);
    textcolor(10);cprintf("|");
    printf("%10.2Le ",x);
    textcolor(10);cprintf("|");
    printf("%10.2Le ",fx);
    textcolor(10);cprintf("|");
    printf("%10.2Le ",f_x);
    textcolor(10);cprintf("|");
    printf("            ");
    textcolor(10);cprintf("|");cout<<endl;

    do
    {
    it+=1;
    xl=x-(fx/f_x);
    fxl=(3*xl)-cos(xl*3.14/180);
    f_xl=(3+sin(xl*3.14/180));
    fs=fabs(xl-x);

    textcolor(10);cprintf("|");
    printf(" %4d    ",it);
    textcolor(10);cprintf("|");
    printf("%10.2Le ",xl);
    textcolor(10);cprintf("|");
    printf("%10.2Le ",fxl);
    textcolor(10);cprintf("|");
    printf("%10.2Le ",f_xl);
    textcolor(10);cprintf("|");

    x=xl;
    fx=fxl;
    f_x=f_xl;

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

    printf("   Nilai Akar : %20.17Le",xl);cout<<endl;
    printf("   Selesai Pada Iterasi Ke- %d",it);cout<<endl;

    textcolor(2);cprintf(" Masih Mau dengan Soal yang Lainnya ? [Y/T] : \n");

    lagi=getche();
    if(lagi=='Y' || lagi=='y')
    goto awal;

    getche();
    }
else if(p==2)
{
clrscr();
textcolor(2);cprintf("============================================================");cout<<endl;
textcolor(12);cprintf("                     NEWTON  RAPHSON                       ");cout<<endl;
textcolor(2);cprintf("============================================================");cout<<endl;
cout<<endl;
textcolor(12);cprintf("  Soal No. 2 : tan(x)=1-x");cout<<endl;
textcolor(10);cprintf("============================================================");cout<<endl;
textcolor(10);cprintf("|");
printf(" Iterasi ");
textcolor(10);cprintf("|");
printf("     x     ");
textcolor(10);cprintf("|");
printf("    f(x)   ");
textcolor(10);cprintf("|");
printf("   f'(x)   ");
textcolor(10);cprintf("|");
printf(" KETERANGAN ");
textcolor(10);cprintf("|");cout<<endl;
textcolor(10);cprintf("============================================================");cout<<endl;
it=0;
x=1;
fx =tan(x*3.14/180)-1+x;
f_x= 1/pow(cos(x*3.14/180),2)+1;
textcolor(10);cprintf("|");
printf(" %4d    ",it);
textcolor(10);cprintf("|");
printf("%10.2Le ",x);
textcolor(10);cprintf("|");
printf("%10.2Le ",fx);
textcolor(10);cprintf("|");
printf("%10.2Le ",f_x);
textcolor(10);cprintf("|");
printf("            ");
textcolor(10);cprintf("|");cout<<endl;

do
{
it+=1;
xl=x-(fx/f_x);
fxl= tan(xl*3.14/180)-1+xl;
f_xl=1/pow(cos(xl*3.14/180),2)+1;

fs=fabs(xl-x);

textcolor(10);cprintf("|");
printf(" %4d    ",it);
textcolor(10);cprintf("|");
printf("%10.2Le ",xl);
textcolor(10);cprintf("|");
printf("%10.2Le ",fxl);
textcolor(10);cprintf("|");
printf("%10.2Le ",f_xl);
textcolor(10);cprintf("|");

x=xl;
fx=fxl;
f_x=f_xl;

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

}
while(it<=90 && fs>=epsilon);
textcolor(10);cprintf("============================================================");cout<<endl;
cout<<endl<<endl;

printf("   Nilai Akar : %20.17Le",xl);cout<<endl;
printf("   Selesai Pada Iterasi Ke- %d",it);cout<<endl;

textcolor(2);cprintf(" Masih Mau dengan Soal yang Lainnya ? [Y/T] : \n");

lagi=getche();
if(lagi=='Y' || lagi=='y')
goto awal;

getche();
}
else
{
printf("Nomer Yang Anda Masukkan Tidak Terdaftar dalam Soal");cout<<endl;
textcolor(2);cprintf(" Masih Mau dengan Soal yang Lainnya ? [Y/T] : \n");

lagi=getche();
if(lagi=='Y' || lagi=='y')
goto awal;
}
getche();
}

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;

}

Pemrograman (Metode Bagi Dua )

Metode Bagi Dua  


#include<stdio.h>
#include<iomanip.h>
#include<conio.h>
#include<math.h>
#include<iostream.h>
#define epsilon 1E-13
main()
{
int it;
long double a=-1,b=2,T,fa,fb,fT,faT,e=2.718281828,KET;

cout<<"**************************************************************************";cout<<endl;
cout<<"          ANALISIS NUMERIK  / Metode Bagi Dua                              ";cout<<endl;
cout<<"**************************************************************************";cout<<endl;
printf("============================================================================");cout<<endl;
printf("| it|    a    |    b    |   f(a)  |   f(b)  |    T   |   f(T)  |f(a)f(T)| Ket |");cout<<endl;
printf("============================================================================");cout<<endl;

it=0;
fa=pow(e,a)-6*pow(a,2);
fb=pow(e,b)-6*pow(b,2);
T=(a+b)/2;
fT=pow(e,T)-6*pow(T,2);
faT=fa*fT;
printf("|%3d| %5.1Le| %5.1Le|%5.1Le |%5.1Le |%5.1Le | %5.1Le |%5.1Le |",it,a,b,fa,fb,T,fT,faT);cout<<endl;

do
{
if(faT<0)
{b=T;fT=fb;}
else
{a=T;fT=fa;}

it=it+1;
T=(a+b)/2;
fT=pow(e,T)-6*pow(T,2);
faT=fa*fT;
KET=fabs(fT);

printf("|%3d| %5.1Le| %5.1Le|%5.1Le |%5.1Le | %5.1Le | %5.1Le |%5.1Le |",it,a,b,fa,fb,T,fT,faT);
if(KET<=epsilon)
{printf("SELESAI|");}
else
{cout<<"LANJUT |";}
cout<<endl;
}
while(it<=100 && fabs(fT)>=epsilon);
printf("============================================================================");cout<<endl;
printf("==> Jadi nilai akarnya ( %3.5Le ) pada iterasi ke %3d .",T,it);

getche();
}

Pemrograman (Metode Posisi Palsu)

Pada kesempatan ini saya akan membagikan artikel mengenai Bahasa pemrograman yaitu bahasa C++  dimana dalam bahasa C++ kita sapat menjumpai Program Borland C++ yang di gunakan Misalnya kawan ada mata kuliah nya Analisa Numerik Atau Komputasi di Perguruan Tinggi yang Kawan kawan tempati. Dalam Hal ini saja akan Membagikan tentang Metode Posisi Palsu.


#include<iostream.h>
#include<iomanip.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define epsilon 1E-13     
main()
{
long double a,b,c,f_a,f_b,f_c,f_ac,ffac;
int max=100;
int it;
char lagi;

awal:
clrscr();
it=-1;
textcolor(13);cprintf("======================================");
textcolor(10);cprintf("=");
textcolor(13);cprintf("========================================");cout<<endl;
textcolor(10);cprintf("=============================");
textcolor(12);cprintf(" Metode Posisi Palsu ");
textcolor(10);cprintf("=============================");cout<<endl;
textcolor(13);cprintf("======================================");
textcolor(10);cprintf("=");
textcolor(13);cprintf("========================================");cout<<endl;
cout<<endl;
cout<<endl;
textcolor(10);cprintf("                              2");cout<<endl;
textcolor(12);cprintf(" Persamaan yang digunakan : ");textcolor(10);cprintf(" X  + X - 3");cout<<endl;cout<<endl;
textcolor(10);cprintf(" Nilai Eror : ");cout<<epsilon<<endl<<endl;
textcolor(14);cprintf("Coba Dengan");textcolor(10);cprintf(" a=1");
textcolor(14);cprintf(" dan ");textcolor(12);cprintf("b=3 ");cout<<endl;;cout<<endl;
textcolor(10);cprintf("Masukkan Nilai a : ");cin>>a;cout<<endl;
textcolor(12);cprintf("Masukkan Nilai b : ");cin>>b;cout<<endl;
cout<<endl;
   textcolor(10);cprintf("================================================================================");cout<<endl;
    textcolor(10);cprintf("|");textcolor(11);cprintf(" No ");
   textcolor(10);cprintf("|");textcolor(12);cprintf("    a    ");
   textcolor(10);cprintf("|");textcolor(13);cprintf("    b    ");
   textcolor(10);cprintf("|");textcolor(14);cprintf("    c    ");
   textcolor(10);cprintf("|");textcolor(15);cprintf("   F(a)   ");
   textcolor(10);cprintf("|");textcolor(9);cprintf("   F(b)   ");
   textcolor(10);cprintf("|");textcolor(7);cprintf("   F(c)   ");
   textcolor(10);cprintf("|");textcolor(19);cprintf(" F(a)xF(c)");
   textcolor(10);cprintf("|");cout<<endl;
    textcolor(10);cprintf("================================================================================");cout<<endl;


   do
       {

      it+=1;
      f_a=pow(a,2)+a-3;
        f_b=pow(b,2)+b-3;
       c=((a*f_b)-(b*f_a))/(f_b-f_a);
      f_c=pow(c,2)+ c-3;
      f_ac=f_a*f_c;
      ffac=fabs(f_ac);



      textcolor(10);cprintf("|");textcolor(11);cprintf("%3d ",it);
      textcolor(10);cprintf("|");textcolor(12);cprintf("%9.2Le",a);
      textcolor(10);cprintf("|");textcolor(13);cprintf("%9.2Le",b);
      textcolor(10);cprintf("|");textcolor(14);cprintf("%9.2Le",c);
      textcolor(10);cprintf("|");textcolor(15);cprintf("%10.2Le",f_a);
      textcolor(10);cprintf("|");textcolor(9);cprintf("%10.2Le",f_b);
      textcolor(10);cprintf("|");textcolor(7);cprintf("%10.2Le",f_c);
      textcolor(10);cprintf("|");textcolor(19);cprintf("%10.2Le",ffac);
      textcolor(10);cprintf("|");
      cout<<endl;
      if(f_ac<=0)
         {
         b=c,f_b=f_c;
         }
         else
         {
         a=c;f_a=f_c;
         }
         }
   while(it<=max && fabs(f_c) >= epsilon);
       if(it<=max)
       {
      textcolor(10);cprintf("================================================================================");cout<<endl;
      textcolor(10);cprintf(" Hampiran (Pendekatan) Nilai ");
      textcolor(12);cprintf("x = %2.13Le ",c);cout<<endl;
               }
      else
      {
      textcolor(10);cprintf("================================================================================");cout<<endl;
      textcolor(10);cprintf(" hampiran tidak mencukupi... tambah nilai toleransi batas ");
      cout<<endl;
        }

      textcolor(2);cprintf(" Masih Mau dengan Epsilon yang Berbeda ? [Y/T] : \n");

        lagi=getche();
        if(lagi=='Y' || lagi=='y')

        goto awal;
getche();
}