TransWikia.com

NDSolve: how the initial step of finding explicit derivatives can be avoided?

Mathematica Asked on October 29, 2020

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.

  1. Formulate ODEs in a vector form (not always possible).
  2. Use some Method options (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}]

One Answer

The current example in the OP does not produce a cannot-solve error message (although it does give a NDSolve::ndsz stiffness/singularity warning). In any case, it sometimes work to hide the complicated right-hand sides behind a black-box function. In this case the NDSolve::ndsz warning goes away.

n = 3;
x = RandomReal[1., {n, n, n, n}];
w = RandomReal[1., {n, n}];
w = w + Transpose[w];
Clear[y, z];
rhsY[x_?ArrayQ, y_?ArrayQ, z_?ArrayQ] := 
  I w.y + TensorContract[
    TensorProduct[x, z], {{2, 6}, {3, 7}, {4, 8}}];
eqY = y'[t] == rhsY[x, y[t], z[t]];
rhsZ[x_?ArrayQ, y_?ArrayQ, z_?ArrayQ] := 
  I z + Transpose[y.Transpose[y.x.y, {2, 1, 4, 3}].y, {2, 1, 4, 3}];
eqZ = z'[t] == rhsZ[x, y[t], z[t]];
icY = y[0] == IdentityMatrix[n];
icZ = z[0] == ConstantArray[0, {n, n, n, n}];
NDSolve[{eqY, eqZ, icY, icZ}, {y, z}, {t, 0, 2}]

[V12.1.1, Mac, in case it matters.]

Correct answer by Michael E2 on October 29, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP