Skip to main content

calculus and analysis - 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?



Answer



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[155]= {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};
centerSubst = Thread[indepVars -> centerVal];

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[157]= {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][[1]]
realsolns = Join[realsolns, solns1];

(* Out[117]= {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][[1]]
realsolns = Join[realsolns, solns2];

(* Out[122]= {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[282]= {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}]][[1]]
realsolns = Join[realsolns, solns1];

(* Out[272]= {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}]][[1]]
realsolns = Join[realsolns, solns2];

(* Out[298]= {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...


Comments

Popular posts from this blog

plotting - How to draw lines between specified dots on ListPlot?

I would like to create a plot where I have unconnected dots and some connected. So far, I have figured out how to draw the dots. My code is the following: ListPlot[{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4,13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full] I have thought using ListLinePlot command, but I don't know how to specify to the command to draw only selected lines between the dots. Do have any suggestions/hints on how to do that? Thank you. Answer One possibility would be to use Epilog with Line : ListPlot[ {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4, 13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full, Epilog -> { Line[ ...

equation solving - Invert and fit implicitly defined curve

I need to fit an implicitly defined curve. I thought I could get some data out of Solve , and then using FindFit . Therefore, I would like to find the relation the parametric curve defined by $F(x,y)=0$: Solve[-(1/2) + 1/2 (0.41202 BesselK[0, 0.1 Sqrt[x^2 + y^2]] + (0.101483 x BesselK[1, 0.1 Sqrt[x^2 + y^2]])/Sqrt[x^2 + y^2]) == 0, y] But I can't get an output: Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help. >> Edit: In particular, I would like to fit the data coming from the curve with the expression of another curve, and not with a function $f(x)$. In particular, since this clearly looks like a cardioid , I would like it to fit to something like it. What other strategies could I try?

dynamic - How can I make a clickable ArrayPlot that returns input?

I would like to create a dynamic ArrayPlot so that the rectangles, when clicked, provide the input. Can I use ArrayPlot for this? Or is there something else I should have to use? Answer ArrayPlot is much more than just a simple array like Grid : it represents a ranged 2D dataset, and its visualization can be finetuned by options like DataReversed and DataRange . These features make it quite complicated to reproduce the same layout and order with Grid . Here I offer AnnotatedArrayPlot which comes in handy when your dataset is more than just a flat 2D array. The dynamic interface allows highlighting individual cells and possibly interacting with them. AnnotatedArrayPlot works the same way as ArrayPlot and accepts the same options plus Enabled , HighlightCoordinates , HighlightStyle and HighlightElementFunction . data = {{Missing["HasSomeMoreData"], GrayLevel[ 1], {RGBColor[0, 1, 1], RGBColor[0, 0, 1], GrayLevel[1]}, RGBColor[0, 1, 0]}, {GrayLevel[0], GrayLevel...