Example problem: exact ODE 2y·y' + 2t = 0, initial condition y(3) = -4
You can check by hand that this ODE is indeed exact and then find Ψ(t,y) = t2 + y2. Then
the general solution in implicit form is t2 + y2 = C, C arbitrary.
syms t y psi = t^2 + y^2 ezcontour(psi,[-5 5 -5 5]) % plot contours of psi for t in [-5,5], y in [-5,5] hold on axis equal % use same size units on both axes
C = subs(psi,{t,y},{3,-4}) % substitute t=3, y=-4 in psi
F = subs(psi-C,t,2) % substitute t=2 in psi-C Fi = inline(vectorize(F)) % turn symbolic expression F into inline function Fi (needed for fzero) y1 = fzero(Fi,-5) % find y1 such that F=0, near y=-5 plot(2,y1,'o') % mark point (2,y(2)) with circle hold off