I am using homotopy perturbation method to solve nonlinear ODE.
The first step is to introduce P parameter and collect different order of P.
The code is like this:
Collect[(1 -
p) ((((1 +
De^2 (Derivative[1][u0] + p Derivative[1][u1] +
p^2 Derivative[1][u2] + p^3 Derivative[1][u3])^2)^(
1/2 (-3 + n)) (1 +
De^2 n (Derivative[1][u0] + p Derivative[1][u1] +
p^2 Derivative[1][u2] +
p^3 Derivative[1][u3])^2) (Derivative[2][u0] +
p Derivative[2][u1] + p^2 Derivative[2][u2] +
p^3 Derivative[2][u3])) (Derivative[1][u0] +
p Derivative[1][u1] + p^2 Derivative[1][u2] +
p^3 Derivative[1][u3])) + (1 +
De^2 ((Derivative[1][u0] + p Derivative[1][u1] +
p^2 Derivative[1][u2] + p^3 Derivative[1][u3]))^2)^((
n - 1)/2) (Derivative[1][u0] + p Derivative[1][u1] +
p^2 Derivative[1][u2] +
p^3 Derivative[1][u3]) (Derivative[2][u0] +
p Derivative[2][u1] + p^2 Derivative[2][u2] +
p^3 Derivative[2][u3])) +
p (-Ha^2 (u0 + p u1 + p^2 u2 +
p^3 u3) + (((1 +
De^2 (Derivative[1][u0] + p Derivative[1][u1] +
p^2 Derivative[1][u2] + p^3 Derivative[1][u3])^2)^(
1/2 (-3 + n)) (1 +
De^2 n (Derivative[1][u0] + p Derivative[1][u1] +
p^2 Derivative[1][u2] +
p^3 Derivative[1][u3])^2) (Derivative[2][u0] +
p Derivative[2][u1] + p^2 Derivative[2][u2] +
p^3 Derivative[2][u3])) (Derivative[1][u0] +
p Derivative[1][u1] + p^2 Derivative[1][u2] +
p^3 Derivative[1][u3])) + (1 +
De^2 ((Derivative[1][u0] + p Derivative[1][u1] +
p^2 Derivative[1][u2] + p^3 Derivative[1][u3]))^2)^((
n - 1)/2) (Derivative[1][u0] + p Derivative[1][u1] +
p^2 Derivative[1][u2] +
p^3 Derivative[1][u3]) (Derivative[2][u0] +
p Derivative[2][u1] + p^2 Derivative[2][u2] +
p^3 Derivative[2][u3])), p]
The problem is that don't get anything back
What do you think?
p's still inside brackets because Mathematica can't expand( stuff )^((n-1)/2)unless you supply an actual integer value forn. Is that the issue? – march Aug 31 '17 at 19:03nis an integer (which I assume it is?). Either do this for different actual values ofnor useSeriesto have Mathematica compute a power series inpbefore collecting. This will result in pretty large expressions though. – march Aug 31 '17 at 20:05poutside of the(stuff)^(depends on n)expressions that should be collected? Compare to e.g.Collect[(q + p) (1 + p)^n, p], which (expectedly) returnsp (1 + p)^n + (1 + p)^n q. Another weird thing:Collect[OPsExpression, p, foo]returns a result withfooabsent. Compare to e.g.Collect[a + b, p, foo], which (expectedly) returnsfoo[a+b]. – jjc385 Sep 01 '17 at 03:27Collect[expr ,p]appears to returnexprunchanged whenexprcontains a rational function ofp(other thanp^n_). E.g.,Collect[(q + p) (1 + p)^(n - 1), p, foo]returns its input unchanged. IMHO, this seems somewhat inconsistent (it carries non-rational functions along, like inCollect[(1+p) f[p], p], and even carries along expressions which will be rational for certain values of the power, like inCollect[(1+p)(p+q)^n, p]), but I suppose some choice had to be made. – jjc385 Sep 01 '17 at 19:49nan integer? If so, you can probably apply the binomial theorem and come up with the coefficients of each power ofpin terms ofnand binomial coefficients. – jjc385 Sep 01 '17 at 20:31Seriesanyway, though!) – march Sep 08 '17 at 23:08