# The periodic condition is added to the differential equation

I want to solve this differential equation

$$\frac{1}{\Phi(\phi)} \frac{d^2 \Phi}{d \phi^2}=-m^2$$

with b.c.

$$\Phi(\phi+2 \pi)=\Phi(\phi)$$

it is easy to solve by wolfram

eq1 = D[Phi[phi], {phi, 2}]/Phi[phi];
sol1 = DSolve[eq1 == -m^2, Phi[phi], phi];


out is {{Phi[phi] -> C[1] Cos[m phi] + C[2] Sin[m phi]}}

In QUANTUM CHEMISTRY by McQuarrie(https://libgen.unblockit.cat/libraryp2/main/0FAA97ECA7C67AEAE6D4DD67E0217420)

$$\Phi(\phi)=A_m e^{i m \phi} \quad \text { and } \quad \Phi(\phi)=A_{-m} e^{-i m \phi}$$

periodicity condition

$$\Phi(\phi+2 \pi)=\Phi(\phi)$$

so $$\begin{gathered} A_m e^{i m(\phi+2 \pi)}=A_m e^{i m \phi} \\ A_{-m} e^{-i m(\phi+2 \pi)}=A_{-m} e^{-i m \phi} \end{gathered}$$

by all of above can get

$$e^{\pm i 2 \pi m}=1$$

so

$$m=0, \pm 1, \pm 2, \ldots$$

finally

$$\Phi_m(\phi)=A_m e^{i m \phi} \quad m=0, \pm 1, \pm 2, \ldots$$

the periodicity condition $$\Phi(\phi+2 \pi)=\Phi(\phi)$$,How do I add periodicity conditions to my code?

In general mathematical physics equations,can be get this $$\Phi(\phi)=A_m \mathrm{e}^{\mathrm{i} m \phi}+A_{-m} \mathrm{e}^{-\mathrm{i} m \phi} \quad(m=0,1,2 \cdots)$$

• "by hand can get this $\Phi(\phi)=A_m e^{i m \phi} \quad \text { and } \quad \Phi(\phi)=A_{-m} e^{-i m \phi}$" How do you get this? As shown in Nasser's answer the general solution is $A_m e^{i m \phi} +A_{-m} e^{-i m \phi}$ Commented Sep 15, 2022 at 3:34
• @xzczd you can download this book in libgen.unblockit.cat/libraryp2/main/… ,page 270~271 Commented Sep 15, 2022 at 3:37
• Aha, Quantum Chemistry textbook, then it's not surprising to find unrigorous deduction. (And it's not even a deduction actually, the textbook simply claim the solution is $\Phi(\phi)=A_m e^{i m \phi} \quad \text { and } \quad \Phi(\phi)=A_{-m} e^{-i m \phi}$. ) Commented Sep 15, 2022 at 4:44
• @xzczd it seem to be dealt with in the general mathematical and physical methods books Commented Sep 15, 2022 at 5:39

Just change constants.

ClearAll[Phi, phi, m];
eq1 = D[Phi[phi], {phi, 2}]/Phi[phi];
sol = Phi[phi] /. First@DSolve[eq1 == -m^2, Phi[phi], phi]


sol = TrigToExp[sol]


Now the idea is to collect on the exponential terms

sol = Collect[sol, {E^(-I m phi), E^(I m phi)}]


We are free now to rename the constants (even if they are complex, it does not matter)

sol = sol /. {C[1]/2 - (I C[2])/2 -> A0, C[1]/2 + (I C[2])/2 -> A1}


Which is what book says

$$\Phi_m(\phi)=A_m e^{i m \phi} \quad m=0, \pm 1, \pm 2, \ldots$$

Update

Answer the comment below. If the book meant to show the negative side also, then this can be done by expanding each term of the solution using FourierSeries and then applying TrigToExp on each term and collecting.

For example for n=2 applied on Cos[m phi] gives

tab1 = Table[FourierSeries[Cos[m*phi], phi, n], {n, 0, 2}]
tab1 = Map[TrigToExp[#] &, tab1]


Then need to do the same for Sin[ m phi] and add and simplify. This will give answer for infinite terms as shown in book.

I do not have the time to write this fully now. If someone wants to do it, they are welcome to.

I read it as just they wanted to rewrite the solution are sum of only 2 complex exponentials instead of two trig functions. But I could be wrong on this.

• This isn't complete, the condition $m=0, \pm 1, \pm 2, \ldots$ hasn't been deduced. Commented Sep 15, 2022 at 3:24
• Which is what book says? you can down this book in libgen.unblockit.cat/libraryp2/main/… page 270~271 Commented Sep 15, 2022 at 3:28
• you seem forget this Φ(ϕ+2π)=Φ(ϕ) Commented Sep 15, 2022 at 3:31
• @xzczd I did not look at it as they wanted the Fourier series expansion of the solution. But may be that is why wanted. Applying FourierSeries on each term of the solution should give the negative and positive terms. But I do not have time to code it now. Please feel free to post your answer on this as needed. Commented Sep 15, 2022 at 3:38
• OK, I've posted a complete solution. Commented Sep 15, 2022 at 4:20

First of all, the deduction in Quantum chemistry by McQuarrie is not rigorous (if we don't call it incorrect). As shown in Nasser's answer, the general solution (when no b.c. is imposed) is

generalsol[phi_] =
With[{ϕ = Phi[phi]},
Collect[DSolveValue[{D[ϕ, {phi, 2}]/ϕ == -m^2}, ϕ, phi] //
TrigToExp, E^_, Simplify] /. {C[1] - I C[2] -> 2 Subscript[A, "m"],
C[1] + I C[2] -> 2 Subscript[A, -"m"]}]

(* E^(-I m phi) Subscript[A, -"m"] + E^(I m phi) Subscript[A, "m"] *)


which is not the separate

$$\Phi(\phi)=A_m e^{i m \phi} \quad \text { and } \quad \Phi(\phi)=A_{-m} e^{-i m \phi}$$

Then what's the rigorous way to deduce the desired solution? To deduce it, we need to be aware of the following facts:

1. Though often written as a single $$Φ(ϕ+2π)=Φ(ϕ)$$ in various materials, when we say periodic boundary condition (b.c.) is imposed, usually it means we're imposing $$Φ(ϕ+2π)=Φ(ϕ)$$, $$Φ'(ϕ+2π)=Φ'(ϕ)$$, $$Φ''(ϕ+2π)=Φ''(ϕ)$$, …. The number of imposed periodic b.c.s depends on the order of differential equations.

2. DSolve (at least for now) is still a solver for generally valid solution i.e. the solutions that are only valid for $$m=0,±1,±2,…$$ i.e. $$m\in \mathbb{Z}$$ cannot be directly found by DSolve. (This behavior is similar to that of Solve. If you don't know what I mean, try Solve[{a + 1 == 0, b == 0}, a] and Solve[{a + 1 == 0, b == 0}, a, MaxExtraConditions -> Infinity]. )

OK, keep the facts in mind, let's start. With generalsol at hand, we just need to deduce $$m\in \mathbb{Z}$$. The ODE is of 2nd order, so we need 2 periodic b.c.s Phi[0] == Phi[2 Pi], Phi'[0] == Phi'[2 Pi]. Substitute the general solution into these and Reduce:

Reduce[{Phi'[0] == Phi'[2 Pi], Phi[0] == Phi[2 Pi]} /. Phi -> generalsol,
m] // FullSimplify
(*
(C[1] ∈
Integers && (m == 1 + 2 C[1] || m == 2 C[1])) || (Subscript[A, -"m"] == 0 &&
Subscript[A, "m"] == 0) || (Subscript[A, -"m"] == Subscript[A, "m"] && m == 0)
*)


$$(c_1\in \mathbb{Z}\land (m=1+2 c_1\lor m=2 c_1))\lor \left(A_{-\text{m}}=0\land A_{\text{m}}=0\right)\lor \left(A_{-\text{m}}=A_{\text{m}}\land m=0\right)$$

$$A_{-\text{m}}=0\land A_{\text{m}}=0$$ corresponds to the general trivial solution, which will be obtained if we substitute the 2 periodic b.c.s into DSolve:

phisol = DSolve[{D[Phi[phi], {phi, 2}]/Phi[phi] == -m^2, Phi[0] == Phi[2 Pi],
Phi'[0] == Phi'[2 Pi]}, Phi[phi], phi]

(* {{Phi[phi] -> 0}} *)


$$(c_1\in \mathbb{Z}\land (m=1+2 c_1\lor m=2 c_1))\lor \left(A_{-\text{m}}=A_{\text{m}}\land m=0\right)$$ is equivalent to $$m\in \mathbb{Z}$$. (Sadly I haven't found a way to make Mathematica prove this equivalence, but I think this is obvious enough. )

Alternatively, we can use Solve with Reduce option:

Solve[{Phi'[0] == Phi'[2 Pi], Phi[0] == Phi[2 Pi]} /. Phi -> generalsol, m,
Method -> Reduce] // Simplify
(*
{{m -> ConditionalExpression[2 C[1], Element[C[1], Integers]]},
{m -> ConditionalExpression[1 + 2 C[1], Element[C[1], Integers]]}}
*)


The result is cleaner, but still, I haven't found a way to make Mathematica prove it's equivalent to $$m\in \mathbb{Z}$$.

• As you get (C[1] \[Element] Integers && (m == 1 + 2 C[1] || m == 2 C[1]) ,it is actually the exact solution,But all the books I read are m=0,-+1,-+2⋯ Commented Sep 15, 2022 at 6:06
• @我心永恒 Yes, and that's what I said in last paragraph. Commented Sep 15, 2022 at 6:17

There is PeriodicBoundaryCondition. The syntax is a bit complicated:

PBC=PeriodicBoundaryCondition[Phi[phi],phi==2*Pi,phi|->phi-2*Pi];


This can be used with some solvers such as

{vals,funs}=NDEigensystem[{Phi''[phi],PBC},Phi[phi],{phi,0,2*Pi},10];


This will compute the first 10 eigenvalues and eigenfunctions

vals
(* {0.,-1.00001,-1.00001,-4.00085,-4.00085,-9.00943,-9.00943,-16.0513,-16.0513,-25.1881} *)


This is a numerical result and contains numerical errors, the actual numbers are of course $$0,-1,-1,-4,-4,-9,-9,-16, \ldots$$ corresponding to $$-m^2$$ in OPs question.

To plot the eigenfunctions, use for example

Plot[{funs[[6]],funs[[7]]},{phi,0,2*Pi}]


which are linear combinations of $$e^{3i\phi}$$ and $$e^{-3i\phi}$$ in OPs question.