0
$\begingroup$

Here is a simple problem where I want to estimate the center manifold using a series expansion. I want to solve for the coefficients:

adot[a_, b_] := -a^2 + α a b
bdot[a_, b_] := a^2 - α a b - b
bseries[a_] := Sum[Subscript[b, n] a^n, {n, 0, 3}]
CoefficientList[bdot[a, bseries[a]] - D[bseries[a], a] adot[a, bseries[a]], a]

At this point, I'd like to set each of coefficients to zero simultaneously. Is there a smarter way to do this, rather than just copy and paste each of them into to solve and set them to 0? I'd imagine there is, thanks for the help.

$\endgroup$
  • $\begingroup$ I would suggest making alpha a parameter of the function adot and bdot as well - global variables are going to give you lots of trouble. If you wrap the final calculation in with, With[{a=0,b=0},CoefficientList[...]], you can quickly change the values used for that calculation. $\endgroup$ – N.J.Evans Aug 4 '17 at 14:13
5
$\begingroup$

Updated to include more details

I would use Series instead of Sum here. First your input:

adot[a_,b_]:=-a^2+α a b
bdot[a_,b_]:=a^2-α a b-b

lhs[b_]:=bdot[a,b]-D[b,a] adot[a,b];

Now, let's take the series expansion of b[a]:

ansatz = Series[b[a], {a, 0, 4}];
ansatz //TeXForm

$b(0)+a b'(0)+\frac{1}{2} a^2 b''(0)+\frac{1}{6} a^3 b^{(3)}(0)+\frac{1}{24} a^4 b^{(4)}(0)+O\left(a^5\right)$

Putting the ansatz into the expression that should be 0:

ser = lhs[ansatz];
ser //TeXForm

$-b(0)+a \left(-\alpha b(0) b'(0)-b'(0)-\alpha b(0)\right)+a^2 \left(-\alpha b(0) b''(0)-\frac{b''(0)}{2}-\alpha b'(0)-b'(0) \left(\alpha b'(0)-1\right)+1\right)+a^3 \left(-\frac{1}{2} \alpha b(0) b^{(3)}(0)-\frac{1}{6} b^{(3)}(0)-\frac{1}{2} \alpha b''(0)-\frac{1}{2} \alpha b'(0) b''(0)-b''(0) \left(\alpha b'(0)-1\right)\right)+a^4 \left(-\frac{1}{6} \alpha b(0) b^{(4)}(0)-\frac{1}{24} b^{(4)}(0)-\frac{1}{6} \alpha b^{(3)}(0)-\frac{1}{2} \alpha b''(0)^2-\frac{1}{6} \alpha b^{(3)}(0) b'(0)-\frac{1}{2} b^{(3)}(0) \left(\alpha b'(0)-1\right)\right)+O\left(a^5\right)$

We want to set each coefficient to 0, and Solve is capable of doing this without further preprocessing. All we need to do is to figure out what the unknowns are, which in this case are {b[0], b'[0], b''[0], ...}. We can extract these from ser using:

unknowns = Cases[ser, (b | Derivative[_][b])[0], Infinity] //Union;
unknowns //TeXForm

$\left\{b(0),b'(0),b''(0),b^{(3)}(0),b^{(4)}(0)\right\}$

Finally, we can use Solve to find the unknowns:

sol = First @ Solve[ser == 0, unknowns];
sol //TeXForm

$\left\{b(0)\to 0,b'(0)\to 0,b''(0)\to 2,b^{(3)}(0)\to -6 (\alpha -2),b^{(4)}(0)\to 24 \left(\alpha ^2-7 \alpha +6\right)\right\}$

Inserting these unknowns into the ansatz:

res = ansatz /. sol;
res //TeXForm

$a^2+(2-\alpha ) a^3+\left(\alpha ^2-7 \alpha +6\right) a^4+O\left(a^5\right)$

Inserting the ansatz into the expression:

lhs[res] //TeXForm

$O\left(a^5\right)$

Another method

It is also possible to use Solve without specifying the unknowns, although it may not be completely robust:

sol2 = First @ Solve[CoefficientList[ser, a] == 0];

res2 = ansatz /. sol2;
res2 //TeXForm

$a^2+(2-\alpha ) a^3+\left(\alpha ^2-7 \alpha +6\right) a^4+O\left(a^5\right)$

$\endgroup$
  • $\begingroup$ Can you possibly explain the syntax in the line after Ansatz? $\endgroup$ – Gregory Aug 4 '17 at 18:36
  • $\begingroup$ @Gregory See update. $\endgroup$ – Carl Woll Aug 4 '17 at 20:49
  • $\begingroup$ SolveAlways[], can be used instead: SolveAlways[lhs[Series[b[a], {a, 0, 4}]] == 0, a] $\endgroup$ – J. M. will be back soon Aug 4 '17 at 22:19
  • $\begingroup$ @CarlWoll, the Derivative[_][b] tells Mathematica to solve for any derivative that it sees of b? $\endgroup$ – Gregory Aug 4 '17 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.