c=
-0.3000
2.0000
78.8000
>> plot(x,b,'*r')
>> hold on
>> x=0:0.1:4; y=c(1)*x.^2+c(2)*x+c(3); plot(x,y)
y=
81.2320
Questão 2:
%Ajuste quadrático
x=[1 2 3 4 5 6];
y=[80.5 81.6 82.1 83.7 83.9 85]';
K=[x.^2;x;ones(1,6)]';
p=inv(K'*K)*K'*y
plot(x,y,'or')
hold on
x=0:0.1:6;
y=p(1)*x.^2+p(2)*x+p(3);
plot(x,y,'b')
p=
0.0107
4.3788
>> b=exp(p(2))
b=
79.7415
>> plot(x,y,'or')
>> hold on
>> x=0:0.1:7; y=b.*exp(p(1).*x); plot(x,y)
>> x=log(82.5/b)/p(1)
x=
3.1769
Questão 4:
>> A=[5 2 -2; 1 -3 1; -1 0 3]; b=[0 1 3]'; x=[0 0 0]'; tol=1e-6;
>> [x1,n,err]=jacobi(A,b,x,tol)
x1 =
0.3830
0.1702
1.1277
n=
14
err =
8.6708e-07
>> syms x y
>> ezsurf((3+x)/3);
>> hold on
>> ezsurf(1-x+3.*y);
>> ezsurf((5.*x+2.*y)/2);
>> %Este ponto é onde os três pontos se interceptam.