#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 (  ) { 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)