# Multivariate series for approximating implicit system

I'm trying to approximate the solution of an implicit set of equations by means of a Taylor series. I have managed to do so for a solution expressed in terms of a single independent variable, by using the Dt function, solving for the required derivatives, and manually constructing the Taylor series (also for higher-order derivatives).

Now, the complexity (for me) increases:

• I have three implicit equations and
• would like to approximate the solution of three unknowns
• in terms of two independent variables,
• using up to the fourth derivatives.

For this problem size, I can probably still figure out the implicit differentiation and Taylor series by hand, but I would like Mathematica to help me with this, since I anticipate more complex problems in the future.

Edit: an example of the equations I am dealing with:

(*P defines a potential: *)
P = -M Rz + (360 (L^2 Rz^2 - 3 L Rz Uy + 3 Uy^2) + (2 L^2 Rz^2 +
30 L Ux - 3 L Rz Uy + 18 Uy^2)^2)/(180 L^3) - Ux V + (1/(
180 L^3))(1/
4 (L^2 (-12 + Rz (3 + 4 Rz)) + 6 L (6 + Rz) Ux + 36 Ux^2 +
60 L Uy - 3 L (L (-4 + Rz) + 12 Ux) Cos[Rz] -
3 L (L (16 + Rz) + 12 Ux - 6 L Cos[Rz]) Sin[Rz])^2 +
360 (L^2 Rz^2 + 3/2 L Rz (L + 2 Ux - L (Cos[Rz] + Sin[Rz])) +
3/4 (L + 2 Ux - L (Cos[Rz] + Sin[Rz]))^2));

(*The three equations are given by:*)
eqs = D[P==0,{{Ux,Uy,Rz},1}]


The two independent variables are Rz and V. The three dependent variables are Ux, Uy and M. Parameter L is a constant. I know that Ux=Uy=Rz=V=M=0 is a solution; this would be the point around which to expand the series, ideally up to fourth order and higher.

In particular, I'm struggling to obtain the various partial derivatives systematically by means of Dt and turn them into a multivariable Taylor series programmatically. I find the nested lists of Mathematica for higher dimensions hard to visualise.

How to solve for the required derivatives and turn them into a series, for this vector-valued multivariate case?

• Maybe you are seeking something like this: Normal[Series[ g[x , y , z, w] /. Thread[{x, y, z, w} -> t*{x, y, z, w}], {t, 0, 3}]] /. t -> 1 Mar 3, 2019 at 15:36
• Not quite. That is a handy way to produce a general series expansion, but I am looking for how to obtain the higher-order derivatives needed to solve a system by means of implicit differentiation. I understand the math, but I am struggling to program it for the vector-valued multivariate case in Mathematica, due to the nested list/array data structures of higher dimensions (hard to visualise). Mar 4, 2019 at 12:19
• Please edit to add an explicit example of an implicit equation, along with an indication of which are dependent and which are independent variables. What is shown above does not give a clear example. Mar 4, 2019 at 16:27
• Sorry for that; I was trying to avoid a mess by giving too many details, but the question wasn't specific. I have added an example of the equations with more details. Mar 4, 2019 at 20:10
• Yes, definitely. The implicit equations are generated in the first place by taking derivatives with respect to {Ux,Uy,Rz}, and equating them to zero. I would then like to approximate the solution of {Ux,Uy,M} in terms of {Rz,V}. Mar 5, 2019 at 8:17

This gets pretty complicated if we work with the parameter so I'll show the main idea with l set to 1.

I am using uncapitalized symbols since that is recommended practice.

pExpr = -(m*
rz) + (360*(l^2*rz^2 - 3*l*rz*uy + 3*uy^2) + (2*l^2*rz^2 +
30*l*ux - 3*l*rz*uy + 18*uy^2)^2)/(180*l^3) -
ux*v + ((l^2*(-12 + rz*(3 + 4*rz)) + 6*l*(6 + rz)*ux + 36*ux^2 +
60*l*uy - 3*l*(l*(-4 + rz) + 12*ux)*Cos[rz] -
3*l*(l*(16 + rz) + 12*ux - 6*l*Cos[rz])*Sin[rz])^2/4 +
360*(l^2*rz^2 + (3*l*rz*(l + 2*ux - l*(Cos[rz] + Sin[rz])))/
2 + (3*(l + 2*ux - l*(Cos[rz] + Sin[rz]))^2)/4))/(180*
l^3) /. l -> 1;


Here are some relevant definitions.

derivVars = {ux, uy, rz};
solveVars = {ux, uy, m};
indepVars = {rz, v};


We define some substitutions, first to make explicit dependencies of dependent on independent variables.

subst =
Thread[solveVars -> Map[Apply[#, indepVars] &, solveVars]]

(* Out= {ux -> ux[rz, v], uy -> uy[rz, v], m -> m[rz, v]} *)


Then we use a "center" point for the expansions. I chose something away from the origin so as to get away from the initial values all being zero, but this seems not to be strictly necessary.

centerVal = {1, 1/2};


We start by taking derivatives with respect to the set of variables specified in the question. This gives three (nonlinear) equations in three unknowns.

derivs1 = D[pExpr, {derivVars, 1}];


We now plug in dependencies and solve at the center point for the variables of interest. I am doing this numerically so as to reduce size of results. I assume it is the real valued solution that is of interest so I select that one to work with.

solns0 = NSolve[(derivs1 /. subst /. centerSubst),
solveVars /. subst /. centerSubst];
realsolns = SelectFirst[solns0, FreeQ[#, Complex] &]

(* Out= {ux[1, 1/2] -> -0.226565925725,
uy[1, 1/2] -> 0.521293098575, m[1, 1/2] -> 2.47566148214} *)


Since we are on a level set, derivatives of the expressions must vanish. So from here on we do implicit differentiation with respect to the independent variables, solve for the new derivatives after back substituting values for lower derivatives. So we successively build up our solution set. This is easy enough since now all equations are linear.

derivs2 = Flatten[D[derivs1 /. subst, {indepVars, 1}]];
solns1 = NSolve[derivs2 /. centerSubst /. realsolns][]
realsolns = Join[realsolns, solns1];

(* Out= {Derivative[0, 1][m][1, 1/2] -> 0.5049474410685676,
Derivative[0, 1][ux][1, 1/2] -> 0.04247077151821635,
Derivative[0, 1][uy][1, 1/2] -> -0.0021891966235871533,
Derivative[1, 0][m][1, 1/2] -> 3.035009091874597,
Derivative[1, 0][ux][1, 1/2] -> -0.5049474410685676,
Derivative[1, 0][uy][1, 1/2] -> 0.527428429008325} *)


Rinse and repeat:

derivs3 = Flatten[D[derivs2, {indepVars, 1}]];
solns2 = NSolve[(derivs3 /. centerSubst /. realsolns) == 0][]
realsolns = Join[realsolns, solns2];

(* Out= {Derivative[0, 2][m][1, 1/2] -> 0.0058561848991389885,
Derivative[0, 2][ux][1, 1/2] -> 0.0012407744471675428,
Derivative[0, 2][uy][1, 1/2] -> -0.0008707825473032442,
Derivative[1, 1][m][1, 1/2] -> 0.4689741977236943,
Derivative[1, 1][ux][1, 1/2] -> -0.005856184899138995,
Derivative[1, 1][uy][1, 1/2] -> -0.0029987473716603917,
Derivative[2, 0][m][1, 1/2] -> 2.0658369667032397,
Derivative[2, 0][ux][1, 1/2] -> -0.4689741977236943,
Derivative[2, 0][uy][1, 1/2] -> -0.025714139536380225} *)


If it is really important to get the parametrized result, we can start at the origin and then things are not so terrible because the initial solution is simple (all zeros). I'll just show the main steps, using Solve now instead of the numeric version.

centerVal = {0, 0}; centerSubst = Thread[indepVars -> centerVal]; derivs1 = D[pExpr, {derivVars, 1}]; solns0 = Solve[(derivs1 /. subst /. centerSubst) == 0, solveVars /. subst /. centerSubst]; realsolns = SelectFirst[solns0 /. l -> 1., FreeQ[#, Complex] &]

(* Out= {ux[0, 0] -> 0, uy[0, 0] -> 0, m[0, 0] -> 0} *)

derivs2 = D[derivs1 /. subst, {indepVars, 1}];
newexpr = (derivs2 /. centerSubst /. realsolns);
solns1 = Solve[newexpr == 0,
Complement[Variables[newexpr], {l}]][]
realsolns = Join[realsolns, solns1];

(* Out= {Derivative[0, 1][m][0, 0] -> 0,
Derivative[0, 1][ux][0, 0] ->
l^3/(2*(6 + 5*l^2)), Derivative[0, 1][uy][0, 0] -> 0,
Derivative[1, 0][m][0, 0] -> 2/l,
Derivative[1, 0][ux][0, 0] -> 0,
Derivative[1, 0][uy][0, 0] -> l/2} *)

derivs3 = Flatten[D[derivs2, {indepVars, 1}]];
newexpr = (derivs3 /. centerSubst /. realsolns);
solns2 = Solve[newexpr == 0,
Complement[Variables[newexpr], {l}]][]
realsolns = Join[realsolns, solns2];

(* Out= {Derivative[0, 2][m][0, 0] -> 0,
Derivative[0, 2][ux][0, 0] -> 0,
Derivative[0, 2][uy][0, 0] -> -((3*l^7)/(2*(6 + 5*l^2)^3)),
Derivative[1, 1][m][0, 0] -> -((-9*l - 5*l^3)/(3*(6 + 5*l^2))),
Derivative[1, 1][ux][0, 0] -> 0, Derivative[1, 1][uy][0, 0] -> 0,
Derivative[2, 0][m][0, 0] -> 0, Derivative[2, 0][ux][0, 0] ->
-((9*l + 5*l^3)/(3*(6 + 5*l^2))), Derivative[2, 0][uy][0, 0] ->
(5*l^3)/(6*(6 + 5*l^2))} *)


Continue as far as needed...

• Thanks, really great, works and clarifies a lot. I like how it's a recursive thing so that higher-order derivatives do not require more involved Mathematica syntax. Mar 8, 2019 at 14:42

You can use the new in M12 function AsymptoticSolve (one of my favorites) for this:

res = AsymptoticSolve[
eqs,
{{Ux, Uy, M}, {0, 0, 0}},
{{Rz, V}, {0, 0}, 2}
];

First @ res //TeXForm


$$\left\{\text{Ux}\to \frac{\left(-5 L^3-9 L\right) \text{Rz}^2}{6 \left(5 L^2+6\right)}+\frac{L^3 V}{2 \left(5 L^2+6\right)},\text{Uy}\to -\frac{3 L^7 V^2}{4 \left(5 L^2+6\right)^3}+\frac{5 L^3 \text{Rz}^2}{12 \left(5 L^2+6\right)}+\frac{L \text{Rz}}{2},M\to \frac{\left(5 L^3+9 L\right) \text{Rz} V}{3 \left(5 L^2+6\right)}+\frac{2 \text{Rz}}{L}\right\}$$

which I believe is in agreement with Daniel's solution.

• Seeing this become a feature is spectacular. Thanks for mentioning it. Jun 21, 2019 at 19:44