Program Interpolasi Linier Dengan C++


#include <stdio.h>
#include <math.h>

float a, c, b, F_a, F_c, F_b, tol;
int max_iter;
float f(float x)
{
return ((x*x)*x) + (x*x)- (3*x) – 3;
}

void main ()
{
int it;
float epsilon;
printf(” METODE REGULASI FALSI”);
printf(“\n”);
printf(“Contoh Soal\n”);
printf(“3*x*x – 2*x – 5 \n\n”);
printf(“Masukkan Batas Bawah :”);
scanf(“%f”,&a);
printf(“Masukkan Batas Atas :”);
scanf(“%f”,&b);
printf(“Masukkan Toleransi Error :”);
scanf(“%f”,&tol);

it = 0;
F_a = f(a);
F_b = f(b);
if(F_a * F_b > 0) printf(” Nilai F(a) x F(b) > 0\n”);
else
{
printf(“\n”);
printf(” I a f(a) b f(b) c f(c)\n\n”);
do
{
it = it +1;
c = a – F_a * (b-a) / (F_b – F_a);
F_c = f(c);
printf(“%2d %7.5f %7.5f %7.5f %7.5f %7.5f %7.2e\n\n”,it, a, F_a, b, F_b, c,fabs(F_b-F_a)/2);
epsilon = fabs(c-a);
if(F_a * F_c <=0){ b = c; F_b = F_c; }
else
{
a=c;
F_a=F_c;
}
}

while(epsilon > tol);
if(epsilon <=tol)
{
printf(“\n”);
printf(“\n”);
printf(“Toleransi terpenuhi\n”);
printf(“\n”);
printf(“Hasil akhir=%g\n\n\n”,c);

}

else
printf(“Toleransi tidak terpenuhi\n”);
}

}

Untuk Sorce Codex Bisa di download disini

Password : dreamer

2 responses to “Program Interpolasi Linier Dengan C++

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s