System of differential equations, unable to find explicit solution with dsolve

2 views (last 30 days)
Hi there!
I am trying to solve the following system of differential equations (4 equations and 4 unknowns):
where and and
So, when I substitute all the derivatives I get the following system of differential equations:
I don't have any initial conditions or any values for the parameters.
I am not familiar with Matlab but after searching online I wrote this code which doesn't work:
syms S(t) P(t) c(t) z(t) A b g v k u d r w % k stands for τ, u for θ and v for a
eqn1 = diff(S,t) == A*(b*S)^(1-g)*(z^g) - k*z - c - b*S*(k+1)
eqn2 = diff(P,t) == u*z - d*P + (1-b)*S
eqn3 = diff(c,t) == (((1-b)/u) * (v - A*g*(b*S)^(1-g)*z^(g-1)) + b * (A*(1-g)*b^(-g)*S^(-g)*z^(g) -k -1) - r) * c
eqn4 = diff(z,t) == ((v - A*g*(b*S)^(1-g)*z^(g-1))/(A*(g-1)*g*(b*S)^(1-g)*z^(g-2))) * ((d - ((1-b) * (A*g*(b*S)^(1-g)*z^(g-1) - v))/u)) + (b / (A*(g-1)*g*(b*S)^(1-g)*z^(g-2))) * (((A*g*(b*S)^(1-g)*z^(g-1) - v)) * (A*b^(2-g)*(1-g)*S^(-g)*z^g - 1 - k) - (A*g*(1-g)*b^(1-g)*S^(-g)*z^(g-1)) * (A*(b*S)^(1-g)*z^g) - v*z - b*S*(k+1) - c) - (((1-w)*u *(1/P)) / (A*(g-1)*g*(b*S)^(1-g)*z^(g-2)))
sol = dsolve(eqn1,eqn2,eqn3,eqn4)
What I am getting back is the following error and an empty matrix of solutions:
Warning: Unable to find explicit solution.
> In dsolve (line 190)
But I am sure that there is a solution for that system.
The version of Matlab I am using is: 9.7.0.1319299 (R2019b) Update 5.
Can't seem to fix this problem even though I tried many things and I don't understand what I am doing wrong. I would really appreciate any help.
Thanks in advance!

Accepted Answer

Star Strider
Star Strider on 24 Apr 2020
Not all differential equations (or integrals) have analytic sollutions. Yours are among them.
Try this:
% k stands for \tau, u for \Theta and v for a
syms S(t) P(t) c(t) z(t) A b g v k u d r w t Y
eqn1 = diff(S,t) == A*(b*S)^(1-g)*(z^g) - k*z - c - b*S*(k+1);
eqn2 = diff(P,t) == u*z - d*P + (1-b)*S;
eqn3 = diff(c,t) == (((1-b)/u) * (v - A*g*(b*S)^(1-g)*z^(g-1)) + b * (A*(1-g)*b^(-g)*S^(-g)*z^(g) -k -1) - r) * c;
eqn4 = diff(z,t) == ((v - A*g*(b*S)^(1-g)*z^(g-1))/(A*(g-1)*g*(b*S)^(1-g)*z^(g-2))) * ((d - ((1-b) * (A*g*(b*S)^(1-g)*z^(g-1) - v))/u)) + (b / (A*(g-1)*g*(b*S)^(1-g)*z^(g-2))) * (((A*g*(b*S)^(1-g)*z^(g-1) - v)) * (A*b^(2-g)*(1-g)*S^(-g)*z^g - 1 - k) - (A*g*(1-g)*b^(1-g)*S^(-g)*z^(g-1)) * (A*(b*S)^(1-g)*z^g) - v*z - b*S*(k+1) - c) - (((1-w)*u *(1/P)) / (A*(g-1)*g*(b*S)^(1-g)*z^(g-2)));
[VF,Subs] = odeToVectorField(eqn1,eqn2,eqn3,eqn4)
odefcn = matlabFunction(VF, 'Vars',{t,A,Y,b,d,g,k,r,u,v,w})
The ‘Subs’ output is important because it tells how the ‘Y’ vector elements are assigned, so ‘Y(1)=Subs(1)’ and so for the rest.
Supply scalar values for the other variables, and (probably) use:
@(t,Y) odefcn(t,A,Y,b,d,g,k,r,u,v,w)
as the function argument to the ODE solver of your choice.
.
  6 Comments

Sign in to comment.

More Answers (1)

Myrto Kasioumi
Myrto Kasioumi on 21 May 2020
Hello again!
I am still trying to solve the above problem but now I made it a little bit harder. So the basic problem is still the same.
I am trying to solve the following system of differential equations:
So I am using the following code:
% k stands for \tau, u for \Theta, v for a, h for \hta and A for Ao
syms S(t) P(t) c(t) z(t) A b g h v k l u d r w t Y
eqn1 = diff(S,t) == (A*exp(h*t)*b*S)^(1-g) * z^g - v*z - c - A*exp(h*t)*b*S*(k*exp(h*t*(-1))+1);
eqn2 = diff(P,t) == u*z - d*P + (1-b)*S;
eqn3 = diff(c,t) == ( ((A*exp(h*t)*b) * ((1-g)*b*z^g*(A*exp(h*t)*S*b)^(-g)*(A*exp(h*t)+S) - 1 - k*exp(l*t*(-1)))) + (((1-b)/u) * (v - g*z^(g-1)*(A*exp(h*t)*S*b)^(1-g))) - r ) * c ;
eqn4 = diff(z,t) == ( ( (g*(A*exp(h*t)*S*b)^(1-g)*z^(g-1) - v)/(g*(g-1)*(A*exp(h*t)*S*b)^(1-g)*z^(g-2)) ) * ( d + ((c*u*(1-w))/(P*w*(v-g*(A*exp(h*t)*S*b)^(1-g)*z^(g-1)))) + ((A*exp(h*t)*b) * ((1-g)*z^g*(A*exp(h*t)*b*S)^(-g)*(A*exp(h*t)*b + b*S) - 1 - (k*exp(l*t*(-1))))) + (((1-b)*(v-g*(A*exp(h*t)*b*S)^(1-g)*z^(g-1)))/(u)) ) ) + ( ( (b*(A*exp(h*t)+S)*z)/(A*exp(h*t)*S) ) * ( S*A*exp(h*t)*h + (A*exp(h*t)) * ((A*exp(h*t)*b*S)^(1-g)*z^g - v*z - c - (1+(k*exp(l*t*(-1))))*A*exp(h*t)*b*S) ) );
[VF,Subs] = odeToVectorField(eqn1,eqn2,eqn3,eqn4);
odefcn = matlabFunction(VF, 'Vars',{t,A,Y,b,d,g,h,k,l,r,u,v,w});
A=3;
b=0.4;
g=0.3;
h=0.3;
v=2;
k=4;
l=0.7;
u=10;
d=0.2;
r=0.5;
w=0.7;
tspan = [0 1000];
y0 = [100 60 30 50];
[t,Y] = ode45(@(t,Y) odefcn(t,A,Y,b,d,g,h,k,l,r,u,v,w) , tspan, y0);
P_1 = Y(:,1);
S_1 = Y(:,2);
c_1 = Y(:,3);
z_1 = Y(:,4);
AF_1 = A*exp(h*t);
x_1 = b*S.*AF;
Now I wanna see where the marginal product of x is lower than the MP of z so I am doing that:
MPx = (1-g)*(b*A*exp(h*t).*S_1).^(-g).*z_1.^g*b.*(A*exp(h*t)+S_1);
MPz = g*(b*A*exp(h*t).*S_1).^(1-g).*z_1.^(g-1);
m = find(MPx(:,1)<MPz(:,1));
i = size(m);
For the values that MPx is lower than MPz I will run the previous code again but for g = 0.7 now instead of 0.3 and then I wanna replace the values of all P_1, S_1, c_1, z_1, x_1 with the new values that I will get from the new code but only in the specific rows for which hold that MPx < MPz.
So I am running this part again:
g=0.7;
tspan = [0 1000];
y0 = [100 60 30 50]; %even with initial values equal to 1 for all, the plots are the same
[t,N] = ode45(@(t,N) odefcn(t,A,N,b,d,g,h,k,l,r,u,v,w) , tspan, y0);
P_2 = N(:,1); %check the size by size(P)
S_2 = N(:,2);
c_2 = N(:,3);
z_2 = N(:,4);
AF_2 = A*exp(h*t);
x_2 = b*S.*AF;
And now I wanna do something that will help me substitutes the values of P_1 etc with the values of P_2 etc in the rows for which MPx < MPz.
Any help would be really appreciated.
Thanks in advance.
  3 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!