Solution Exam 1 (MATH246, Spring 2024)

clearvars; format short g

Problem 1(a)

separable, constant solution
syms y(t) % defines symbolic variable t and symbolic function y(t)
Dy = diff(y);
ode = Dy+t*(y-1)^2==0;
dsolve(ode)
ans = 
We get two solutions: one from separation (for ), and the constant solution .
dsolve(ode,y(2)==-1)
ans = 
solution does not exist for , solution exists for
dsolve(ode,y(2)==1)
ans = 
1
solution exists for all

Problem 1(b)

ODE is exact:
Find with and : we get .
ode = -4*y+16*t+(2*y-4*t)*Dy==0;
dsolve(ode,'Implicit',true) % solution in implicit form
ans = 
dsolve(ode)
ans = 
dsolve(ode,y(0)==-1)
ans = 
solution exists for , i.e.,

Problem 2(a)

stationary points:
0 (neg to pos), hence unstable
1 (pos to neg), hence stable
3 (neg to pos), hence unstable
y<0: negative
0<y<1: positive
1<y<3: negative
y>3: positive

Problem 2(b)

(i) for we get as , as , solution exists for all
(ii) for we get as (solution does not exist for since improper integral is finite)
as , solution exists for

Problem 3(a)

denotes total amount of water in tank at time t,
volume of water in tank at time t is
average concentration in tank is
ODE , initial condition

Problem 3(b)

linear ODE , , , integrating factor
ode = Dy==6-2*y/(10+t);
dsolve(ode)
ans = 
dsolve(ode,y(0)==50)
ans = 

Problem 4

f = @(t,y) y-t^2;
t0 = 1; y0 = -1; h = 1;
s1 = f(t0,y0)
s1 = -2
yE = y0 + h*s1 % Euler approximation
yE = -3
s2 = f(t0+h,yE)
s2 = -7
y1 = y0 + h*(s1+s2)/2
y1 = -5.5