0

I am trying to solve an ODE of the form: (d/dt) x = A * x

given the square matrix A and the vector x at t=0 in sympy. The system I am studying has more than 50 equations.

As I defined it above, I believe these equations are linear, homogeneous, and first-order. When I looked in the sympy documentation, I found something similar ("system_of_odes_linear_neq_order1_type1"). I defined the system and am trying to solve with a command like so:

sympy.dsolve(system,hint='system_of_odes_linear_neq_order1_type1') The script has been running for a while without terminating so I'm getting a bit worried. On second look, I saw the system being called "nonhomogeneous" in the documentation:

https://www.cfm.brown.edu/people/dobrush/am33/SymPy/part2.html#sympy.solvers.ode._linear_neq_order1_type1

Why is it called "nonhomogeneous" here? Is type of solver I used incorrect and should I redefine the system/solver? I don't see many other options for systems of differential equations where there are more than 3 equations.

Daylight
  • 1
  • 1
  • Is there any reason why you can't just use `expm(A*t) @ x0` or a similar idea? For a mass production of results it would be cheaper to do the expensive steps like the eigen-decomposition of `A` only once, or to push the multiplication with `x0` inside so that no matrix-matrix products are evaluated. – Lutz Lehmann Nov 12 '22 at 08:59
  • If you just call `dsolve` with the appropriate equations then it will try to compute the matrix exponential. However it will try to compute this matrix exponential symbolically which is probably going to fail for a 50x50 matrix (although that depends on the sparsity and the nature of the coefficients). – Oscar Benjamin Nov 12 '22 at 12:31
  • Thank you both for the comments! You've given me an idea. This dsolve thing seems to be too much. I may have another question later. – Daylight Nov 13 '22 at 10:04

0 Answers0