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;

}

nnn

·         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

 

 

1.       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

bbbbbb

 

1.      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=”<<“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;

}

 

 

 

 

 

dddd

x

f(x)

2

49

1

16

0

5

-1

0

-2

1

eeeeeeee

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=”<<“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;

}

 fffff

ggggg

 

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=”<<“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;

}

hhhhh

  iiiiii

 

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=”<<“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;

}

 jjjj1

Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s


%d bloggers like this: