Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
31 views5 pages

Oooo

The document contains calculations for the density and molar volume of CO2 using the Ideal Gas and Redlich-Kwong equations, followed by numerical solutions to a differential equation using the Euler method and ode45. It also includes polynomial root calculations, quadratic formula solutions, numerical integration using the trapezoidal rule, and matrix operations. The results of these calculations are displayed throughout the document.

Uploaded by

Paint with MSM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views5 pages

Oooo

The document contains calculations for the density and molar volume of CO2 using the Ideal Gas and Redlich-Kwong equations, followed by numerical solutions to a differential equation using the Euler method and ode45. It also includes polynomial root calculations, quadratic formula solutions, numerical integration using the trapezoidal rule, and matrix operations. The results of these calculations are displayed throughout the document.

Uploaded by

Paint with MSM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

disp('Question No.

8')

%Density and Molar Volume of CO2 using Ideal Gas Equation and Redlich-Kwong Equation

p = 50; %bar

p = 50*100; %kPa

p = 5000; %kPa

T = 450; %K

R = 8.3145; %kPa.m3/(kmol.K)

pc = 7374; %kPa

Tc = 304.12; %K

M = 44.01; %kg/kmol

v_ig = (R*T)/p; %m3/kmol

den_ig = (p*M)/(R*T) %kg/m3

a = 0.42747*(R^2)*(Tc^2)/pc; %m6.kPa/lmol2

b = 0.08664*R*Tc/pc; %m3/kmol

alpha = sqrt(Tc/T);

fV_RK= @(v) v^3-(R*T/p)*(v^2)+((a*alpha/p)-(b*R*T/p)-(b^2))*v-(a*alpha*b/p);

v = fzero(fV_RK,v_ig); %m3/kmol

den = M/v

disp('Question No.9')

disp('Step size 0.1')

f=@(t,y) 30*y-40*y.^2;

Y=@(t) 3*exp(30*t)./(26+4*exp(30*t));

t0 = 0;

y0 = 0.1;

h = 0.1;

n = 10; % Number of steps

t(1)=t0;

y(1)=y0;

% Euler Method
for i = 1:n

y(i+1) = y(i)+ h * f(t(i),y(i));

t(i+1) = t(i)+ h;

end

y_exact=Y(t);

percent_error =100*abs((y_exact-y)./y_exact);

Result=[t;y;y_exact;percent_error]

fprintf('t\t y\t y_exact\t percent_error\n');

fprintf('%0.2f\t %0.2f\t %0.2f\t %0.2f\n', Result)

disp('Step size 0.05')

f=@(t,y) 30*y-40*y.^2;

Y=@(t) 3*exp(30*t)./(26+4*exp(30*t));

t0 = 0;

y0 = 0.1;

h = 0.05;

n = 10; % Number of steps

t(1)=t0;

y(1)=y0;

% Euler Method

for i = 1:n

y(i+1) = y(i)+ h * f(t(i),y(i));

t(i+1) = t(i)+ h;

end

y_exact=Y(t);

percent_error =100*abs((y_exact-y)./y_exact);

Result=[t;y;y_exact;percent_error]

fprintf('t\t y\t y_exact\t percent_error\n');

fprintf('%0.2f\t %0.2f\t %0.2f\t %0.2f\n', Result)


disp('Step size 0.025')

f=@(t,y) 30*y-40*y.^2;

Y=@(t) 3*exp(30*t)./(26+4*exp(30*t));

t0 = 0;

y0 = 0.1;

h = 0.025;

n = 10; % Number of steps

t(1)=t0;

y(1)=y0;

% Euler Method

for i = 1:n

y(i+1) = y(i)+ h * f(t(i),y(i));

t(i+1) = t(i)+ h;

end

y_exact=Y(t);

percent_error =100*abs((y_exact-y)./y_exact);

Result=[t;y;y_exact;percent_error]

fprintf('t\ty\ty_exact\tpercent_error\n');

fprintf('%0.2f\t %0.2f\t %0.2f\t %0.2f\n', Result)

disp('Ode45_Command')

f=@(t,y) 30*y-40*y.^2;

t0 = 0;

y0 = 0.1;

h=0.1;

[t y]=ode45(f,[0:0.1:1],0.1)

result=[t;y]

fprintf('t\t y\n');

fprintf('%0.2f\t %0.2f\n', result)

disp('Question No.10')
disp('y=x4+3x2+2x+5')

y=[1 0 3 2 5];

r=roots(y)

disp('Question No.11')

a=2;

b=-10;

c=12;

x =(-b+(sqrt((b^2)-(4*a*c))))/(2*a)

disp('Question No.12')

x=[0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6];

y=[5,5.2,5.3,5.4,5.5,5.6,5.7,5.7,5.8];

q=trapz(x,y)

plot(x,y)

xlabel('x')

ylabel('y')

title('x vs y plot')

disp('Question No.13')

x=pi/5;

z=(cos(x/2))^2

h=(tan(x)+sin(x))/(2*tan(x))

result=[z;h]

fprintf('%s\t %6s\n\n', 'z','h');

fprintf('%0.4f\t %0.4f\n', result)

disp('L.H.S=R.H.S')

disp('Question No.14')

A=[5 2 4;1 7 -3;6 -10 0];

B=[11 5 -3;0 -12 4;2 6 1];

C=[7 14 1;10 3 -2;8 -5 9];


disp('A+B')

A+B

disp('B+A')

B+A

disp('A+(B+C)')

A+(B+C)

disp('(A+B)+C')

(A+B)+C

disp('3(A+B)=3A+3B')

x=3*(A+B)

Z=3*A+3*B

disp('3(A+B)=3A+3B')

You might also like