Finding roots of imaginary

If we are to understand how to find roots of quadratic equations course, we can determine the roots of imaginary.

Imaginary number is a number that has the properties i 2 = -1, Numbers are usually part of complex numbers. In addition to the imaginary part, complex numbers have the real numbers, by definition, (the) imaginary number i is obtained from solving a quadratic equation.

Algorithm Quadratic Equations and imaginary roots :

Reading A, B, and C, and then calculates the roots of a quadratic equation Ax ^ 2 Bx C = 0 by determining the value of disc = B * B-4 * A * C first then later look for the roots of the quadratic equation and the roots imaginer.


A, B, C       : integer           {koefisien-koefisien persamaan}

disk          : longint           {nilai diskriminan}

x1, x2 : real                     {nilai-nilai akar untuk disk>=0}
XRiil,Ximaginer : float


read (A, B, C)

disk ß B*B– 4*A*C

if (A = 0) then write (‘Bukan Persamaan Kuadrat’)

else if disk > 0 then

x1 ß-B + sqrt (disk)/2*A

x2 ß-B – sqrt(disk)/2*A

else if disk = 0 then

x1 ß-B/2*A

x2 ß x1

else XRiil ß -b/(2*a)

XImaginer ß sqrt(-D)/(2*a);

end if

program C++
#include <iostream.h> #include <conio.h> #include <fstream.h> class Persamaan{ friend istream& operator>>(istream&, Persamaan&); friend ostream& operator<<(ostream&, Persamaan&); public: void proses(); void HitungPers1(); void HitungPers2(); void HitungPers3(); private: float a,b,c,D,X,X1,X2,XRiil,XImajiner; }; istream& operator>>(istream& input, Persamaan& Masukan){ cout<<" \t\t PROGRAM MENCARI AKAR PERSAMAAN KUADRAT \n\n"; cout<<" Perhitungan akar-akar persamaan aX2+bX+c= 0\n"; cout<<"Masukkan nilai koefisien a,b,dan c\n"; cout<<"Nilai a: "; input>>Masukan.a; cout<<"Nilai b: "; input>>Masukan.b; cout<<"Nilai c: "; input>>Masukan.c; } ostream& operator<<(ostream& output, Persamaan& Keluaran){ output<<"Akar Persamaan "<<Keluaran.a<<"X2 + "<<Keluaran.b<<"X + "<<Keluaran.c<<"= 0 adalah\n"; if(Keluaran.D>0){Keluaran.HitungPers1();} else if(Keluaran.D==0){Keluaran.HitungPers2();} else{Keluaran.HitungPers3();} } void Persamaan::proses(){ D = b*b-4*a*c; cout<<"Diskriminan =\n "<<D<<endl; } void Persamaan::HitungPers1(){ X1 = (-b+sqrt(D))/(2*a); X2 = (-b-sqrt(D))/(2*a); cout<<" X1 =\n "<<X1; cout<<" X2 =\n "<<X2; } void Persamaan::HitungPers2(){ X = -b/(2*a); cout<<" X1 = X2 = \n"<<X; } void Persamaan::HitungPers3(){ XRiil = -b/(2*a); XImajiner = sqrt(-D)/(2*a); cout<<" Akar imajiner:\n "; cout<<" X1 = "<<XRiil<<"+"<<XImajiner<<"*i\n "; cout<<" X2 = "<<XRiil<<"-"<<XImajiner<<"*i\n "; } int main { Persamaan x; x.proses(); x.HitungPers1(); x.HitungPers2(); x.HitungPers3(); getch(); return 0; }


  1. No trackbacks yet.

Leave a Reply

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

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

%d bloggers like this: