Top Stories

Rumus Matlab, menghitung error dalam Metode Numerik

In toleran..
Soal :

1)  x^2-cos(x)+4*x
2) sin(x)+4*(x^-1)+2

Jawaban (script menggunakan aplikasi matlab) :

syms x;
disp(' 1.) x^2-cos(x)+4*x');
disp(' 2.) sin(x)+4*(x^-1)+2');
disp('');
p=input('masukan pilihan : ');
a=input('masukkan nilai a : ');
b=input('masukkan nilai b : ');
et=input('masukkan Error Toleransi : ');
e=abs(b-a);
i=1;
disp(' i      a       b      x     f(a)    f(b)   f(x)    E');
disp('----------------------------------------------------------');
clama=a;
cbaru=b;
while (e > et ) & (clama ~= cbaru) & (i < 4);
switch p
    case 1
        f=x^2-cos(x)+4*x;
    case 2
        f=sin(x)+4*(x^-1)+2;
end   
fa=subs(f,x,a);
fb=subs(f,x,b);
%c=(a+b)/2;
clama=cbaru;
c=(fb*a-fa*b)/(fb-fa);
cbaru=c;
fc= subs(f,x,c);
fprintf('%3.0f %6.4f %6.4f %12.10f %7.4f %7.4f %7.4f %7.4f \n', i, a, b, c, fa, fb, fc, e);
if fa*fc < 0
b=c; %geser kiri
else
a=c; %geser kanan
end
e=abs(b-a);  % menghitung error
i=i+1;
end 
Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

1 comments

  1. sudikah anda berbagi ilmu? :)
    saya ingin lebih tau tentang apa yg anda post ... karna sy baru menghadapi matkul ini
    terimakasih mas bahtiar

    ReplyDelete

:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

 
© 2011 UI
Designed by Blog Thiet Ke
Posts RSSComments RSS
Back to top