# numerical solution for coupled first order ODE

How can I numerically solve the below equation, assume I have $$K(z)$$, the solution is in the $$[0,L]$$ domain, the conditions are: $$A(0)=1, B(L)=1$$ $$1. \frac{dA}{dz} = -K(z)A(z) - K(z)B(z)$$ $$2. \frac{dB}{dz} = -K(z)A(z) - K(z)B(z)$$

• $A(z)-2B(z)=C_0$ Mar 31, 2021 at 10:00
• Do you really have identical right hand sides in both equations? In general, the problem has boundary values at different points, i.e. it is a boundary value problem, for which for example the shooting method (en.wikipedia.org/wiki/Shooting_method) or the collocation method (en.wikipedia.org/wiki/Collocation_method) can be used. Mar 31, 2021 at 17:16

## 1 Answer

We can decouple the equations by defining the functions $$F=A+B$$ and $$G=A-B$$. Then

$$\frac{dF}{dz}=-2K(z)F,\qquad\frac{dG}{dz}=0$$,

so that

$$F(z)=F_0\exp\left[-2\int_0^z K(t)dt\right],\qquad G(z)=G_0,$$

from which follows

$$A(z)=\frac{1}{2}F_0\exp\left[-2\int_0^z K(t)dt\right]+\frac{1}{2}G_0, \qquad B(z)=\frac{1}{2}F_0\exp\left[-2\int_0^z K(t)dt\right]-\frac{1}{2}G_0.$$

In order to determine $$F_0$$ and $$G_0$$, we use the boundary conditions $$\left(\xi = e^{-2\int_0^L K(t)dt}\right)$$

$$A(0) = \frac{1}{2}F_0+\frac{1}{2}G_0 = 1,\qquad B(L) = \frac{1}{2}F_0\xi-\frac{1}{2}G_0 = 1$$,

which yield

$$F_0=\frac{4}{\xi +1}, \qquad G_0=\frac{2(\xi-1)}{\xi+1}.$$

Use the numerical method of your choice to compute the integral $$\int_0^z K(t)dt$$.

• Thank you very much Ricardo, that is very helpful. By the way if you are intrested in the physical background of this broblem, these equations stem from the coupled mode theory (CMT) of 2 modes (propagate and co-propagate) in a cylindric waveguide. Apr 5, 2021 at 20:14
• This is the first step of the problem, i trying to find a numerical solution for a system of first order coupled ODE, i posted a question here (math.stackexchange.com/questions/4090787/…). It will be great if you have something to share over there. Apr 5, 2021 at 21:58