jawaban

download
1.      Coba anda cari In 4 dengan metode interpolasi linier berdasarkan data In 2 dan In 8. Dan bandingkan dengan data In 2 dan In 10. Untuk membandingkan hasil yang diperoleh, maka ketahui terlebih dahulu nilai eksak dari In 4 itu berapa? 

                                                                               
#include <iostream.h>
#include <conio.h>
void main()
{
float fln2=0.693147,fln8=2.079441,fln10=2.302585;
float fx1,fx2,et1,et2,eksak=1.386294;
int ln2=2,ln8=8,ln10=10;
int x0=ln2,x1=ln8,x10=ln10,x;
{
cout<<"Nilai eksak dari ln 4 adalah  = 1.386294"<<endl;
cout<<"________________________________________\n\n"<<endl;
cout<<"------------------------------------------"<<endl;
cout<<"masukkan nilai Ln yang akan di cari : ";cin>>x;
cout<<"------------------------------------------\n\n"<<endl<<endl;
{                                                           
fx1=fln2+((fln8-fln2)/(x1-x0))*(x-x0);//berdasarkan ln2 dan ln8
{
fx2=fln2+((fln10-fln2)/(x10-x0))*(x-x0);
{
et1=((eksak-fx1)/(eksak))*100;
{
et2=((eksak-fx2)/(eksak))*100;
cout<<"Nama : Fiki irawan (3105111060)\n"<<endl;
cout<<"\thasil ln4 dengan METODE INTERPOLASI LINIER"<<endl;
cout<<"___________________________________________________________"<<endl;
cout<<"| berdasarkan  |         fx           |         Et        | "<<endl;
cout<<"-----------------------------------------------------------"<<endl;
cout<<"|ln 2 dan ln 8 |""\t"<<fx1;cout<<"\t\t\t"<<et1<<"%"<<endl;
cout<<"|ln 2 dan ln 8 |""\t"<<fx2;cout<<"\t\t\t"<<et2<<"%"<<endl;
}}}}} getch();}



2.
#include <iostream.h>
#include <conio.h>

void main()
{
int x0=3, x1=7, x2=9;
long double fx0=1.098612289, fx1=1.945910149, fx2=2.197224577;
long double et, eksak=1.386294361;
long double a,b,c,b0,b1,b2,f2;
{
b0=fx0;
b1=(fx1-fx0)/(x1-x0);
a=(fx2-fx1);
b=((fx1-fx0)/(x1-x0))*(x2-x1);
c=((x2-x0)*(x2-x1));
b2=(a-b)/c;
f2=fx0+b1*(4-3)+b2*(4-3)*(4-7);
et=((eksak-f2))/(eksak)*100;
{
cout<<"diketahui xo = "<<x0<<"\t\t\t""f(x0) = "<<fx0<<endl;
cout<<"diketahui xo = "<<x1<<"\t\t\t""f(x0) = "<<fx1<<endl;
cout<<"diketahui xo = "<<x2<<"\t\t\t""f(x0) = "<<fx2<<endl<<endl;
cout<<"___________________________________"<<endl;
cout<<"dicari ln 4 dengan eksak = "<<eksak<<endl;
cout<<"___________________________________"<<endl<<endl<<endl;
cout<<"Nama : Fiki irawan (3105111060)"<<endl;
cout<<"hasilnya ="<<endl;                                 
cout<<"----------------------------------------------------------"<<endl;
cout<<"|   b1       |      b2      |     f2(4)      |    et     |"<<endl;
cout<<"----------------------------------------------------------"<<endl;
cout<<b1<<"\t"<<b2<<"\t"<<f2<<"\t\t"<<et<<endl;

}
getch();}}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
3.
#include <iostream.h>                                  
#include <conio.h>

void main()
{
float x0=1,x1=4,x2=6,x3=9;
long double fx0=0, fx1=1.386294361, fx2=1.791759469, fx3=2.197224577;
long double eksak=0.6931471806,fx1x0,fx2x1,fx3x2,fx2x1x0,fx3x2x1;
long double b0,b1,b2,b3,f3,et;
double a,b,c,d;
{
//pembagian hingga pertama
fx1x0=(fx1-fx0)/(x1-x0);
fx2x1=(fx2-fx1)/(x2-x1);
fx3x2=(fx3-fx2)/(x3-x2);
{
// pembagian hingga kedua
fx2x1x0=(fx2x1-fx1x0)/(x2-x0);
fx3x2x1=(fx3x2-fx2x1)/(x3-x0);
{
b0=fx0;
b1=fx1x0;
b2=fx2x1x0;
b3=fx3x2x1;
{
a=(b0+b1)*(2-1);
b=(b2)*(2-4)*(2-1);
c=b3*((2-1)*(2-4)*(2-6));
f3=a+b+c;
et=((eksak-f3)/eksak)*100;
{
cout<<"diketahui :"<<endl;
cout<<" x0: "<<x0<<"\t\tfx0 : "<<fx0<<endl;
cout<<" x1: "<<x1<<"\t\tfx0 : "<<fx1<<endl;
cout<<" x2: "<<x2<<"\t\tfx0 : "<<fx2<<endl;
cout<<" x3: "<<x3<<"\t\tfx0 : "<<fx3<<endl<<endl;

cout<<"hasil pembagian hingga pertama dan kedua"<<endl;
cout<<"b0 : "<<b0<<endl;
cout<<"b1 : "<<b1<<endl;
cout<<"b2 : "<<b2<<endl;
cout<<"b3 : "<<b3<<endl<<endl;
cout<<"Nama : Fiki irawan (3105111060)"<<endl;
cout<<"hasil"<<endl;
cout<<"-----------------------------"<<endl;
cout<<"|   f3        |     et      |"<<endl;
cout<<"-----------------------------"<<endl;
cout<<f3<<"\t"<<et<<"%"<<endl;
}}}} }
getch();}


4.
#include <iostream.h>
#include <conio.h>

void main()
{
float x0=1,x1=6,x2=7;
long double fx0=0,fx1=1.791759469,fx2=1.945910149;
long double eksak=0.6931471806,f1,f2,et1,et2,a,b,ln2=2;
long double a1,b1,c1;
{
a=((ln2-x1)/(x0-x1))*(fx0); //order satu fiki
b=((ln2-x0)/(x1-x0))*(fx1);
f1=a+b;
{
a1=(((ln2-x1)/(x0-x1))*((ln2-x2)/(x0-x2)))*fx0;  // order dua fiki
b1=(((ln2-x0)/(x1-x0))*((ln2-x2)/(x1-x2)))*fx1;
c1=(((ln2-x0)/(x2-x0))*((ln2-x1)/(x2-x1)))*fx2;
f2=a1+b1+c1;
{
et1=((eksak-f1)/(eksak))*100;
et2=((eksak-f2)/(eksak))*100;

cout<<"INTERPOLASI LAGRANGE ORDER SATU DAN DUA"<<endl;
cout<<"nama : fiki irawan"<<endl;
cout<<"nim  : 3105111060"<<endl;
cout<<"diketahui : "<<endl;
cout<<"x0 : "<<x0<<"\t\t"<<"f(x0) : "<<fx0<<endl;
cout<<"x1 : "<<x1<<"\t\t"<<"f(x1) : "<<fx1<<endl;
cout<<"x2 : "<<x2<<"\t\t"<<"f(x2) : "<<fx2<<endl<<endl;
cout<<"------------------------------------------"<<endl;
cout<<"dicari ln2 dengan nilai eksak 0.6931471806"<<endl<<endl;
cout<<"------------------------------------------"<<endl<<endl;
cout<<"hasilnya : "<<endl;
cout<<"___________________________________________"<<endl;
cout<<"|  Order      |    f1(2)     |     et     |"<<endl;
cout<<"-------------------------------------------"<<endl;
cout<<"  satu\t\t"<<f1<<"\t"<<et1<<"%"<<endl;
cout<<"  dua \t\t"<<f2<<"\t"<<et2<<"%"<<endl;
}}}
getch();}


Popular posts from this blog

Menampilkan tanggal fastreport delphi

Android C2DM (Cloud to Device Message) adalah

Menambahkan data pada TreeView delphi dari database mysql