Tampilkan postingan dengan label Rekayasa Komputasional. Tampilkan semua postingan
Tampilkan postingan dengan label Rekayasa Komputasional. Tampilkan semua postingan

Selasa, 12 Juni 2012

Integrasi Numerik Metode Titik Tengah Menggunakan R - Stat


a <- 0
b <- 2
n <- 256
h <- (b-a)/n
x <- a
sigma <- 0
for i=1:n-1;
      x <- x+h
      xr <- x/2
      fr <- ((4*xr)-(xr^3))*exp(xr^2)
        print('%11.6f \t %11.6f \t %11.6f \n',i/2,xr,fr);
        sigma <- sigma+((4*xr)-(xr^3))*exp(xr^2)
  end
  disp("Hasil perhitungan titik tengah= ")
  print('%11.6f',sigma)

Selasa, 03 April 2012

Implementasi Perhitungan Metode Newton Raphson Dalam R-Stat


(function (y) {
y<- f(x)
y<-x^3 + 2*x^2 + 10*x - 20
}

(function (y) { y
<-df(x)
y<-3*x^2 + 4*x + 10;
}

(function (xr) {
xr <- newtonraphson(f, x0, aprox)
i<-1
er(1)<-1
xr(1)<-x0
while abs(er(i))>=aprox {
    xr(i+1)<-xr(i)-f(xr(i))/df(xr(i))
    er(i+1)<-abs((xr(i+1)-xr(i))/xr(i+1))
    i=i+1}

printt(' i  \t      xn(i)      Error aprox (i) \n');
for j=1:i{
    print('%2d \t %11.7f \t %7.6f \n',j-1,xr(j),er(j));
}
}

Implementasi Perhitungan Metode Scant Dalam R-Stat


(function (y){
y <- g(x)
y <- x^3 + 2*x^2 + 10*x - 20
}

(function(x0, x1, aprox){
j<-2;
i<-1;
pn(1)<-x0;
pn(2)<-x1;
er(i)<-1;
while abs(er(i))>=aprox{
   pn(j+1)<-(pn(j-1)*f(pn(j))-pn(j)*f(pn(j-1)))/(f(pn(j))-f(pn(j-1)));
   er(i+1)<-abs((pn(j+1)-pn(j))/pn(j+1));
   j<-j+1;
   i<-i+1;
}

print(' i \t\t pn(i) \t\t Error aprox (i) \n')
print('%2d \t %11.7f \t\t \n',0,pn(1))

for k=2:j{
print(%2d \t %11.7f \t %7.8f \n,k,pn(k),er(k-1))}}

Implementasi Perhitungan Metode Regulfasi Dalam R-Stat



y <- 1
z <- 1.5
fy <- ((y^3)  + (2 (y^2)) + (10 y) – 20)
fz <- z^3  + 2 z^2 + 10 z – 20
x <- z – (fz * (z – y) / (fz – fy))
hasil <- x^3  + 2 x^2 + 10 x – 20
print(hasil)
fy * fz < 0
z <- x
fz <- z^3  + 2 z^2 + 10 z – 20
fy
x <- z – (fz * (z – y) / (fz – fy))
hasil <- x^3  + 2 x^2 + 10 x – 20
print (hasil)
fy * fz < 0
fy * fz >= 0
y <- x
fz
fy <- y^3  + 2 y^2 + 10 y – 20
x <- z – (fz * (z – y) / (fz – fy))
hasil <- x^3  + 2 x^2 + 10 x – 20
print (hasil)

Implementasi Perhitungan Metode BagiDua Dalam R-Stat


( function(x)
{
y <- x^3 + 2*x^2 + 10*x - 20
}

(function(f, x0, x1, approx)
{
i <- 1
er(1) <- 100
if (f(x0)*f(x1) < 0){
    a(1) <- x0
    b(1) <- x1
    c(1) <- (a(1)+b(1))/2
    print (r\t\t a\t\t b\t\t c\t\t f(c)\t  Error  \n)
    print (%2d \t %11.6f \t %11.6f \t %11.6f \t %11.6f \n,i,a(i),b(i),c(i),f(c(i)))
    while (abs(er(i)) >= approx){
      if (f(a(i))*f(c(i))< 0){
         a(i+1) <- a(i)
         b(i+1) <- c(i)}
   
      if (f(a(i))*f(c(i))> 0){
         a(i+1) <- c(i)
         b(i+1) <- b(i)}
       
      c(i+1) <- (a(i+1)+b(i+1))/2
      er(i+1) <- abs((c(i+1)-c(i))/(c(i+1)))
      print (%2d \t %11.6f \t %11.6f \t %11.6f \t %11.6f \t %7.6f \n,i+1,a(i+1),b(i+1),c(i+1),f(c(i+1)),er(i+1))
      i=i+1 }}
else
   print (" ")
}