There are several posts here devoted to resolving the following error message of NDSolve (NDSolve::ntdvdae,
NDSolve::ntdv)
Cannot solve to find an explicit formula for the derivatives
The reason for this message is quite obvious: when ordinary differential equations (ODEs) become quite complicated, MA cannot write them in the form
$$\dot{y}_i=f_i(y,t).$$
To the best of my knowledge there are 2 strategies of dealing with it.
- Formulate ODEs in a vector form (not always possible).
- Use some
Methodoptions (they typically change ODEs to DAEs and employ a simpler solver).
One of the deficiencies of the 2nd route is that it (Implicit Differential-Algebraic IDA) does not work for complex functions. On the other hand, the structure of my ODEs is such that a vector form is not fully possible:
$$\dot{y}(t)=f(y(t),\vec{v}(t),t),\\ \dot{\vec{v}}(t)= M[\vec{v}(t),y(t)]. $$
The right hand side (rhs) of the second vector equation can be expressed as some tensor contraction. $f$ cannot be expressed as some matrix operation on $\vec v(t)$. Even though, the given ODEs have explicit derivatives in the left hand side (lhs), MA tries hard to analyze the rhs, and fails because equations on the right hand side are difficult. So my question is, how can we indicate that the given system of ODEs already has derivatives in an explicit form on the left hand side and urge MA to proceed with a numerical integration.
Just to repeat my question in a simple form. My 1st-order ODEs always have explicit derivatives on the left hand side and a functional of unknown functions and time on the right hand side. How to enforce numerical integration without algebraic preprocessing?
Edit: an attempt to construct a minimal example
n = 3;
x = RandomReal[1., {n, n, n, n}];
w = RandomReal[1., {n, n}];
w = w + Transpose[w];
Clear[y, z];
eqY = y'[t] == I w.y[t] +
TensorContract[TensorProduct[x, z[t]], {{2, 6}, {3, 7}, {4, 8}}];
eqZ = z'[t] == I z[t] +
Transpose[ y[t].Transpose[y[t].x.y[t], {2, 1, 4, 3}].y[t], {2, 1, 4, 3}];
icY = y[0] == IdentityMatrix[n];
icZ = z[0] == ConstantArray[0, {n, n, n, n}];
NDSolve[{eqY, eqZ, icY, icZ}, {y, z}, {t, 0, 2}]
NDSolve[{y'[t] == 1, z'[t] == {2, 3}, y[0] == 0, z[0] == {4, 5}}, {y, z}, {t, 0, 2}]– xzczd Sep 24 '20 at 11:45y[t]alone are perfectly solvable. Add an equation forz[t]tensor and everything breaks down. Notice, that I do not get here an error message as in my real example. It can indicate that there is another problem operating here. – yarchik Sep 24 '20 at 12:23z[t]is a scalar, right? – xzczd Sep 24 '20 at 12:31z[t]is{n,n,n,n}tensor. – yarchik Sep 24 '20 at 12:32zis wrong. You need e.g.icZ = z[0] == ConstantArray[0, {3, 3, 3, 3}];. – xzczd Sep 24 '20 at 12:33y[t]matrix has some complicated contraction in it.NDSolvecan solve it. But the problem is with my abstract formulation: theTensorContract/TensorProductis extremely memory hungry $\mathcal{O}(n^8)$. – yarchik Sep 24 '20 at 12:58Compiled combination ofTableandSumwill be a better choice. – xzczd Sep 24 '20 at 13:07NDSolvegives the messageCannot solve to find an explicit formula for the derivatives. Usually I am usingFlattenform of equations andCoefficientArraysto get matrix and put equations in an explicit form. – Alex Trounev Sep 24 '20 at 16:25Sums. It is correct? – yarchik Sep 24 '20 at 17:37y[i,j,k,l][t]I need to make additional step withFlattenandCoefficientArraysto procide withNDSolve. – Alex Trounev Sep 25 '20 at 11:26