# Calculating the constants in the general solution of second order homogeneous ODE reduced from Riccati equation

I am writing a code to simulate a kind of volumetric flow, and I have encountered the non-linear Riccati equation in its general form near the end of my calculations. I am having trouble finding the formulas for determining the constants so I'll write down my calculations so far. The first part is similar to the reduction process described in the linked Wikipedia page:

Starting equation: $y' = q_0+q_1y+q_2y^2$.

Initial conditions: $y(0) = V_0$ and $y'(0) = dV_0$, where $V_0$ and $dV_0$ are constants input by the user and belong to $\mathbb{R}^+$

In my case, $q_0$ and $q_1$ are functions of time $t$, and $q_2$ is a constant in $\mathbb{R}$

Setting $v=yq_2$ yields: $v'=v^2+Rv+S$, where $R = q_1 + \frac{q_2'}{q2} = q_1$ and $S=q_2q_0$

Fast forwarding through the reduction with $v=-u'/u$ gives $u''-Ru'+Su=0$ which is a homogeneous second order ordinary differential equation.

Assuming that $R^2 > 4S$ for the purpose of this question and setting $\Delta = \sqrt{R^2-4S}$ so I don't have to carry the square root around, the solution is of the form: $u_c = C_1e^{(R+\Delta)t/2}+C_2e^{(R-\Delta)t/2}$ and $y_c = -\frac{u_c'}{q_2u_c}$

Calculating the constants using the initial values:

\begin{align} y(0) &= -\frac{u'(0)}{q_2u(0)} = - \frac{(R+\Delta)C_1 + (R-\Delta)C_2}{2q_2(C_1+C_2)} = V_0 \hspace{7.25cm} (1)\\ y'(0) &= \frac{u'(0)u'(0)-u''(0)u(0)}{q_2u^2(0)} = - \frac{4(R'+\Delta')C_1^2+(8R'+\Delta^2)C_1C_2+4(R'-\Delta')C_2^2}{4q_2(C_1+C_2)^2} = dV_0 \;(2) \end{align}

Rearranging equation (1):

$$C_1 =\frac{\Delta -R-2q_2V_0}{\Delta +R+2q_2V_0} C_2 = KC_2$$

Inserting the value of $C_1$ in equation (2) causes $C_2$ to vanish:

\begin{align} \require{cancel} \frac{4(R'+\Delta')C_1^2+(8R'+\Delta^2)C_1C_2+4(R'-\Delta')C_2^2}{4q_2(C_1+C_2)^2} &= dV_0\\ \frac{4K^2(R'+\Delta')\cancel{C_2^2}+K(8R'+\Delta^2)\cancel{C_2^2}+4(R'-\Delta')\cancel{C_2^2}}{16q_2\cancel{C_2^2}(K+1)^2} &= dV_0\\ \end{align}

My questions are:

• Am I following a wrong procedure?
• What is the correct way to determine $C_1$ and $C_2$ given the described constraints?

The touble seems to come in the relationship between the respective initial conditions of the Riccati ODE and the second order linear ODE. In your wording, you give two initial conditions $y(0)=V_0$ and $y'(0)=dV_0$ . This is overmuch because the Riccati ODE is a first order ODE. To numerically solve the Riccati ODE, you don't need two constants, but only one.

The second constant of the second order linear ODE is necessary when you come back from the solution of the Riccati ODE to the solution of the second order linear ODE. There is a numerical integration to go from $v(t)$ to $u(t)$ with your notations or from $y(t)$ to $f(t)$ with the notations below. So, at this point, the second condition seems to be missing in the wording.