Sunteți pe pagina 1din 5

Tema nr 2

k=20
1)a) format long;
>>x=0:0.0001:pi/(2*20);
>>f=inline('cos(20*x)-20*x','x')
f=
Inline function:
f(x) = cos(20*x)-20*x
>> f1=inline('cos(20*x)','x')
f1 =
Inline function:
f1(x) = cos(20*x)
>> f2=inline('-20*x','x')
f2 =
Inline function:
f2(x) = -20*x
>> plot(x,f,x,f1,x,f2),grid,title (' problema1 '),xlabel(' x '),ylabel(' f , f1 , f2 ')

b)>> [s1,eroare,info]=fsolve(f,0.7853)

s1 =
0.36954258905462
eroare =
-7.513527644498197e-008
info =
1
c) >> err=f(s1)
err =
-7.513527644498197e-008
2) x=[1 1 1];
>>function y=sistem(x)
>y(1)=sin(x(1))+(x(2)).^2+log(x(3))-7-0.2;
>y(2)=3*(x(1))+2.^(x(2))-(x(3)).^3+1+0.2;
>y(3)=x(1)+x(2)+x(3)-5-0.2;
endfunction;
>>[sol,msg,info]=fsolve(sistem,x);
3) x=[20:0.001:21];
>> f=inline('sin(20.*x)./(20.*x)','x')
f=
Inline function:
f(x) = sin(20.*x)./(20.*x)
>> format long
>> i=quad(f,20,21)
i=
-1.32653774651685e-004
>> i1=trapz(x,sin(20.*x)./(20.*x))
i1 =
-1.32649354880709e-004
b) >> f1=inline('20.*sin(20.*x)./(20.*x)','x')
f1 =

Inline function:
f1(x) = 20.*sin(20.*x)./(20.*x)
>> m=1;
>> while(quad(f1,m,m+1)>(10.^(-4)))
m=m+1;
end
>> m
m=
2
>> quad(f1,m,m+1)
ans =
-2.39503094837085e-004
4) >>x=[0:0.1:3.5];
>>f=x.^3-6*x.^2+11*x-20;
>>dn=diff(f)./diff(x);
>> da=3.*x.^2-12*x+11;
>> eroare=da(1:length(dn))-dn
eroare =
Columns 1 through 4
0.59000000000000 0.56000000000000 0.53000000000001 0.49999999999998
Columns 5 through 8
0.47000000000001 0.44000000000000 0.40999999999999 0.38000000000002
Columns 9 through 12
0.34999999999999 0.32000000000000 0.29000000000001 0.25999999999999
Columns 13 through 16
0.22999999999999 0.20000000000001 0.17000000000000 0.14000000000001
Columns 17 through 20
0.10999999999999 0.08000000000003 0.05000000000000 0.01999999999997
Columns 21 through 24
-0.00999999999999 -0.04000000000001 -0.06999999999997 -0.09999999999998
Columns 25 through 28

-0.13000000000005 -0.16000000000003 -0.18999999999994 -0.22000000000003


Columns 29 through 32
-0.24999999999997 -0.28000000000002 -0.30999999999994 -0.34000000000004
Columns 33 through 35
-0.37000000000008 -0.40000000000002 -0.42999999999992
>> p=[1 -6 11 -20]
p=
1

-6

11 -20

>> d1=polyder(p)
d1 =
3 -12

11

>> xd=x(2:length(x));
>> darb=dn(1:length(dn)-1).*dn(2:length(dn));p_critic=xd(find(darb<0))
p_critic =
1.4000 2.6000
>> plot(x,f,x,da),grid,title('problema 4'),xlabel('x'),ylabel(' f , f ');

5)
>>format long e;
>>x=0:0.001:pi/2;
>>integ=trapz(x,(sin(x).*cos(x)).^2005)
integ =
0.00000000000000e+000
>> a=1003; b=1003; c(a,b)=factorial(a-1)*factorial(b-1)/factorial(a+b-1);
0

0 0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 NaN

S-ar putea să vă placă și