penambahan 2 matrik

January 12, 2009

matriks a ordo 2 x 3

#include<iostream>
using namespace std;
int main (){
int a[2][3];
a[0][0]=4;
a[1][0]=5;
a[0][1]=2;
a[1][1]=7;
a[0][2]=3;
a[1][2]=6;

for(int i=0;i<2;i++){
for (int j=0;j<3;j++){
cout<<a[i][j];}
cout<<endl;
}

return 0;
}

gg22

matriks b 0rdo 2 x 3

#include<iostream>
using namespace std;
int main (){
int b[2][3];
b[0][0]=1;
b[1][0]=3;
b[0][1]=8;
b[1][1]=5;
b[0][2]=5;
b[1][2]=4;
for(int i=0;i<2;i++){
for(int j=0;j<3;j++){
cout<<b[i][j];}
cout<<endl;
}
return 0;
}

vv2

penambahan 2 matrik

January 12, 2009

#include<iostream>
using namespace std;
int main (){
int a[1][2];
a[0][0]=4;
a[1][0]=3;
a[0][1]=2;
a[1][1]=7;
a[0][2]=3;
a[1][2]=6;

for(int i=0;i<2;i++){
for (int j=0;j<3;j++){
cout<<a[i][j];}
cout<<endl;
}

gg1

metode biseksi edisi lanjutan

January 8, 2009

ini telah saya perbaiki metode biseksi

listing  programnya adalah:

#include<iostream>
using namespace std;
int main(){
int i;
float fx,fa,fb;
float a,b;
float xbaru;
a=-1;
b=0;
for(i=0;i<10;i++)
{
fa=(a*a)-(4*a)-5;
fb=(b*b)-(4*b)-5;
if(fa*fb>0)
{
cout<<“berhenti”;
}
else
{
xbaru=(a+b)/2;
fx=xbaru*(xbaru)-(4*xbaru)-5;
if(fx*fa<0)
{
b=xbaru;
}else{
a=xbaru;
}
}
cout <<fx<<”   “<<fa<<endl;
}
return 0;
}

z52

metode biseksi

January 8, 2009

<!– /* Font Definitions */ @font-face {font-family:”Cambria Math”; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:””; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:”Calibri”,”sans-serif”; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:”Times New Roman”; mso-bidi-theme-font:minor-bidi;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:”Times New Roman”; mso-bidi-theme-font:minor-bidi;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} –>


/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:””;
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:”Calibri”,”sans-serif”;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:”Times New Roman”;
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}

#include<iostream>

using namespace std;

int main(){

int i;

float fx,fa,fb;

float a,b;

float xbaru;

a=-1;

b=0;

for(i=0;i<10;i++)

{

<!– /* Font Definitions */ @font-face {font-family:”Cambria Math”; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:””; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:”Calibri”,”sans-serif”; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:”Times New Roman”; mso-bidi-theme-font:minor-bidi;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:”Times New Roman”; mso-bidi-theme-font:minor-bidi;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} –>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:””;
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:”Calibri”,”sans-serif”;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:”Times New Roman”;
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}

fa=(a*a)-(4*a)-5;

fb=(b*b)-(4*b)-5;

if(fa*fb>0)

{

fevi-r

cout<<“berhenti”;

}

else

{

xbaru=(a+b)/2;

fx=xbaru*(xbaru)-(4*xbaru)-5;

if(fx*fa<0)

{

b=xbaru;

}else{

a=xbaru;

}

}

cout <<fx<<“ “<<fa<<endl;

}

return 0;

}

Form Laporan Akhir

January 6, 2009

NAMA                            : FEVI RIZQIAH

NIM                                : 0608102010009

Judul Percobaan             : Penyelesaian Persamaan Non Linear

 

·         Algoritma :

1.      Nilai a = 1, b= -4, c= -5

2.      Jika a dan b adalah nol maka tidak ada penyelesaian

3.      Jika a adalah nol, maka akarnya hanya satu (-c/b)

4.      Jika (b2 – 4ac) adalah negative, maka tidak ada akar yang real

5.                Jika dalam bentuk selain di atas, maka terdapat dua akar, yaitu x1 dan x2

·         Listing program yang benar:

#include <iostream>

#include <cmath>

using namespace std;

int main ( )

{

                               int a=1;

                               int b=-4;

                               int c=-5;

                               int d;

                               int x1;

                               int x2;

                               cout <<“a=”<<a<<“b=”<<“c=”<<c<<endl;

                               if (a==0 && b==0){

                                    cout <<“maka tidak ada akar”<<endl;

                               }else{

                                    if (a==0){

                                                x1=(-c/b);

                                                cout <<“x1=”<<x1<<endl;

                                    }else{

                                                d=((b*b)-(4*a*c));

                                                if (d<0){

                                                            cout <<“imaginer”<<endl;

                                                }else{

                                                            x1=((-b+sqrt(d))/(2*a));

                                                            x2=((-b-sqrt(d))/(2*a));

                                                            cout<<“x1=”<<x1<<endl;

                                                            cout<<“x2=”<<x2<<endl;

                                                }

                                    }

                               }

                               return 0;

}

 gambar

·         Pengamatan awal:

1.      Persamaan  x2 – 4x – 5 = 0, diselesaikan dengan perfaktoran

x2 – 4x – 5 = 0

(x – 5) (x + 1) = 0

X1– 5 = 0 dan x2 + 1 = 0

         X1= 5  dan       x2 = -1

 

·         Hasil Percobaan:

1.      Printscreent hasil dari program yang dijalankan

 

 

 

 

 

 

gambar21

2.       Dapatkan X1 dan x2 beserta grafik dengan persamaan x2 – 4x – 5 = 0

 

 

 

 

 

 

 

 

 

 

           

x

F(x)

6

7

5

0

4

-5

3

-8

2

-9

1

-8

0

-5

-1

0

-2

7

-3

16

gambar3

 

 

3.      Dapatkan X1 dan x2 beserta grafik dengan persamaan ax+bx-c=0, menggunakan progam;

 

No

a

b

d

X1

X2

1

3

8

5

-1

-1

2

-6

7

8

0

1

3

0

9

-10

1

0

4

0

0

11

Tidak ada akar

Tidak ada akar

 

Penyelesaian:

1.

#include <iostream>

#include <cmath>

using namespace std;

int main ( )

{

     int a=3;

     int b=8;

     int c=5;

     int d;

     int x1;

     int x2;

     cout <<“a=”<<a<<“b=”<<b<<“c=”<<c<<endl;     

if (a==0 && b==0){

            cout <<“maka tidak ada akar”<<endl;

     }else{

            if (a==0){

                        x1=(-c/b);

                        cout <<“x1=”<<x1<<endl;

            }else{

                        d=((b*b)-(4*a*c));

                        if (d<0){

                                    cout <<“imaginer”<<endl;

                        }else{

                                    x1=((-b+sqrt(d))/(2*a));

                                    x2=((-b-sqrt(d))/(2*a));

                                    cout<<“x1=”<<x1<<endl;

                                    cout<<“x2=”<<x2<<endl;

                        }

            }

     }

     return 0;

}

gambar42

x

f(x)

2

49

1

16

0

5

-1

0

-2

1

 

 

gambar61

 

 

 

2. #include <iostream>

#include <cmath>

using namespace std;

int main ( )

{

            int a=-6;

            int b=7;

            int c=8;

            int d;

            int x1;

            int x2;

            cout <<“a=”<<a<<“b=”<<b<<“c=”<<c<<endl;

            if (a==0 && b==0){

                        cout <<“maka tidak ada akar”<<endl;

            }else{

                        if (a==0){

                                    x1=(-c/b);

                                    cout <<“x1=”<<x1<<endl;

                        }else{

                                    d=((b*b)-(4*a*c));

                                    if (d<0){

                                                cout <<“imaginer”<<endl;

                                    }else{

                                                x1=((-b+sqrt(d))/(2*a));

                                                x2=((-b-sqrt(d))/(2*a));

                                                cout<<“x1=”<<x1<<endl;

                                                cout<<“x2=”<<x2<<endl;

                                    }

                        }

            }

            return 0;

}

gambar15

 

gambar8

3. #include <iostream>

#include <cmath>

using namespace std;

int main ( )

{

       int a=0;

       int b=9;

       int c=-10;

       int d;

       int x1;

       int x2;

       cout <<“a=”<<a<<“b=”<<b<<“c=”<<c<<endl;

       if (a==0 && b==0){

            cout <<“maka tidak ada akar”<<endl;

       }else{

            if (a==0){

                        x1=(-c/b);

                        cout <<“x1=”<<x1<<endl;

            }else{

                        d=((b*b)-(4*a*c));

                        if (d<0){

                                    cout <<“imaginer”<<endl;

                        }else{

                                    x1=((-b+sqrt(d))/(2*a));

                                    x2=((-b-sqrt(d))/(2*a));

                                    cout<<“x1=”<<x1<<endl;

                                    cout<<“x2=”<<x2<<endl;

                        }

            }

       }

       return 0;

}

 gambar161gambar17

 

 

4. #include <iostream>

#include <cmath>

using namespace std;

int main ( )

{

       int a=0;

       int b=0;

       int c=11;

       int d;

       int x1;

       int x2;

       cout <<“a=”<<a<<“b=”<<b<<“c=”<<c<<endl;

       if (a==0 && b==0){

            cout <<“maka tidak ada akar”<<endl;

       }else{

            if (a==0){

                        x1=(-c/b);

                        cout <<“x1=”<<x1<<endl;

            }else{

                        d=((b*b)-(4*a*c));

                        if (d<0){

                                    cout <<“imaginer”<<endl;

                        }else{

                                    x1=((-b+sqrt(d))/(2*a));

                                    x2=((-b-sqrt(d))/(2*a));

                                    cout<<“x1=”<<x1<<endl;

                                    cout<<“x2=”<<x2<<endl;

                        }

            }

       }

       return 0;

}

gambar10

4. #include <iostream>

#include <cmath>

using namespace std;

int main ( )

{

       int a=0;

       int b=0;

       int c=11;

       int d;

       int x1;

       int x2;

       cout <<“a=”<<a<<“b=”<<b<<“c=”<<c<<endl;

       if (a==0 && b==0){

            cout <<“maka tidak ada akar”<<endl;

       }else{

            if (a==0){

                        x1=(-c/b);

                        cout <<“x1=”<<x1<<endl;

            }else{

                        d=((b*b)-(4*a*c));

                        if (d<0){

                                    cout <<“imaginer”<<endl;

                        }else{

                                    x1=((-b+sqrt(d))/(2*a));

                                    x2=((-b-sqrt(d))/(2*a));

                                    cout<<“x1=”<<x1<<endl;

                                    cout<<“x2=”<<x2<<endl;

                        }

            }

       }

       return 0;

}

gambar11gambar9

 

 

Hello world!

December 30, 2008

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!