Vous êtes sur la page 1sur 4

Ex. 4.

29
f=inline('sin(x)/x','x');
imp=pontomedio(0,1,8,f)
%os outros nao pode ser pk ser um integral impropios e simpson e
trapezio precisa de saber
%o valor em f(0)

Ex. 4.30
t=[0 6 12 18 24 30 36 42 48 54 60 66 72 78 84];
v=[124 134 148 156 147 133 121 109 99 85 78 89 104 116 123];
Z = TRAPZ(t,v)

Ex.4.31
f=inline('exp(x).*cos(x)','x')
[ISf,nodes] = simpsonadaptativa(f,0,pi,10^-2,0.1)

Ex.4.32
f=inline('x.^3-x','x');
c=linspace(-1,2,5);
der=inline('3.*x.^2-1','x');
l=inline('sqrt(1+(3.*x.^2-1).^2)','x');
y=feval(f,c)
Z = TRAPZ(y,c)

Ex.4.37
t=[1.0 1.01 1.02 1.03 1.04];
y=[3.10 3.12 3.14 3.18 3.24];
h=0.01
for i=1:1:4
c(i)=(y(i+1)-y(i))/h
end
for i=5
c(i)=(y(i)-y(i-1))/h
end
E=0.98.*c*0.142.*y

Ex.5.21
A=[1 2 1 1; 2 3 4 1; 1 2 2 1;3 7 -1 -1];
b=[2;6;2;-8];
[l,u]=lu(A)
y=l\b;
x=u\y;

Ex.5.22
A=[1 0 3; 2 2 2; 3 6 4];
b=[0 2 3;1 1 -1;0 -1 1];
[l,u,p]=lu(A)
y=l\b;

x=u\y

Ex.5.24
A=[1 1 -1; 5 2 2; 3 1 1];
b=[1;-4;1]
[l,u]=lu(A)
y=l\b
x=u\y

Ex.5.37
A=[5 -1;-1 10];
b=[3;19];
[l,u,P]=lu(A);
J=P;
[x,iter] = metodoiterativo (A,b,[0;0],100,10^-4,'J')
G=P;
[x1,iter1] = metodoiterativo (A,b,[0;0],100,10^-4,'G')
D=[5 0;0 10];
miter=inv(D)*(D-A);%matriz iter.
%
valorpp=eig(miter'*miter)
raioesprectal=max(abs(valorpp))
norma_2=sqrt(raioesprectal)
%==========================================
norma1=norm(miter,1)
norma2=norm(miter,2)
normainf=norm(miter,inf)
Ex.5.39
% A=[9 3 1;-6 0 8; 2 5 -1];
% b=[13 2 6];
% D=diag(diag(A));
% L=-tril(A,-1);
% U=-triu(A,1);
% Bj=inv(D)*(L+U);
% %valorpp=eig(Bj)
% %raioesprectal=max(abs(valorpp))
% norma=norm(Bj,1);
% Bg=inv(D-L)*U;
% normags=norm(Bg,1);
%===========================================
A=[1 1 6;1 5 -1; 4 2 -2];
b=[8 5 4];
D=diag(diag(A));
L=-tril(A,-1);
U=-triu(A,1);
Bj=inv(D)*(L+U);
norma=norm(Bj,1);
Bg=inv(D-L)*U;
normags=norm(Bg,1);
%===========================================
A=[-3 4 5;-2 2 -3; 0 2 -1];

b=[6 -3 1];
D=diag(diag(A));
L=-tril(A,-1);
U=-triu(A,1);
Bj=inv(D)*(L+U);
norma=norm(Bj,1)
Bg=inv(D-L)*U;
normags=norm(Bg,1)

ex.6.9
A=[1 2 0;1 0 0;0 1 0];
tol=10^-10;
x0=[1 2 3]'
nmax=100;
[lambda,x,iter]=potencia (A,tol,nmax,x0)
B=[0.1 3.8 0;1 0 0;0 1 0]
[lambdaB,x,iter]=potencia (B,tol,nmax,x0)
C=[0 -1 0;1 0 0 ;0 1 0]
[lambdaC,x,iter]=potencia (B,tol,nmax,x0)
valorpA=eig(A)
valorpB=eig(B)
valorpC=eig(C)

ex.6.10
A=[(1/3) (2/3) 2 3;1 0 -1 2;0 0 -(5/3) -(2/3);0 0 1 0]
valorpro=eig(A)

Ex.6.13
A=[2 -(1/2) 0 -(1/2); 0 4 0 2;-(1/2) 0 6 (1/2);0 0 1 9];
valopro=eig(A)
B=[-5 0 (1/2) (1/2); 1/2 2 (1/2) 0;0 1 0 (1/2);0 (1/4) (1/2) 3]
valoproB=eig(B)
gershcircles(A)
%gershcircles(B)
Ex.7.23
y0=0;
t=[0 1];
dery=inline('sin(t)+y','t','y')
NH=25;
[T, U] = EULERPROG(dery, t, y0, NH)

[Treg, Ureg] = EULERREGR(dery, t, y0, NH)


g=inline('(-1/2).*(sin(t)+cos(t))+(1/2).*exp(t)','t')
plot(T,Ureg,'r')
hold on
fplot(g,[0 1])
Ex.7.24
dery=inline('-t.*exp(-y)','t','y');

t=[0 1];
y0=0;
NH=1024;
[T, U] = EULERPROG(dery, t, y0, NH);
[Treg, Ureg] = EULERREGR(dery, t, y0, NH);
Te=linspace(0,1,1024);
plot(T,U)
hold on;
plot(Treg,Ureg)
g=inline('log(1-(t^2/2))','t')
fplot(g,[0 1],'r')
NH1=2;
NH2=2^2;
NH3=2^3;

Vous aimerez peut-être aussi