0

In most of the below answers for complex matrix differential equations, the odeintw package has been suggested. https://stackoverflow.com/a/45970853/7952027

https://stackoverflow.com/a/26320130/7952027

https://stackoverflow.com/a/26747232/7952027

https://stackoverflow.com/a/26582411/7952027

I want to know the theory behind the manipulations done in the code of odeintw. Like why one has to build that banded jacobian, the idea behind the functions _complex_to_real_jac, _transform_banded_jac, etc.

Tejas Shetty
  • 685
  • 6
  • 30
  • 1
    A complex matrix space is a real vector space, so a complex matrix can be represented by an array of real numbers preserving this linear structure. All odeintw has to do is to wrap odeint or better the function given to it with this basis transformation, forward and backwards. – Lutz Lehmann Jan 25 '21 at 07:59
  • I think the issue is non-trivial. – Tejas Shetty Jan 25 '21 at 08:03
  • 1
    Yes, it is that trivial. Now if you want to speed up the computation by providing the Jacobian, it also needs to be translated into the real form. In the method of lines as example you get banded Jacobians, the translation has to keep that property for efficiency reasons. – Lutz Lehmann Jan 25 '21 at 08:30
  • 2
    The nontrivial part arises when you want to specify the Jacobian via the `Dfun` argument. The complex Jacobian requires that the right-hand side of the equation be complex differentiable (i.e. [holomorphic](https://en.wikipedia.org/wiki/Holomorphic_function)). For example, the function f(z) = z* (the complex conjugate) is not complex differentiable, so you can't specify a complex Jacobian for the equation dz/dt = z*. You would have to rewrite it as a system of real equations. (This example is in the docstring of `odeintw`.) – Warren Weckesser Jan 25 '21 at 09:35
  • 1
    If the right-hand side is complex differentiable, then you can give a complex Jacobian via `Dfun`. – Warren Weckesser Jan 25 '21 at 09:40
  • Where can I read more about this "method of lines" @LutzLehmann – Tejas Shetty Jan 25 '21 at 09:46
  • Where can I read more about whatever you spoke @WarrenWeckesser – Tejas Shetty Jan 25 '21 at 09:46
  • 1
    M-o-L is a common method in solving PDE of the heat or wave equation type. Essentially, it discretizes the space dimension(s) while leaving the time dimension continuous, resulting in a large-dimensional ODE system in time direction. The resulting Jacobians only are non-zero at nearest-neighbor interactions, thus very sparse, and have a banded structure if the discretization is via a regular grid. – Lutz Lehmann Jan 25 '21 at 10:02
  • Can https://stackoverflow.com/a/65838993/7952027 be used instead of odeintw ?@LutzLehmann – Tejas Shetty Jan 25 '21 at 10:29
  • Can https://stackoverflow.com/a/65838993/7952027 be used instead of odeintw? @WarrenWeckesser – Tejas Shetty Jan 25 '21 at 10:29
  • yes it seems so – Tejas Shetty Apr 03 '21 at 14:33

1 Answers1

0

The answer is in the comments.

A complex matrix space is a real vector space, so a complex matrix can be represented by an array of real numbers preserving this linear structure. All odeintw has to do is to wrap odeint or better the function given to it with this basis transformation, forward and backward.

Now if you want to speed up the computation by providing the Jacobian, it also needs to be translated into the real form. In the method of lines as example you get banded Jacobians, the translation has to keep that property for efficiency reasons.

M-o-L is a common method in solving PDE of the heat or wave equation type. Essentially, it discretizes the space dimension(s) while leaving the time dimension continuous, resulting in a large-dimensional ODE system in time direction. The resulting Jacobians only are non-zero at nearest-neighbor interactions, thus very sparse, and have a banded structure if the discretization is via a regular grid.

The nontrivial part arises when you want to specify the Jacobian via the Dfun argument. The complex Jacobian requires that the right-hand side of the equation be complex differentiable (i.e. holomorphic). For example, the function f(z) = z* (the complex conjugate) is not complex differentiable, so you can't specify a complex Jacobian for the equation dz/dt = z*. You would have to rewrite it as a system of real equations. (This example is in the docstring of odeintw.)

If the right-hand side is complex differentiable, then you can give a complex Jacobian via Dfun.

Tejas Shetty
  • 685
  • 6
  • 30