I really have a problem here. I have not found a solution yet. The system I need to solve similar to this:(Basic idea)

$$c_1 = \dfrac{dx}{dr}+y$$

$$c_2 = \dfrac{dy}{dr}+x$$

Both $c_1/ c_2$ are equal to 0 meaning the desired system is: $$\dfrac{dy}{dr} = -x$$ and $$\dfrac{dx}{dr} = -y$$

The ODE system I wanna solve is the above with Initial Values given $(x0,y0,r0)$ and needs to be solved for the space $(r0,rf)$

Generally, the $c$ expressions are quantities of: x,y,dx,dy,r and more specific

IMPORTANT I'm in no position to solve with respect to dx,dy. Although this example is easy, (2 variables), I got 12 Variables and the Expr are super large.

Generally, I would like to solve this system:

$$A\cdot \dfrac{dX}{dr} + B\cdot X= 0 $$

where X is a set of Variables, and A,B are Square Matrix of the Length of X.

Is there any routine I can Solve it in that form?

  • 1
    $\begingroup$ I don't understand how both Expr are equal to zero, but also contain quantities x,y,dx,dy,r. $\endgroup$ – Wolfgang Bangerth Mar 11 at 20:27
  • 1
    $\begingroup$ I also don't understand what dx,dy are. Are these $dx/dt$ and $dy/dt$? $\endgroup$ – Wolfgang Bangerth Mar 11 at 20:28
  • 1
    $\begingroup$ And finally, since there does not appear to be a term $dr/dt$, how come you need/are given initial conditions r0 for this function? $\endgroup$ – Wolfgang Bangerth Mar 11 at 20:29
  • $\begingroup$ Is it possible to writing down the expressions by using LaTeX that we have here to make your question clearer? I agree Wolfgang cause it's not clear at all what you want to accomplish. $\endgroup$ – Alone Programmer Mar 11 at 20:58
  • $\begingroup$ @AloneProgrammer I did use Latex now. Sorry for not using before :( 1st time in this SE. Thought I could not write. $\endgroup$ – billy Mar 11 at 22:20

You are trying to solve this matrix ODE system as:

$$A \mathbf{x}^{'}(r) = -B \mathbf{x}(r)$$

where: $\mathbf{x}^{'}(r) = \frac{d \mathbf{x}}{dr}$. If $A$ is invertible:

$$\mathbf{x}^{'}(r) = -A^{-1} B \mathbf{x}(r)$$

The general solution is:

$$\mathbf{x}(r) = \sum_{i=1}^{n} c_{i} \exp{(\lambda_{i} r)} \mathbf{u}_{i}$$

Where $\lambda_{i}$ and $\mathbf{u}_{i}$ are eigenvalue and eigenvector of $-A^{-1} B$ matrix. These eigenvalues and eigenvectors can be extracted easily by something like SVD. $c_{i}$ are constants that depend on your initial condition $\mathbf{x}(0)$. I'm not sure why you got stuck because as Wolfgang said it is just very routine method to solve system of ODEs.

Update: A less expensive approach to avoid inverting $A$ directly, may be using a backward Euler method to solve this system of ODEs numerically:

$$A \frac{\mathbf{x}(r+\Delta r) - \mathbf{x}(r)}{\Delta r} = -B \mathbf{x} (r+\Delta r)$$


$$(A + \Delta r B) \mathbf{x} (r+\Delta r) = A \mathbf{x} (r)$$

Please be aware that to work with all of these methods including the direct method to invert $A$ and this numerical scheme, you must have $A$ and $B$ available. The above equation is just a linear equation when you know $\mathbf{x}(r)$ from previous step and you can solve for $\mathbf{x}(r+\Delta r)$ by using any linear equation solver available in Python, C, C++, etc.

| cite | improve this answer | |
  • $\begingroup$ Sorry I asked this. Although with this method seperate ALL elements from the system. I only have the final Matrix $$C(X,X')=0$$ (1-Row) which can be written $$C(X,X') = AX'+BX =0$$ but I need to write functions to seperate each component, right? There is no easy way? $\endgroup$ – billy Mar 12 at 15:03
  • $\begingroup$ What do you mean I have the final matrix? $C$ is just a vector. Also, if you have just $C$, it means you have a vector with all components equal to zero... so what? I agree @WolfgangBangerth, your question is so vague... $\endgroup$ – Alone Programmer Mar 12 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.