Matlab Code to solve Matrix Differential Riccati Equation with Terminal constraint

264 Views Asked by At

I am new to the theory of MDRE and the following came up while I was going through the text by Dockener(2000)(page 181). They mention that the following coupled Riccati equations can be solved 'readily' by numerical methods. I am sure I am missing something, but i have not been able to figure out how to go about it in Matlab.

Without further ado:

$$\dot{v}_1(t)=g_1+rv_1(t)-b_1(v_1(t))^2-c_1v_1(t)v_2(t)$$ $$\dot{v}_2(t)=g_2+rv_2(t)-b_2(v_2(t))^2-c_2v_1(t)v_2(t)$$ With boundary conditions $v_1(T)=0,v_2(T)=0$

My initial hunch was that I could use Matlab's bvp4c or bvp5c boundary value problem solving routine to solve them, but my attempt was not successful. I fear that the lack of initial condition i.e $v_i(0)$ is to the fault. (The matlab documentation seems to suggest that i need the conditions for the beginning and end of the time period).

Any suggestion would be greatly appreciated. Here is the code I have used so far.

function dydx = bvpfcn(x,y) % equation to solve
 dydx = zeros(2,1);
 dydx(1)=0.2-5*y(1)-0.1*(y(1)^2)-2*y(1)*y(2)
 dydx(2)=0.22-5*y(2)-0.12*(y(2)^2)-2.5*y(1)*y(2)
 end

The boundary conditions are here

function res = bcfcn(ya,yb) % boundary conditions
res = [yb(2)
    yb(1)];
end

The initial guess is here

function g = guess(x) % initial guess for y and y'
g = [x^2
    x^2];
end

And the final call is this

xmesh = linspace(0,2,5);
solinit = bvpinit(xmesh, @guess);

The error that I am getting is

Error using bvp5c (line 266)
Unable to solve the collocation equations -- a singular Jacobian encountered

I did try solving the the example from the documentation using only two terminal conditions. And that seemed to work. I am not sure what is the missing bit here