# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Generate the tensor associated with the nth derivative of a vector field at a point

Contributed by:
E. Chan-López, Víctor Castellanos, Héctor Argote Morales & Sjoerd Smit

ResourceFunction["DVectorField"][ gives the tensor corresponding to the |

ResourceFunction["DVectorField"][*f*,*vars**,** **p**,** **n*] is a useful tool for computing the tensors associated with the Taylor approximations used in local bifurcation theory for nonlinear ordinary differential equations or nonlinear maps.

DvectorField[*f*,*vars**,** **p**,** **n**,*"MultilinearFunction"] can be used to obtain multilinear functions associated with the tensors of each Taylor approximation.

DvectorField[*f*,*vars**,** **p**,** **n**,*"MultilinearFunction"] generates new indexed symbols, such as x1, from the variables of the vector field , so once generated, preassigning values to these symbols should be avoided. These indexed symbols allow multilinear functions to be easily evaluated in calculations where they are required.

DvectorField[*f*,*vars**,** **p**,** **n**,*"PureMultilinearFunction"] can be used to obtain multilinear functions associated with the tensors of each Taylor approximation using pure functions.

In typical usage, *p* will be an equilibrium point of the dynamical system *f*.

Use DVectorField with a 2D vector field:

In[1]:= |

Out[1]= |

Use DVectorField with a 3D vector field:

In[2]:= |

Out[2]= |

Use DVectorField with the Lorenz system to compute some multilinear functions:

In[3]:= |

Out[6]= |

Equilibrium points:

In[7]:= |

Out[11]= |

Linear and bilinear functions for Lorenz system at the above equilibrium points:

In[12]:= |

Out[12]= |

In[13]:= |

Out[13]= |

Compute the first Lyapunov coefficient for the Brusselator system:

In[14]:= |

Out[18]= |

The equilibrium point:

In[19]:= |

Out[21]= |

Assume fixed and take as a bifurcation parameter to show that the system exhibits a supercritical Hopf bifurcation at , where .

The Jacobian matrix and its transpose:

In[22]:= |

Out[23]= |

In[24]:= |

Out[25]= |

Analyse the local stability with the resource function BialternateSum, with *β* as control parameter:

In[26]:= |

Out[26]= |

The critical value of the Hopf bifurcation:

In[27]:= |

Out[27]= |

Then, the equilibrium of the Brusselator system is locally asymptotically stable for and locally asymptotically unstable for (appears a stable limit cycle surrounded the unstable equilibrium point). We verify the previous conclusion by the transversality condition:

In[28]:= |

Out[28]= |

The non-trivial equilibrium point at :

In[29]:= |

Out[30]= |

Shift the non-trivial equilibrium point to the origin:

In[31]:= |

Out[33]= |

Verify that indeed the non-trivial equilibrium was shifted to the origin:

In[34]:= |

Out[34]= |

The Jacobian matrix in the new state variables:

In[35]:= |

Out[37]= |

Using both the linear approximation and its transpose at the origin, with and , we obtain the eigenvalues and :

In[38]:= |

Out[41]= |

In[42]:= |

Out[43]= |

In[44]:= |

Out[44]= |

The critical eigenvectors , , , :

In[45]:= |

Out[49]= |

The normalization

In[50]:= |

Out[50]= |

In[51]:= |

Out[52]= |

In[53]:= |

Out[53]= |

In[54]:= |

Out[54]= |

The third-order Taylor approximation for the polynomial system

Linear function:

In[55]:= |

Out[56]= |

Bilinear function:

In[57]:= |

Out[58]= |

Trilinear function:

In[59]:= |

Out[60]= |

Verify that the Taylor series expansion of the Brusselator system is correct:

In[61]:= |

Out[61]= |

The first Lyapunov coefficient is given by:

where

and , are given by

,

First, compute , and as follows:

In[62]:= |

Out[63]= |

In[64]:= |

Out[65]= |

In[66]:= |

Out[66]= |

Finally, compute the first Lyapunov coefficient:

In[67]:= |

Out[68]= |

In[69]:= |

Out[69]= |

The first Lyapunov coefficient is clearly negative for all positive . Thus, the Hopf bifurcation is nondegenerate and always supercritical.

Compute the first Lyapunov coefficient for the following predator-prey system:

In[70]:= |

Out[74]= |

The orbitally equivalent polynomial system:

In[75]:= |

Out[76]= |

The Jacobian matrix for the orbitally equivalent polynomial system:

In[77]:= |

Out[79]= |

The non-trivial equilibrium point:

In[80]:= |

Out[82]= |

The linear approximation at :

In[83]:= |

Out[85]= |

Analyse the local stability with the resource function BialternateSum, with as control parameter:

In[86]:= |

Out[86]= |

The critical value of the Hopf bifurcation:

In[87]:= |

Out[87]= |

Then, is locally asymptotically stable for and locally asymptotically unstable for (with ), and can be confirmed by the transversality condition:

In[88]:= |

Out[88]= |

The non-trivial equilibrium point at :

In[89]:= |

Out[90]= |

Shift the non-trivial equilibrium point to the origin:

In[91]:= |

Out[94]= |

Verify that indeed the non-trivial equilibrium was shifted to the origin:

In[95]:= |

Out[95]= |

The Jacobian matrix in the new state variables:

In[96]:= |

Out[97]= |

Using both the linear approximation and its transpose at the origin, with and , we obtain the eigenvalues and :

In[98]:= |

In[99]:= |

Out[101]= |

In[102]:= |

Out[104]= |

In[105]:= |

Out[105]= |

The critical eigenvectors , , , :

In[106]:= |

Out[111]= |

The normalization

In[112]:= |

Out[113]= |

In[114]:= |

Out[116]= |

In[117]:= |

Out[117]= |

In[118]:= |

Out[118]= |

The third-order Taylor approximation for the polynomial system

Linear function:

In[119]:= |

Out[121]= |

Bilinear function:

In[122]:= |

Out[124]= |

Trilinear function:

In[125]:= |

Out[127]= |

Verify that the Taylor series expansion of the polynomial system is correct:

In[128]:= |

Out[128]= |

The first Lyapunov coefficient is given by:

where

and , are given by

,

First, compute , and as follows:

In[129]:= |

Out[131]= |

In[132]:= |

Out[134]= |

In[135]:= |

Out[136]= |

Finally, we compute the first Lyapunov coefficient:

In[137]:= |

Out[138]= |

Clearly, the first Lyapunov coefficient is strictly negative for all combinations of the fixed parameters. Therefore, a unique limit cycle emerges from the non-trivial equilibrium via Hopf bifurcation for .

Compute the first Lyapunov coefficient for the following nonlinear feedback-control system of Lur'e type:

In[139]:= |

Out[143]= |

For all values of , the Lur'e system has two equilibria, the origin and . At the origin, this system exhibits a supercritical Hopf bifurcation when , where :

In[144]:= |

Out[146]= |

The Jacobian matrix and its transpose:

In[147]:= |

Out[149]= |

In[150]:= |

Out[152]= |

Analyse the local stability with the resource function BialternateSum, with as control parameter:

In[153]:= |

Out[153]= |

The critical value of the Hopf bifurcation:

In[154]:= |

Out[155]= |

Then, the equilibrium of the Lur'e system is locally asymptotically stable for and locally asymptotically unstable for (appears a stable limit cycle surrounded the unstable equilibrium point). We verify the previous conclusion by the transversality condition:

In[156]:= |

Out[156]= |

Using both the linear approximation and its transpose at the origin, with and , we obtain the eigenvalues and :

In[157]:= |

Out[160]= |

In[161]:= |

Out[163]= |

In[164]:= |

Out[164]= |

The critical eigenvectors , , , :

In[165]:= |

Out[170]= |

The normalization

In[171]:= |

Out[172]= |

In[173]:= |

Out[175]= |

In[176]:= |

Out[176]= |

In[177]:= |

Out[177]= |

The third-order Taylor approximation for the polynomial system

Linear function:

In[178]:= |

Out[180]= |

Bilinear function:

In[181]:= |

Out[183]= |

Trilinear function:

In[184]:= |

Out[186]= |

We verify that the Taylor series expansion of the Lur'e system is correct:

In[187]:= |

Out[187]= |

The first Lyapunov coefficient is given by:

where

and , are given by

,

First, compute , and

In[188]:= |

Out[190]= |

In[191]:= |

Out[193]= |

In[194]:= |

Out[195]= |

Finally, compute the first Lyapunov coefficient:

In[196]:= |

Out[197]= |

In[198]:= |

Out[203]= |

The first Lyapunov coefficient is strictly negative for all positive . Thus, the Hopf bifurcation is nondegenerate and always supercritical.

Let's delve into a discrete population model by leveraging the capabilities of the DVectorField function. In this framework, the population at a given time is determined by its value at the previous moment. Specifically, the growth rate of our population is influenced by intraspecific competition, where the current population has a limiting effect on its future growth. Through this approach, interactions can be depicted discretely at each time step, providing a comprehensive view of population dynamics.

Define the previously described discrete-time dynamical system as follows:

In[204]:= |

Out[207]= |

Jacobian matrix:

In[208]:= |

Out[210]= |

The non-trivial fixed point:

In[211]:= |

Out[213]= |

The linear approximation at :

In[214]:= |

Out[215]= |

The eigenvalues of the linear approximation :

In[216]:= |

Out[216]= |

For the eigenvalues are complex, so the following shift is made in the growth rate to handle this restriction, and then the eigenvalues of are computed again:

In[217]:= |

Out[218]= |

In[219]:= |

Out[220]= |

The value where the fixed point loses its stability, giving rise to a Neimark-Sacker bifurcation, is given by:

In[221]:= |

Out[221]= |

Therefore, the fixed point loses its stability at as verified below:

In[222]:= |

Out[222]= |

The linear approximation at the critical bifurcation value and its transpose:

In[223]:= |

Out[224]= |

In[225]:= |

Out[226]= |

The critical multipliers are given by:

In[227]:= |

Out[230]= |

The transversality condition:

In[231]:= |

Out[231]= |

The nondegeneracy condition:

for

In[232]:= |

Out[232]= |

The critical eigenvectors , , , :

In[233]:= |

Out[238]= |

The normalization

In[239]:= |

Out[240]= |

In[241]:= |

Out[243]= |

In[244]:= |

Out[244]= |

In[245]:= |

Out[245]= |

In[246]:= |

Out[246]= |

The bilinear and trilinear forms to compute the first Lyapunov coefficient:

In[247]:= |

Out[249]= |

In[250]:= |

Out[252]= |

The first Lyapunov coefficient (additional nondegeneracy condition) is given by

Finally, compute the first Lyapunov coefficient:

In[253]:= |

Out[254]= |

In[255]:= |

Out[256]= |

In[257]:= |

Out[257]= |

Therefore, a unique and stable closed invariant curve bifurcates from the non-trivial fixed point for .

Compute the quadratic coefficients of the Bogdanov-Takens bifurcation normal form for a predator-prey model with non-linear predator reproduction and prey competition:

In[258]:= |

Out[262]= |

The Jacobian matrix:

In[263]:= |

Out[265]= |

Look for the Bogdanov-Takens point:

In[266]:= |

Out[266]= |

To explicitly handle constraint , apply the following shift to get the Bogdanov-Takens point:

In[267]:= |

Out[267]= |

With the above shift in the predator population, the equilibrium point of coexistence and the critical value of bifurcation are as follows:

In[268]:= |

Out[270]= |

In[271]:= |

Out[272]= |

The linear approximation at :

In[273]:= |

Out[275]= |

Verify that has a pair of null eigenvalues:

In[276]:= |

Out[276]= |

The critical right eigenvectors and :

In[277]:= |

Out[278]= |

In[279]:= |

Out[280]= |

Verify the conditions and

In[281]:= |

Out[281]= |

The transition matrix with the critical right eigenvectors:

In[282]:= |

Out[283]= |

The critical left eigenvectors and :

In[284]:= |

Out[285]= |

In[286]:= |

Out[287]= |

In[288]:= |

Out[289]= |

Verify the conditions and

In[290]:= |

Out[290]= |

Finally, verify the conditions , and that the matrix is similar to a simple Jordan block:

In[291]:= |

Out[291]= |

In[292]:= |

Out[292]= |

The quadratic coefficients, involved in the nondegeneracy condition, can be computed in the following two ways:

In[293]:= |

Out[295]= |

In[296]:= |

Out[296]= |

In[297]:= |

Out[297]= |

In[298]:= |

Out[300]= |

In[301]:= |

Out[301]= |

In[302]:= |

Out[302]= |

The Bogdanov-Takens bifurcation in this case is non-degenerate when and the unique point of degeneracy is:

In[303]:= |

Out[303]= |

Use DVectorField with the resource function SymbolToSubscript:

In[304]:= |

Out[304]= |

In[305]:= |

Out[305]= |

Using the option "MultilinearFunction", DVectorField creates new indexed and unprotected variables from the original ones. This can be problematic if the new variables were previously assigned, as shown below:

In[306]:= |

Out[307]= |

To handle this possible problem, it is recommended to avoid preassigning the unprotected variables generated by DVectorField. In this way, if in the previous example we clean the assigned variables, we obtain the correct trilinear function:

In[308]:= |

Out[309]= |

When we want to copy our results to LATEX code, the "MultilinearFunction" option is very useful in combination with the resource function SymbolToSubscript, but we must always keep a strict control of the new symbols generated so as not to pre-assign values to them.

If we are not interested in copying expressions to LaTeX code and want to avoid conflicts with unprotected symbols, DVectorField has the "PureMultilinearFunction" option to work with pure functions, for example:

In[310]:= |

Out[311]= |

In[312]:= |

Out[312]= |

In[313]:= |

Out[313]= |

This work is licensed under a Creative Commons Attribution 4.0 International License