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 - Filling between two spheres in SphericalPlot3D

Manipulate[ SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, Mesh -> None, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], {n, 0, 1}] I cant' seem to be able to make a filling between two spheres. I've already tried the obvious Filling -> {1 -> {2}} but Mathematica doesn't seem to like that option. Is there any easy way around this or ... Answer There is no built-in filling in SphericalPlot3D . One option is to use ParametricPlot3D to draw the surfaces between the two shells: Manipulate[ Show[SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], ParametricPlot3D[{ r {Sin[t] Cos[1.5 Pi], Sin[t] Sin[1.5 Pi], Cos[t]}, r {Sin[t] Cos[0 Pi], Sin[t] Sin[0 Pi], Cos[t]}}, {r, 1, 2 - n}, {t, 0, Pi}, PlotStyle -> Yellow, Mesh -> {2, 15}]], {n, 0, 1}]

plotting - Plot 4D data with color as 4th dimension

I have a list of 4D data (x position, y position, amplitude, wavelength). I want to plot x, y, and amplitude on a 3D plot and have the color of the points correspond to the wavelength. I have seen many examples using functions to define color but my wavelength cannot be expressed by an analytic function. Is there a simple way to do this? Answer Here a another possible way to visualize 4D data: data = Flatten[Table[{x, y, x^2 + y^2, Sin[x - y]}, {x, -Pi, Pi,Pi/10}, {y,-Pi,Pi, Pi/10}], 1]; You can use the function Point along with VertexColors . Now the points are places using the first three elements and the color is determined by the fourth. In this case I used Hue, but you can use whatever you prefer. Graphics3D[ Point[data[[All, 1 ;; 3]], VertexColors -> Hue /@ data[[All, 4]]], Axes -> True, BoxRatios -> {1, 1, 1/GoldenRatio}]

plotting - Mathematica: 3D plot based on combined 2D graphs

I have several sigmoidal fits to 3 different datasets, with mean fit predictions plus the 95% confidence limits (not symmetrical around the mean) and the actual data. I would now like to show these different 2D plots projected in 3D as in but then using proper perspective. In the link here they give some solutions to combine the plots using isometric perspective, but I would like to use proper 3 point perspective. Any thoughts? Also any way to show the mean points per time point for each series plus or minus the standard error on the mean would be cool too, either using points+vertical bars, or using spheres plus tubes. Below are some test data and the fit function I am using. Note that I am working on a logit(proportion) scale and that the final vertical scale is Log10(percentage). (* some test data *) data = Table[Null, {i, 4}]; data[[1]] = {{1, -5.8}, {2, -5.4}, {3, -0.8}, {4, -0.2}, {5, 4.6}, {1, -6.4}, {2, -5.6}, {3, -0.7}, {4, 0.04}, {5, 1.0}, {1, -6.8}, {2, -4.7}, {3, -1.