6
$\begingroup$

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] 
$\endgroup$
1

1 Answer 1

7
$\begingroup$

The question is how to get eqn11 and eqn12 automatically, introducing the additional separation constant k2^2. Here is one way of doing it:

eqn11 = Expand@Simplify[(Select[ Apply[Subtract, eqn1], (D[#, θ] == 0 &)]) == k2^2] 

$$-\text{k1}^2 r^2+\frac{r^2 R''(r)}{R(r)}+\frac{r R'(r)}{R(r)}=\text{k2}^2$$

eqn12 = Expand@Simplify[(Select[ Apply[Subtract, eqn1], (D[#, θ] =!= 0 &)]) == -k2^2] 

$$\frac{\Theta ''(\theta )}{\Theta (\theta )}+\text{k2}^2=0$$

By applying Subtract to eqn1, I first bring all terms into one expression. Then I use Select to get the terms depending only on one of the variables each. The resulting expressions are then set equal to the common constant k2^2.

$\endgroup$
7
  • $\begingroup$ That works very well for [CapitalTheta][] and R[], thanks! How do I include [Theta] and r? $\endgroup$ Commented Sep 18, 2016 at 16:58
  • $\begingroup$ Can you elaborate on what you mean by "include"? I don't see where else they should appear. $\endgroup$ Commented Sep 18, 2016 at 17:31
  • $\begingroup$ In a more general situation, where I don't play tricks by multiplying by r^2when creating eqn1, I'd like to be able to (say) put r, R, R', R'' ... etc on one side and all the equivalent [Theta]'s on the other. $\endgroup$ Commented Sep 18, 2016 at 17:56
  • $\begingroup$ I think that will lead back to what I did in my answer here. I.e., divide by f and apply the same tricks as above to get the first separation. $\endgroup$ Commented Sep 18, 2016 at 18:09
  • $\begingroup$ Didn't work. I removed my 'multiply by r^2' hack and got an r below the line on eqn12. $\endgroup$ Commented Sep 18, 2016 at 18:27

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.