0% found this document useful (0 votes)
49 views1 page

Metode Biseksi untuk Mencari Akar

The document describes a bisection method for finding roots of a function, including error handling for input parameters. It defines a function 'f' and plots the function along with its roots using specified tolerance levels. The code includes iterations for refining the root estimates and visualizing the results.

Uploaded by

Xyzer Skipping
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views1 page

Metode Biseksi untuk Mencari Akar

The document describes a bisection method for finding roots of a function, including error handling for input parameters. It defines a function 'f' and plots the function along with its roots using specified tolerance levels. The code includes iterations for refining the root estimates and visualizing the results.

Uploaded by

Xyzer Skipping
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#1.

RUMUS KUADRAT

{ stop('x1 must have length equal to 1.')}


if ( tol < 1.0e-17) { tol = 1.0e-17} #if tol less -17 make it -17
if ( ![Link]([Link]) ) { stop( '[Link] must be numeric.')}
if ( [Link] < 1 ) { stop( '[Link] must be positive.')}

[Link] = 0

a=x0
b=x1
i=0
tol=tol
if (f(a)*f(b) > 0 ) { stop('f function do not bracket root beween a and b.')}
options(digits=20)
while((abs(b-a) > tol) && (i < [Link]) ) ###((a+b)/2)!

From Winsy Weku to Everyone: 09:55 AM

tf(output, fmt = '%#.7f')


return( list('roots' = m, '[Link]' = f(m), '[Link]' = i, 'tol'=tol))#returning values
i<-i+1
}

f<-function(x) {2*x*cos(2*x) - (x+1)^2}

plot(x,(2*x*cos(2*x) - (x+1)^2), ylab="fungsi",xlab="x", main="Metode Biseksi")


abline(h=0,v=0,lty="dashed",col="blue")
akar<-[Link](f, -1, 0, tol = 1e-10)
abline(v=c(-1,0),lty="dashed",col="green")
akar
points(akar[1],0,pch=20, cex=2, col="red")
akar<-[Link](f, -2.5, -1.5, tol = 1e-10)
abline(v=c(-2.5,-1.5),lty="dashed",col="green")

abline(h=0,v=akar$roots,lty="dashed",col="blue")

bisection(sin, 1, 7, tol = 1e-6)

You might also like