Anda di halaman 1dari 2

# Week 9 Erdyanti Rinta Bi Tari

3715100024
Regresi Polinomial

A. Teori
Prinsip dari regresi polinomial sama dengan regresi linier, hanya berbeda pada
derajat polinomialnya
𝑦 = 𝑎0 + 𝑎1 𝑥𝑖 + 𝑎2 𝑥𝑖2 + 𝑒 (1)
2 2 2
𝑆𝑟 = ∑(𝑦𝑖 − 𝑎0 − 𝑎1 𝑥𝑖 − 𝑎2 𝑥𝑖 ) (2)
𝜕𝑆𝑟
= −2 ∑[𝑦𝑖 − 𝑎0 − 𝑎1 𝑥𝑖 − 𝑎2 𝑥𝑖2 ] = 0  ∑ 𝑦𝑖 = 𝑛𝑎0 + ∑ 𝑎1 𝑥𝑖 + 𝑎2 𝑥𝑖2 (3)
𝜕𝑎0

𝜕𝑆𝑟
= −2 ∑ 𝑥𝑖 [𝑦𝑖 − 𝑎0 − 𝑎1 𝑥𝑖 − 𝑎2 𝑥𝑖2 ]  ∑ 𝑥𝑖 𝑦𝑖 = ∑ 𝑥𝑖 𝑎0 + ∑ 𝑎1 𝑥𝑖2 + 𝑎2 𝑥𝑖2 (4)
𝜕𝑎1

𝜕𝑆𝑟
= −2 ∑ 𝑥𝑖2 [𝑦𝑖 − 𝑎0 − 𝑎1 𝑥𝑖 − 𝑎2 𝑥𝑖2 ]  ∑ 𝑥𝑖2 𝑦𝑖 = ∑ 𝑥𝑖 𝑎0 + ∑ 𝑎1 𝑥𝑖3 + 𝑎2 𝑥𝑖4 (5)
𝜕𝑎2

## Persamaan 3, 4, dan 5 dapat diselesaikan dengan penyelesaian matriks square

(menggunakan invers matriks A\b)

## B. Script dan Hasil Running

a. Manual
clc
clear all

x=[0:5]';
y=[2.1 7.7 13.6 27.2 40.9 61.1]'

n=length(y);

A(1,1)=n;
A(1,2)=sum(x);
A(1,3)=sum(x.^2);
A(2,1)=sum(x);
A(2,2)=sum(x.^2);
A(2,3)=sum(x.^3);
A(3,1)=sum(x.^2);
A(3,2)=sum(x.^3);
A(3,3)=sum(x.^4);

b(1,1)=sum(y);
b(2,1)=sum(x.*y);
b(3,1)=sum(x.^2.*y);

%misal Ax=b
z=A\b
Week 9 Erdyanti Rinta Bi Tari
3715100024
b. Untuk polinomial orde n
clc
clear all

x=[0:5]';
y=[2.1 7.7 13.6 27.2 40.9 61.1]'

% n=length(y);
orde=2

## for i=1:orde+1 %indeks baris

k=i-1;
b(i,1)=sum(x.^k.*y);
for j=1:orde+1 %indeks kolom
A(i,j)=sum(x.^k);
k=k+1;
end
end

% misal Ax=b
z=A\b