Professional Documents
Culture Documents
Semester : II
UPC: 32351202
Answer
Editor window:-
n=1:1:100;
a(n)= (-1).^n;
plot (n,a,'md')
hold on
xlabel ('n')
ylabel ('a(n)')
title('Verifying Bolzano Weierstrass Theorem')
Command window:-
Answer
Editor window:-
clear all
n=1:1:500;
g(n)=(-1).^(n+1)./n;
v=cumsum(g)
plot(v,'rd')
Command window:-
#For the given series,1+{-1/2}+{1/3}+{-1/4}+.... the sequence of partial
sum is
<v(n)>=<1.00000,0.50000,0.83333,0.58333,0.78333,0.61667,0.75952,0.
63452,0.74563,0.64563, 0.73654...> which is in a convergent
sequence.
#the limit is ln2=0.6931. Therefore the given series is convergent and
the sum is 0.6931.
Answer
Editor window:-
n=1:1:200;
a(n)=(factorial(n)./(n.^n));
plot(n,a,'rd')
n=1;
while abs(factorial(n)./(n.^n))>=10^(-8);
n=n+1;
endwhile
disp(n)
Command window:-
#the above inequality does not satisfy for n=21 and hence
abs(factorial(n)./(n.^n))<10^(-8) will hold.
#verification that above inequality does not satisfy for n>=21 and hence
abs(factorial(n)./(n.^n))<10^(-8) will hold for all n>=21.
for n=21:500
if abs(factorial(n)./(n.^n))>=10^(-8);
disp(n)
endif
end
Answer
Editor window:-
function cdot=f1(c,t)
r=100; # constant rate of flow of water into the lake and out of the lake
v=100000;
u=5; #concentration of pollutant in the flow entering the lake
cdot=(r./v)*(u-c);
endfunction
Command window:-
c=lsode('f1',10,t=linspace(0,20,100));
plot(t,c)
hold on
xlabel('time')
ylabel('concentration')