Tuesday, 18 April 2017

TUGAS MANDIRI METODE NUMERIK

TUGAS MANDIRI 1
METODE NUMERIK





 













OLEH :
RISAL GUNAWAN
F1B314012




JURUAN TEKNIK PERTAMBANGAN
FAKULATAS ILMU DAN TEKNOLOGI KEBUMIAN
UNIVERSITAS HALU OLEO
KENDARI
2017








1.      Kode MATLAB function splineCurf
function k = splineCurv(xData, yData)
% Returns curvatures of a cubic spline at the knots.
% USAGE: k  = splineCurv(xData,yData)
% xData = x-coordinates of data points.
% yData = y-coordinates of data points.

n = length(xData);
c  =zeros(n-1,1);d=ones(n, 1);
e  =zeros(n-1,1);k=zeros(n, 1);
c(1:n-2)  =  xData(1:n-2) - xData(2:n-1);
d(2:n-1)  =  2*(xData(1:n-2) - xData(3:n));
e(2:n-1)  =  xData(2:n-1) - xData(3:n);
k(2:n-1)  =  6*(yData(1:n-2) - yData(2:n-1))...
                      ./(xData(1:n-2) - xData(2:n-1))...
                      - 6*(yData(2:n-1) - yData(3:n))...
                         ./(xData(2:n-1) - xData(3:n));
[c,d,e] = LUdec3(c, d ,e);
k = LUsol3(c ,d, e, k);

2.      Kode MATLAB function splinEval
function  y = splineEval(xData, yData, k, x)
%  Returns value of cubic spline interpolant at x.
%  USAGE: y  =  splineEval(xData,yData,k,x)
%  xData  =   x-coordinates of data points.
%  yData  =   y-coordinates of data points.
%  k           =  curvaturesofsplineattheknots;
%                     returned by function splineCurv.

i  = findSeg(xData, x);
h  =  xData(i)  -  xData(i+1);
y  =  ((x - xData(i+1))^3/h  -  (x - xData(i+1))*h)*k(i)/6.0...
     - ((x - xData(i))^3/h  -  (x - xData(i))*h)*k(i+1)/6.0...
    + yData(i)*(x - xData(i+1))/h...
     - yData(i+1)*(x - xData(i))/h;

function i = findSeg(xData, x)
% Returns index of segment containing x.
iLeft  =  1;  iRight  =  length(xData);
while 1
         if (iRight  -  iLeft) <= 1
                 i  =  iLeft; return
         end
         i  =   fix((iLeft + iRight)/2);
         if  x  <  xData(i)
                 iRight = i;
         else
                  iLeft = i;
         end
end

3.      Gunakan data pada example 3.5 untuk menghitung nilai y pada x=2.5, x=3.5, dan x=4.5(secara manual dan komputasi numerik).

X
1
2
3
4
5
y
0
1
0
1
0

Komputasi numerik
xData = [1; 2; 3; 4; 5];
yData = [0; 1; 0; 1; 0];
k = splineCurv(xData,yData);
while 1
          x = input('x = ');
         if isempty(x)
             fprintf('Done'); break
         end
         y = splineEval(xData,yData,k,x)
         fprintf('\n')
end
      Running the program produces the following results:
x = 2.5

y =

    0.4464


x = 3.5

y =

    0.4464


x = 4.5

y =

    0.7679

Perhitungan Manual
x=2,5
 

x=3,5
 





x=4,5



4.      Gunakan data pada example 3.6 untuk menghitung nilai y pada x=1.6, x=2.6(secara manual dan komputasi numerik).

Komputasi numerik
xData  =  [0; 1; 2; 3];
yData  =  [1; 1; 0.5; 0];
k  =  splineCurv(xData,yData);
while 1
         x  =  input('x = ');
         if  isempty(x)
                fprintf('Done'); break
        end
        y  =  splineEval(xData,yData,k,x)
        fprintf('\n')
end
            Running the program produces the following results:
x = 1.6

y =
    0.7320


x = 2.6

y =

    0.1888

Perhitungan Manual
5.      Tuliskan dengan benar kode-kode MATLAB pada example3.7 dan tunjukan bahwa hasil eksekusi program yang dibuat sesuai dengan hasil yang tercantum pada buku teks.
xData = [1; 2; 3; 4; 5];
yData = [0; 1; 0; 1; 0];
k = splineCurv(xData,yData);
while 1
          x = input('x = ');
          if isempty(x)
                fprintf('Done'); break
          end
           y = splineEval(xData,yData,k,x);
           fprintf('\n')
end
            Running the program produces the following results:


x = 1.5

y =

    0.7679


x = 4.5

y =

    0.7679



6.      Kerjakan soal-soal pada PROBLEM SHEET 3.1 untuk nomor 10,11,12,13 dan17.
Ø Nomor 10
xData = [0; 1; 2];
yData = [0; 2; 1];
k = splineCurv(xData,yData);
while 1
         x = input('x = ');
         if isempty(x)
              fprintf('Done'); break
         end
         y = splineEval(xData,yData,k,x)
         fprintf('\n')
end
            Running the program produces the following results:
x = 0

y =

     0


x = 0.1

y =

    0.2742


x = 0.2

y =

    0.5440


x = 0.3

y =

    0.8047


x = 0.4

y =

    1.0520


x = 0.5

y =

    1.2813


x = 0.6

y =

    1.4880


x = 0.7

y =

    1.6677


x = 0.8

y =

    1.8160


x = 0.9

y =

    1.9283


x = 1

y =

     2


x = 1.1

y =

    2.0282


x = 1.2

y =

    2.0160


x = 1.3

y =

    1.9677


x = 1.4

y =

    1.8880


x = 1.5

y =

    1.7813


x = 1.6

y =

    1.6520


x = 1.7

y =

    1.5048


x = 1.8

y =

    1.3440


x = 1.9

y =

    1.1743


x = 2

y =

     1

Ø Nomor11
xData  =  [1; 2; 3; 4; 5;];
yData  =  [13; 15; 12; 9; 13];
k  =  splineCurv(xData,yData);
while 1
          x  =  input('x = ');
          if isempty(x)
               fprintf('Done'); break
          end
          y  =  splineEval(xData,yData,k,x)
          fprintf('\n')
end
            Running the program produces the following results:

x = 3.4

y =

   10.2549
Ø Nomor12
xData  =  [0.2;  0.4; 0.6; 0.8; 1.0];
yData  =  [1.150;  0.855;  0.377;   -0.266;  -1.049];
k  =  splineCurv(xData,yData);
while 1
         x  =  input('x = ');
         if isempty(x)
               fprintf('Done'); break
         end
         y  =  splineEval(xData,yData,k,x)
      fprintf('\n')
end

Ø Nomor13
xData = [0.2; 20; 200; 2000; 20000];
yData = [103; 13.9; 2.72; 0.800; 0.401; 0.433];
k = splineCurv(xData,yData);
while 1
          x = input('x = ');
          if isempty(x)
               fprintf('Done'); break
          end
          y = splineEval(xData,yData,k,x)
          fprintf('\n')
end
            Running the program produces the following results:
x = 5

y =

   80.3860


x = 50

y =

  -78.8036


x = 500

y =

  411.2887


x = 5000

y =

 -1.9155e+003

Ø Nomor 17
ReData = [0.2;2;20;200;2000;20000];
CdData = [103;13.9;2.72;0.800;0.401;0.433];
k = splineCurv(xData,yData);
while 1
    x = input('x = ');
    if isempty(x)
        fprintf('Done'); break
    end
    y = splineEval(xData,yData,k,x)
    fprintf('\n')
end
>> tugas17
x = 5
y =
      214.5685
x = 50
y =
      4.2602e+05
x = 500
y =
       4.5013e+08
x = 5000
y =
      4.5257e+11





1 comment:

  1. If you're looking to lose weight then you certainly need to start following this totally brand new custom keto meal plan diet.

    To design this keto diet, certified nutritionists, fitness couches, and professional cooks united to produce keto meal plans that are effective, convenient, money-efficient, and fun.

    From their grand opening in early 2019, 100's of clients have already completely transformed their figure and well-being with the benefits a great keto meal plan diet can offer.

    Speaking of benefits: clicking this link, you'll discover eight scientifically-confirmed ones given by the keto meal plan diet.

    ReplyDelete

Manajemen dan Audit Lingkungan Artikel ISO 14001 Sebagai Pengelolaan Lingkungan Standar

1.1 Latar B e la k a n g   Untuk   mem e nuhi k e butuhan k e hidupan manusia mem e rluk a n sumb e rd a y a a lam, b e r...