Menu

  • 0812 7124 5514
  • 0878 9929 7914
  • Pin BB 587FBF31
  • frwebhost@gmail.com

FR-System

Detail Artikel

Home/ Metode Numerik/Detail Artikel

Pemrograman Metode Bisection Menggunakan QBasic

SATU:

CLS

SCREEN 0

COLOR 3,0,0

CLS

LOCATE 2,8:PRINT CHR$(201); STRING$(58,205); CHR$(187)

FOR I = 3 TO 22

LOCATE i, 8: PRINT CHR$(186); STRING$(58,” ”);CHR$(186)

NEXT i

LOCATE 23,8:PRINT CHR$(200); STRING$(58,205); CHR$(188)

COLOR 3,0,0

LOCATE 3,12:PRINT “=================================================”

LOCATE 4,12:PRINT ” PROGRAM MENCARI AKAR PERSAMAAN “

LOCATE 5,12:PRINT “ Oleh : Ferdian Rahabista “

LOCATE 6,12:PRINT “ Metode : BISECTION “

LOCATE 7,12:PRINT “=================================================”

DEF fnz(x) = 3*x^3+4*x-7

LOCATE 9,10: PRINT “Bentuk Fungsinya :f(x)=3*x^3+4*x-7”

LOCATE 10,10: PRINT “Buat Pendugaan akar ini pada selang [a,b]”

btanda = 10

WHILE(btanda <> 1)

LOCATE 12,10: PRINT “input nilai a = “

LOCATE 13,10: PRINT “input nilai b = “

LOCATE 14,10: PRINT “input nilai toleransi = “

LOCATE 12,10: PRINT “isikan nilai a =”,a

LOCATE 13,10: PRINT “isikan nilai b =”,b

IF a>b THEN

LOCATE 15,15: PRINT “Nilai a harus kurang dari b”

INPUT “”,BOM

GOTO SATU:

END IF

LOCATE 14,10: INPUT “inputan nilai toleransi =”,tol

 

IF tol = 0 THEN

LOCATE 15,15: PRINT “Nilai tol harus diisi”

INPUT “”,BOM

GOTO SATU:

END IF

h = 01

n = ABS((b-a)/h)

btanda = 0

tanda1 = SGN(fnz(a))

FOR i=1 TO n+1

tanda2=SGN(fnz(h*(i-1)+a))

‘PRINT h*(-1) + a,tanda2

If tanda1 <> tanda2 THEN

IF tanda1 <> 0 THEN

Btanda=btanda+1

END IF
tanda1=tanda2

END IF
NEXT i

IF btanda = 0 THEN

LOCATE 16,10: PRINT “pada selang [“; a; “,”;b;”] tidak terdapat”

COLOR 18,8,0: LOCATE 18,18: PRINT “mohon inputkan a&b diulang”

COLOR 3,0,0

ELSE

IF btanda > 1 THEN

‘LOCATE 16,10: PRINT “pada selang [“;a;”,;b;” : PRINT USING “]”;

‘COLOR 18,8,0: LOCATE 18,18: PRINT “mohon inputkan a&b diulang”

‘COLOR 3,0,0

‘ LOCATE 20,20: INPUT “ulangi dengan menekan <<enter>>”,put$

‘LOCATE 20,20: PRINT “”

END IF

ELSE

LOCATE 16,10: PRINT “tepat, pada selang [“;a;”,”;b;”: PRINT USING “]”;

LOCATE 17,10: PRINT “”

COLOR 18,8,0:LOCATE 18,18: PRINT “anda benar memasukkan selang nilai”

COLOR 3,0,0

LOCATE 20,20: PRINT “isikan nilai toleransi unutk f(x)”

END IF

WEND

COLOR 3,0,0

LOCATE 12,10: PRINT USING “nilai a=###.###”;a

LOCATE 13,10: PRINT USING “nilai b=###.###”;b

LOCATE 14,10: PRINT USING “toleransi=###.###”;tol

LOCATE 18,18: PRINT “”

LOCATE 20,20: PRINT “”

CLS

PRINT “mencari akar dengan metode BISECTION”

PRINT “bentuk fungsinya : f(x)=3*x^3+4*x-7”

PRINT”nilai toleransi tol =”;tol

C$=”###:##.##### :##.##### :##.##### :##.##### :##.##### :##.##### :”

PRINT “=================================================”

PRINT “iter: a : b : f(a) : f(b) : c : f(c) :”

PRINT”---------------------------------------------------------------------------------------“

Iter=0

Y=tol

WHILE(ABS(y)>=tol)

C=(a+b)/2

‘c=a-fnz(a)*(b-a)/(fnz(b)-fnz(a))

Y=fnz(c)

PRINT USING c$; iter, a, b, fnz(a), fnz(b), c, fnz(c)

Iter = iter+1

IF(fnz(a)*fnz(c)>0) THEN

A = c

ELSE

b=c

END IF

WEND

PRINT “=================================================”

PRINT USING “nilai akar = ##.##### pada x = ##.#####”; fnz(c),c

PRINT USING”jumlah iterasi =#### kali”;iter

COLOR 3,0,0: PRINT “jika anda telah puas, tekan <<enter>>”

LG$ = “Y”

INPUT “COBA LAGI (Y/T);”,LG$

IF LG$ = “Y” OR LG$ = “y” THEN

GOTO SATU:

ELSE

END IF

Artikel Lainnya

Komentar Anda

syYXm

2 Komentar

FR-SYSTEM.WEB.ID

13-11-2011 | 03:01:41 contact@fr-system.web.id
di internet banyak yg ngebahas tentang itu, tetapi biasanya menggunakan Bahasa C, ya tinggal di logikakan saja ke Qb

Envory

21-10-2011 | 10:12:34 envorydamnation@gmail.com
GAN kalo bikin * ** *** **** ***** GMANA gan scrip na di QB

Produk Kami

Popular Post

Facebook Page

Statistik Pengunjung

  • Hari ini
    :
    442
  • Kemarin
    :
    745
  • Bulan ini
    :
    11396
  • Tahun ini
    :
    185517
  • Total
    :
    1184729
  • Hits Count
    :
    2381935
  • Now Online
    :
    2 Users