Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 9

GARCIA, Raffy V.

Midterm Exam in Computer Application in Chemical


Engineering
Date of Examination: February 10, 2020

1 Provide yourself with a unique ten equations in ten unknowns whose values of the
unknowns are all whole numbers which can either be positive or negative. Solve this set of
equations using Matlab command window and Matlab Editor creating m-file.

2a + 3b + 4c + 5d + 6e + 7f + 8g + 9h + 10i + j = 9
2a - 4b - 6c - 8d - 10e - 12f - 14g - 16h - 18i - 20j = 18
2a + 3b + 6c + 9d + 12e + 15f + 18g + 21h + 25i + 27j = 21
4a + 8b + 12c + 16d + 20e + 24f + 28g + 32h + 36i + 40j = 24
5a + 10b + 15c + 20d + 25e + 30f + 35g + 40h + 45i + 50j = 27
6a + 12b + 18c + 21d + 24e + 27f + 30g + 33h + 36i + 40j = 30
a + b + c + d + e + f + g + h + i + j = 33
7a + 14b + 21c + 28d + 35e + 42f + 49g + 56h + 63i + 70j = 36
8a + 10b + 12c + 14d + 16e + 18f + 20g + 22h + 24i + 26j = 40
9a + 12b + 15c + 18d + 21e + 24f + 27g + 30h + 33i + 36j = 50

> A = [2,3,4,5,6,7,8,9,10,1; 2,-4,-6,-8,-10,-12,-14,-16,-18,-20; 2,3,6,9,12,15,18,21,25,27; 4,8,12,16,20,24,28,32,36,40;


5,10,15,20,25,30,35,40,45,50; 6,12,18,21,24,27,30,33,36,40; 1,1,1,1,1,1,1,1,1,1; 7,14,21,28,35,42,49,56,63,70;
8,10,12,14,16,18,20,22,24,26; 9,12,15,18,21,24,27,30,33,36];
> A

A=
2 3 4 5 6 7 8 9 10 1

2 -4 -6 -8 -10 -12 -14 -16 -18 -20


2 3 6 9 12 15 18 21 25 27
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 21 24 27 30 33 36 40
1 1 1 1 1 1 1 1 1 1
7 14 21 28 35 42 49 56 63 70
8 10 12 14 16 18 20 22 24 26
9 12 15 18 21 24 27 30 33 36

m-file
clc;
disp('Systems of Equations');
eqn1 = ('2*a + 3*b + 4*c + 5*d + 6*e + 7*f + 8*g + 9*h + 10*i + j == 9');

eqn2 = ('2*a - 4*b - 6*c - 8*d - 10*e - 12*f - 14*g - 16*h - 18*i - 20j == 18');

eqn3 = ('2*a + 3*b + 6*c + 9*d + 12*e + 15*f + 18*g + 21*h + 25*i + 27j == 21');

eqn4 = ('4*a + 8*b + 12*c + 16*d + 20*e + 24*f + 28*g + 32*h + 36*i + 40j == 24');

eqn5 = ('5*a + 10*b + 15*c + 20*d + 25*e + 30*f + 35*g + 40*h + 45*i + 50j == 27');
eqn6 = ('6*a + 12*b + 18*c + 21*d + 24*e + 27*f + 30*g + 33*h + 36*i + 40j == 30'); eqn7 = ('a + b + c + d + e +

f + g + h + i + j == 33');

eqn8 = ('7*a + 14*b + 21*c + 28*d + 35*e + 42*f + 49*g + 56*h + 63*i + 70j == 36'); eqn9 = ('8*a + 10*b + 12*c +

14*d + 16*e + 18*f + 20*g + 22*h + 24*i + 26j == 40'); eqn10 = ('9*a + 12*b + 15*c + 18*d + 21*e + 24*f + 27*g +

30*h + 33*i + 36j == 50');

A = [2,3,4,5,6,7,8,9,10,1; 2,-4,-6,-8,-10,-12,-14,-16,-18,-20;
2,3,6,9,12,15,18,21,25,27; 4,8,12,16,20,24,28,32,36,40;

5,10,15,20,25,30,35,40,45,50; 6,12,18,21,24,27,30,33,36,40;
1,1,1,1,1,1,1,1,1,1; 7,14,21,28,35,42,49,56,63,70;

8,10,12,14,16,18,20,22,24,26; 9,12,15,18,21,24,27,30,33,36]; B =

[9,18,21,24,27,30,33,36,40,50];

x = A / B;

Matlab Commands and Results


>> GARCIA_me01

Systems of Equations
> A/B

ans =

0.1768
-0.3943
0.5126
0.7961
0.9952
0.8628
0.0302
1.3932
0.5793
0.7783

2 Provide yourself with unique differential equations. Solve each of this differential equation
using matlab built-in functions in Matlab command window.

First Order Differential Equation

dy
dz =zy
> syms y(t)
> ode = diff(y,t) == t*y

ode(t) =

diff(y(t), t) == t*y(t)

> ySol(t) = dsolve(ode)

ySol(t) = C12*exp(t^2/2)

> fplot('ySol')

Second Order Differential Equation

2
2 x2 d y +3 x dy − y =0
dx2 dx

Matlab Commands and Results

> syms y(x)

> ode = 2*x^2*diff(y,x,2)+3*x*diff(y,x)-y == 0; ySol(x) =

dsolve(ode)

ySol(x) =

C6/(3*x) + C7*x^(1/2)

> fplot(ySol)

< Insert in here the third order differential equation together with the matlab built-in function you used in
solving it, together with its results. Show also the resulting graph. Delete this message after doing so.>

First Order Differential Equation

dy
dt + y=1
y(0)=0.

Matlab Commands and Results

>> syms y(t)


ode = (diff(y,t)+y)^2 == 1;
cond = y(0) == 0;
ySol(t) = dsolve(ode,cond)

ySol(t) =
exp(-t) - 1
1 - exp(-t) >>

fplot (ySol)

100

50

-50

-100

-5 -4 -3 -2 -1 0 1 2 3 4 5

Second Order Differential Equation


d2 y
=cos (2 x )− y
2
dx

Matlab Commands and Results


> syms y(x)
Dy = diff(y);

ode = diff(y,x,2) == cos(2*x)-y;

cond1 = y(0) == 1;

cond2 = Dy(0) == 0;

> conds = [cond1 cond2];

ySol(x) = dsolve(ode,conds);
ySol = simplify(ySol)

ySol(x) =

1 - (8*sin(x/2)^4)/3

>> fplot(ySol)

0.5

-0.5

-1

-1.5

-5 -4 -3 -2 -1 0 1 2 3 4 5

Third Order Differential Equation


d3 y =u
dx3

u(0)=1, u′(0)=−1, u′′(0)=π.


Matlab Commands and Results

> syms u(x) Du


= diff(u,x); D2u =
diff(u,x,2);
> ode = diff(u,x,3) ==
u; cond1 = u(0) == 1;
cond2 = Du(0) == -1;
cond3 = D2u(0) == pi;
conds = [cond1 cond2 cond3];

uSol(x) = dsolve(ode,conds)

uSol(x) =

(pi*exp(x))/3 - exp(-x/2)*cos((3^(1/2)*x)/2)*(pi/3 - 1) - (3^(1/2)*exp(-x/2)*sin((3^(1/2)*x)/2)*(pi + 1))/3

120
100

80

60

40

20

-20

-5 -4 -3 -2 -1 0 1 2 3 4

Systems of Differential Equation


du
=3 u+4 v ,
dt

Matlab Commands and Results

> syms u(t) v(t)


ode1 = diff(u) == 3*u + 4*v;
ode2 = diff(v) == -4*u + 3*v;

odes = [ode1; ode2]

odes(t) =

diff(u(t), t) == 3*u(t) + 4*v(t)

diff(v(t), t) == 3*v(t) – 4*u(t)

>>S=

struct with fields:

v: [1×1 sym]

u: [1×1 sym]

> uSol(t) = S.u

vSol(t) = S.v

uSol(t) =

C9*cos(4*t)*exp(3*t) + C8*sin(4*t)*exp(3*t)

vSol(t) =

C8*cos(4*t)*exp(3*t) - C9*sin(4*t)*exp(3*t)

> cond1 = u(0) == 0;

cond2 = v(0) == 1;

conds = [cond1; cond2];

[uSol(t), vSol(t)] = dsolve(odes,conds)

uSol(t) =

sin(4*t)*exp(3*t)
disp ('MDAS Problem Solver');

disp (' 25 + 7*9 - 20/2 ');

ans = 25 + 7*9 - 20/2;

fprintf('The answer is %0.2f. ',ans);

Matlab Commands and Results


>> GARCIA_me03

MDAS Problem Solver


25 + 7*9 - 20/2
The answer is 78.00.

4 Before the final examination week, you need to submit your own designed laboratory
exercise. This will serve as your final exam.
< Provide in here a discussion about the laboratory exercise that you will design.
Start with the title. Delete this message after doing so.>

You might also like