I'm trying to use Mathematica to solve various separable differential equations, but I'm trying to do this step-by-step - this is important! I am sort-of making notes to remind me how to do stuff, and the more that I expose the better I remember it. I know about DSolve[], and it works very well, but I want to expose certain internal steps in the process.
Following is an example, using polar co-ordinates in the plane, and the wave equation, but what I ask later I want to generalise to multiple co-ordinate systems:
First, I set up a separable function f[]
f[r_, θ_, t_] := R[r] Θ[θ] T[t]
Then I set up the wave equation:
WaveEqn = Laplacian[f[r, θ, t], {r, θ}, "Polar"] ==
1/c^2 D[f[r, θ, t], {t, 2}] // Simplify // Expand
... where the // Simplify // Expand
at the end makes it all look nice and clean.
Now I split the equation at the equals sign:
{lhs, rhs} = {WaveEqn[[1]]/f[r, θ, t] // Simplify // Expand,
WaveEqn[[2]]/f[r, θ, t] // Simplify // Expand}
Yes, I know I could have done this directly instead of making WaveEqn
an equation; bear with me.
Now I tidy up the LHS and introduce k1^2
, the constant of separation. This will give me an equation that I want to separate like the {lhs,hrs}
above, except that \Theta[]
and R[]
will both be on the LHS. What I really want is r
, R[]
and its derivatives on the LHS, and θ
, Θ[]
and its derivatives on the RHS. The r^2
factor is a hack to clean up the terms:
eqn1 = r^2 (lhs - k1^2) == 0 // Expand
And now the question. I did eqn11
and eqn12
below by hand by copy/pasting bits from the evaluation of eqn1
, and using k2^2
as the constant of separation. How can I do this automagically? Maple's collect()
operation does a pretty good job, but I now want to do this in Mathematica:
eqn11 = R[r] (-k1^2 r^2 +
(r Derivative[1][R][r])/R[r] +
(r^2 R^′′[r])/R[r] - k2^2)
== 0 // Simplify // Expand
eqn12 = Θ[θ]((Θ^′′)[θ]/Θ[θ]
- k2^2)
== 0 // Simplify // Expand
This was easy, as its part of the first split:
eqn2 = rhs - k1^2 == 0 // Simplify // Expand
Now solve everything. I include this for completeness; its not part of the actual question:
DSolve[eqn11, R[r], r]
DSolve[eqn12, Θ[θ], θ]
DSolve[eqn2, T[t], t]