# direction field and solution curve for differential equation.

58 views (last 30 days)
Hyun Suk Song on 15 Sep 2020
Answered: esat gulhan on 16 Sep 2020
given function dy/dt = -ty^3
the solution of function is +-1/sqrt(t^2+C) and y(0) = +-1/sqrt(c).
I cannot deal with this solution with C
How can I find solution curves for the differential equation and combined graph of solution curve with direction field.
For solution curve, I used
syms y(t) c
sol = dsolve(diff(y, t) == -t*y^3, y(0) == [-1 1]/sqrt(c))
fplot (sol, [-3, 3])
For direction field
[T, Y] = meshgrid(-2:0.2:3, -1:0.2:2);
S = -t*y^3;
L = sqrt(1 + S.^2) <- I don't know what that means actually
quiver(T, Y, 1./L, S./L, 0.5) axis equal tight

esat gulhan on 15 Sep 2020
Maybe like this
clc; clear;
syms y(t) c
sol = diff(y, t) == -t*y^3 %your equation
cond=y(0) == 1/sqrt(c); %condition for 1/sqrt(c)
sol2=(dsolve(sol,cond));%solution of differential in cond
cond2=y(0) == -1/sqrt(c);%condition for -1/sqrt(c)
sol3=(dsolve(sol,cond2));%solution of differential in cond2
for c=linspace(0.25,10,8); %c values for condition, i take it free, you can change it
t=linspace(-3,3,100);%t values in -3 3 with 100 divides
plot(t,subs(sol2),'b','LineWidth',1.5); %plot lines with cond 1
hold on
plot(t,subs(sol3),'b','LineWidth',1.5);grid on;%plot lines with cond 2
end
[t, y] = meshgrid(-3:0.2:3, -2:0.2:2);%limits of meshgrid
S = -t.*y.^3;
L = sqrt(1 + S.^2)
quiver(t, y, 1./L, S./L, 0.5)
set(gca, 'XLim', [-3 3], 'YLim', [-2 2]);%limits of graph
Hyun Suk Song on 16 Sep 2020
Actually they give me this
Error using plot
Data must be numeric, datetime, duration or an array convertible to double.
Error in projectB (line 34)
plot(t, subs(sol2), 'b', 'LineWidth',1.5);
I don't know why this code is not working

esat gulhan on 16 Sep 2020
Did you copy to code in a new blank script. It is not an extension of a code it is a new indepentend code. It must work. Impossıble not to work. plot(t, subs(sol2), 'b', 'LineWidth',1.5); can not be in line 34 in ,it is in line 12.
Plot will seen like this