# Real ODE yields real solution through complex numbers

• I
• FranzS
I got the same real and imaginary parts as before!In summary, the problem is real, the expected solution is in ##\mathbb{R}## as well, and the solution obtained by solving the original integral equation*** step-by-step using very small discrete intervals is also correct.

#### FranzS

TL;DR Summary
ODE in the real domain requires calculations in the complex doman in order to yield a (real) solution
Hello,

I'm posting here since what follows is not about homework, but constitutes a personal research which underlies some more general questions.

As with the infamous "casus irreducibilis" (i.e. finding the real roots of a cubic function sometimes requires intermediate calculations with complex numbers), I found myself solving an ordinary differential equation which seems to require the same approach.

Before explaining the problem in detail, I'd like to anticipate what I wish to understand (with the help of you knowledgeable people) for the general case: when a problem is formulated in ##\mathbb{R}## with expected solutions also in ##\mathbb{R}## but solving it requires an "intermediate journey" in ##\mathbb{C} \, ##, is there a general approach to find a way (if any exists) to bypass that "intermediate journey" in ##\mathbb{C} \,##?

Now, my personal research addresses a specific problem which is indeed very real. It's about finding the pressure ##P## of a gas inside a container as a function of time ##t## when said gas is slowly flowing out from said container through an orifice. Well, the problem itself is slightly more detailed but you shouldn't bother about anything except for the math to come (the aim of this introduction is to show that it is a real-world problem whose domain is ##\mathbb{R}## and whose expected solution is in ##\mathbb{R}## as well). By the way, I apologise in advance for my possibly loose math language.
Also, I'd like to say that what follows lead "in a certain way" (more details hereafter) to the correct solution of the problem, but I cannot get my head around it about that "in a certain way" (again, more details hereafter).

My calculations lead to an ordinary differential equation which is separable and yields the following integral:

$$\int \frac{ dP(t) }{ \sqrt{a+b \, P(t)+c \, P^2(t) } } \, dx =-\alpha \, t + C$$

where ##a##, ##b##, ##c## and ##\alpha## are known parameters (and real numbers).
I'm not skilled enough to solve the integral myself, so I relied on a couple online solvers, which both gave the solution:

$$\frac{1}{\sqrt{c}} \log \left( 2 \sqrt{c} \sqrt{ a+b \, P(t)+c \, P^2(t) } + b + 2c \, P(t) \right) = -\alpha \, t + C$$

where ##log## is the natural logarithm.
Here arises the first problem: the parameter ##c## (which is under a square root) is negative.
If I don't bother and go on with the calculations, after a couple of rearrangements, I get the following equation for ##P(t) \, ##:

$$P(t) = \frac{k}{4 \, c} e^{ - \sqrt{c} \alpha \, t } + \frac{b^2-4 \, a \, c}{4 \, c \, k} e^{ + \sqrt{c} \alpha \, t } - \frac{b}{2 \, c}$$

where ##k## is the constant to be determined using the problem's initial conditions (it derives from the previous constant of integration ##C \, ##).
The initial condition (remember the physical problem?) is that the pressure ##P## is equal to a certain real value ##P_0## at the time ##t=0 \, ##.
Please note that the exponents of the two exponential terms (if we exclude the variable ##t \, ##) are purely imaginary (because of ## \sqrt{c} ## with ##c<0## ) and they only differ by a minus sign: that means that they are also complex conjugate.
Well, applying the constraint of the initial conditions yields a value of ##k## which makes the coefficient of the two exponential terms (the ones expressed in terms of ##a##, ##b##, ##c## and ##k## itself) complex conjugate as well.

Thus, with the final expression for ##P(t)## (which is the one above but with ##k## made explicit), I can throw in real values of the time ##t## and indeed get real values of the pressure ##P(t) \, ##.
And the values of ##P(t)## are correct. They match the values I got by solving the original integral equation*** step-by-step (using very small discrete intervals).
*** I mean the original integral equation I was solving, which leads to the differential equations that in turn leads to the first equation in this post.

So far so good but, as said at the beginning, I do not know if there is a way to bypass this "intermediate journey" in ##\mathbb{C} \, ##.

Now, the odd part. If I want to find the time ##t## for which ##P(t)=P_1## (where ##P_1<P_0## is a specific pressure of interest) and I solve the equation for ##P(t)## accordingly, I get a complex value as a result (comprised of both non-zero real and imaginary parts).
To double check, I used this "complex time" into the expression for ##P(t)## and it worked (it gave the real value ##P_1 \, ##).
What's strange to me is that the real part of this "complex time" seems to be the actual real-world solution (again, I compared it with the step-by-step numerical solution described above), in other words the real time for which ##P(t)=P_1 \, ##.
What is happening here?

Sorry for the lenghty post. I'd appreciate if anyone could chime in and enlighten me. Thank you!

FranzS said:
Summary: ODE in the real domain requires calculations in the complex doman in order to yield a (real) solution

Hello,

I'm posting here since what follows is not about homework, but constitutes a personal research which underlies some more general questions.

As with the infamous "casus irreducibilis" (i.e. finding the real roots of a cubic function sometimes requires intermediate calculations with complex numbers), I found myself solving an ordinary differential equation which seems to require the same approach.

Before explaining the problem in detail, I'd like to anticipate what I wish to understand (with the help of you knowledgeable people) for the general case: when a problem is formulated in ##\mathbb{R}## with expected solutions also in ##\mathbb{R}## but solving it requires an "intermediate journey" in ##\mathbb{C} \, ##, is there a general approach to find a way (if any exists) to bypass that "intermediate journey" in ##\mathbb{C} \,##?

Now, my personal research addresses a specific problem which is indeed very real. It's about finding the pressure ##P## of a gas inside a container as a function of time ##t## when said gas is slowly flowing out from said container through an orifice. Well, the problem itself is slightly more detailed but you shouldn't bother about anything except for the math to come (the aim of this introduction is to show that it is a real-world problem whose domain is ##\mathbb{R}## and whose expected solution is in ##\mathbb{R}## as well). By the way, I apologise in advance for my possibly loose math language.
Also, I'd like to say that what follows lead "in a certain way" (more details hereafter) to the correct solution of the problem, but I cannot get my head around it about that "in a certain way" (again, more details hereafter).

My calculations lead to an ordinary differential equation which is separable and yields the following integral:

$$\int \frac{ dP(t) }{ \sqrt{a+b \, P(t)+c \, P^2(t) } } \, dx =-\alpha \, t + C$$

Is this $$\int \frac{1}{\sqrt{cP^2 + bP + a}}\,dP = -\alpha t + C$$ with $c < 0$? The quadratic $cP^2 + bP + a$ then tends to $-\infty$ as $|P| \to \infty$ so it will be positive only between its real roots; the condition that these exist and are distinct is $b^2 - 4ac > 0$.

We can complete the square in the quadratic to obtain $$cP^2 + bP + a = c\left(P + \frac{b}{2c}\right)^2 + \frac{4ac - b^2}{4c}.$$ If $c < 0$ and the quadratic has distinct real roots then the constant term $\dfrac{4ac - b^2}{4c} = \dfrac{b^2 - 4ac}{4|c|}> 0$ and we may set $$P = -\frac{b}{2c} + \sqrt{\frac{b^2 - 4ac}{4|c|^2}}\sin \theta$$ with a much simpler integral, $$\begin{split} \int \frac{1}{\sqrt{cP^2+bP+a}}\,dP &= \frac{1}{\sqrt{|c|}}\int \frac{\cos\theta}{\sqrt{1 - \sin^2\theta}}\,d\theta \\ &= \frac{1}{\sqrt{|c|}}\theta \\ &= \frac{1}{\sqrt{|c|}} \arcsin\left(\sqrt{\frac{4|c|^2}{b^2 - 4ac}}\left(P + \frac{b}{2c}\right) \right). \end{split}$$ To compare this with the solution you obtained, recall that $$\begin{split} \sin x &= \frac{e^{ix} - e^{-ix}}{2i}, \\ \arcsin x &= -i \log\left( \sqrt{1-x^2} + ix\right).\end{split}$$

• topsquark
The prototypical example of this is the simple $$\ddot x = Cx$$ with solution $$x(t) = A\cosh(\sqrt{C}t) + B\sinh(\sqrt{C}t).$$ Now if $C < 0$ we set $\sqrt{C} = i\sqrt{|C|}$ and get $$\begin{split} x(t) &= A\cosh(i\sqrt{|C|}t) + B \sinh(i\sqrt{|C|}t) \\ &= A \cos(\sqrt{|C|}t) + iB\sin(\sqrt{|C|}t) \end{split}$$ which will be real for real $t$ provided $A$ is real and $B = -iD$ for real $D$.

• topsquark
pasmith said:
Is this $$\int \frac{1}{\sqrt{cP^2 + bP + a}}\,dP = -\alpha t + C$$ with $c < 0$? The quadratic $cP^2 + bP + a$ then tends to $-\infty$ as $|P| \to \infty$ so it will be positive only between its real roots; the condition that these exist and are distinct is $b^2 - 4ac > 0$.

We can complete the square in the quadratic to obtain $$cP^2 + bP + a = c\left(P + \frac{b}{2c}\right)^2 + \frac{4ac - b^2}{4c}.$$ If $c < 0$ and the quadratic has distinct real roots then the constant term $\dfrac{4ac - b^2}{4c} = \dfrac{b^2 - 4ac}{4|c|}> 0$ and we may set $$P = -\frac{b}{2c} + \sqrt{\frac{b^2 - 4ac}{4|c|^2}}\sin \theta$$ with a much simpler integral, $$\begin{split} \int \frac{1}{\sqrt{cP^2+bP+a}}\,dP &= \frac{1}{\sqrt{|c|}}\int \frac{\cos\theta}{\sqrt{1 - \sin^2\theta}}\,d\theta \\ &= \frac{1}{\sqrt{|c|}}\theta \\ &= \frac{1}{\sqrt{|c|}} \arcsin\left(\sqrt{\frac{4|c|^2}{b^2 - 4ac}}\left(P + \frac{b}{2c}\right) \right). \end{split}$$ To compare this with the solution you obtained, recall that $$\begin{split} \sin x &= \frac{e^{ix} - e^{-ix}}{2i}, \\ \arcsin x &= -i \log\left( \sqrt{1-x^2} + ix\right).\end{split}$$
Thanks a lot, that worked perfectly. So, it was all about my inability to solve non-trivial integrals!