I have a function dependent on w(x,t) which is integrated in an interval. After integration of this function, I want to apply variation followed by integral by parts. Integral by parts results in to more than one results, if equated with zero. $$\begin{array}{l} U = \int\limits_0^l {{{\left( {\frac{{{\partial ^2}w}}{{\partial {x^2}}}} \right)}^2}dx} \\ \text{Taking variation and equating with 0,}\\ \delta U = \int\limits_0^l {2\,\left( {\frac{{{\partial ^2}w}}{{\partial {x^2}}}} \right)\,\,\delta \left( {\frac{{{\partial ^2}w}}{{\partial {x^2}}}} \right)dx} = 0\\ \delta U = 2\left( {\left( {\frac{{{\partial ^2}w}}{{\partial {x^2}}}} \right)\delta \left( {\frac{{\partial w}}{{\partial x}}} \right)\mathop |\limits_0^l - \left( {\frac{{{\partial ^3}w}}{{\partial {x^3}}}} \right)\delta \left( w \right)\mathop |\limits_0^l + \int\limits_0^l {\left( {\frac{{{\partial ^4}w}}{{\partial {x^4}}}} \right)\,\,\delta \left( w \right)dx} } \right) = 0\\ \text{that gives boundary conditions},\,\left( {\frac{{{\partial ^2}w}}{{\partial {x^2}}}} \right)\delta \left( {\frac{{\partial w}}{{\partial x}}} \right) = \left( {\frac{{{\partial ^3}w}}{{\partial {x^3}}}} \right)\delta w = 0,\,at\,x = 0,\,\,l\\ \text{equation},\,\left( {\frac{{{\partial ^4}w}}{{\partial {x^4}}}} \right) = 0 \end{array}$$

Mathematica codes,

dU[x, t] = D[w[x, t], {x, 2}]^2

Taking Variation variationofdU = VariationalD[dU[x, t], w[x, t], {x, t}] that gives fourth order derivative, 2*Derivative[4, 0][w][x, t] which is perfect as per the result shown above. This command gives variational derivative of the integral with respect to w[x,t], but irrespective of the limits of the integral but, if I want to get the boundary conditions also (as per shown above) for a definite integral of a function than VariationalD doesn't give.

Can anyone please tell how to evaluate the boundary conditions which comes from the integral by parts? I want to use this to apply Hamilton's theorem for a larger equation.

I have used Mathematica for solving differential equations and algebric equations but for the advance calculations in mathematica, I am very new. Any help for this problem, I will appreciate. Can anyone please help me how I can get all the equations shown above using Mathematica?


I've looked into this problem myself. As far as I know, you just have to program in the variational derivatives from the Euler-Lagrange equations by yourself using D. For example, for a simple harmonic oscillator:

lagrangian = D[y[x], {x, 1}]^2 - y[x]^2

You can emulate what VariationalD does with the following line of code:

D[lagrangian , y[x]] - D[D[lagrangian , y'[x]], x]

In the same way, you can get a boundary term for this equation:

D[lagrangian, y'[x]]

In higher dimensions or for Lagrangians with higher order derivatives, you'll have to figure out for yourself which derivatives of your Lagrangian you need to take to get the BCs you want. But after you have that, you can simply plug in the derivatives to get your BCs.

  • $\begingroup$ Yes, surely this is helpful to solve my problem. Thank you very much. Actually my all the equations are very big with 3 field variables and two independent variables. "VariationalD" uses the integral by parts and Boundary terms are the result of it. Can there be some way that I can extract those terms, which are not being given in output. $\endgroup$
    – Hari
    Dec 5 '17 at 13:17
  • $\begingroup$ I don't think I understand what you mean by that question, but if you suspect that VariatonalD does something during its evaluation that you could use, you could try playing around with Trace, TracePrint or TraceScan to see if you can extract those intermediary steps. However, I suspect that the terms you need never get evaluated explicitly because it seems like VariationalD only takes the derivatives it needs to get the bulk equation. $\endgroup$ Dec 8 '17 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.