# Use of variational operator, 𝛿 in Wolfram Mathematica (Version 11.0) [closed]

I have been working on a problem which requires the use of Energy Methods which is based on the variational principles. I am finding it hard to replicate my formulated equations in Mathematica.

How can I find the variation of any parameter using the variational operator in Mathematica? I have been trying the following function with 'u' being the dependent variable.

𝛿F(x,u) means the variation in the function with respect to the dependent variable. If F(x,u) can be given as:

F(x,u)= f(x)+x^2*u(x)-2u du/dx + 2x*Sin u


How can I find the first and second variation of this function w.r.t the dependent variable?

• You're also going to have trouble if you don't use proper syntax... – b3m2a1 Jul 19 '18 at 8:27
• Yes. I have been working on the syntax. Right now, more than syntax, I am more concerned with the use of this operator to deduce the required result. – Kamran Ali Ahmed Jul 20 '18 at 13:05

You can use the the function VariationalD in package VariationalMethods:

Needs["VariationalMethods"]

VariationalD[u[x] + x^2 u[x] - 2 u[x] u'[x] + 2 x*Sin[u[x]], u[x], x]


1 + x^2 + 2 x Cos[u[x]]

• I have been using this package but the results do not match the hand calculations. For example, if we assume this variational operator to work as a differential operator, the term "2 u[x] u'[x]" should be evaluated using the multiplicative rule of differentiation and should not equal zero. – Kamran Ali Ahmed Jul 19 '18 at 9:00
• What should the “2 u[x] u’[x]” evaluate to? – QuantumDot Jul 19 '18 at 18:36
• It should result in 2 u'[x] 𝛿u[x] + 2 u[x] 𝛿u'[x] – Kamran Ali Ahmed Jul 20 '18 at 13:06
• @KamranAliAhmed I also need this kind of result form according to the textbook definition. Do you find the right way? – A little mouse on the pampas Feb 17 at 6:13

Maybe you are looking for

D[u[x] + x^2 u[x] - 2 u[x] u'[x] + 2 x*Sin[u[x]], {{u[x], u'[x]}, 1}]


$\left\{-2 u'(x)+2 x \cos (u(x))+x^2+1,-2 u(x)\right\}$

or for

integrand[u_] := u[x] + x^2 u[x] - 2 u[x] u'[x] + 2 x*Sin[u[x]]
D[integrand[u + t v], t] /. t -> 0


$-2 v(x) \, u'(x) -2 u(x) \, v'(x)+2 \,x \, v(x) \cos (u(x))+x^2 \, v(x) + v(x)$

I prefer the latter. This variational-$\delta$ hokuspokus is basically what has been called a Gâteaux or Fréchet derivative since the mid of the last century.

PS.: The result of VariationalD[u[x] + x^2 u[x] - 2 u[x] u'[x] + 2 x*Sin[u[x]], {u[x]}, x] is actually correct if the boundary conditions of $u$ are fixed: This can be seen by integration by parts.

• I am looking for an answer to the following form after applying 𝛿 with respect to the dependent variable which is 'u' in this case: 1+x^2*𝛿u[x] - 2 u'[x] 𝛿u[x] - 2 u[x] 𝛿u'[x] + 2x cos[u[x]] 𝛿u[x] – Kamran Ali Ahmed Jul 20 '18 at 13:18

Perhaps what you're really looking for is the functional derivative, which can be defined as follows, see this answer:

FunctionalD[functional_, f_[y_]] :=
Assuming[Element[y, Reals],
Limit[((functional /.
f :> Function[x, f[x] + ε DiracDelta[x - y]]) - functional)/ε, ε -> 0]]

FunctionalD[u[x] + x^2 u[x] - 2 u[x] u'[x] + 2 x*Sin[u[x]], u[y]]


$$-2 \delta (x-y) u'(x)+2 x \delta (x-y) \cos (u(x))+x^2 \delta (x-y)+\delta (x-y)-2 u(x) \delta '(x-y)$$

You get the variational derivative by sticking this into an integral over $y$ which kills the delta functions. This result is different from the VariationalD result in that it is agnostic about whether the integral allows integration by parts. If the latter is allowed, then the (correct) result of Mathematica's VariationalD is recovered because the terms involving derivative of u` and of the delta function cancel.

• I appreciate you for taking out time to answer this question but I really cannot comprehend what is being said – Kamran Ali Ahmed Jul 20 '18 at 13:19
• Well, your question is unclear to me (and to the other answerers, too). Maybe you're looking for something completely different, like a numerical solution in terms of some basis expansion. I cannot make any further guesses unless the question is made more specific. – Jens Jul 20 '18 at 16:16
• I have my answer. I was trying to apply the delta operator which can be operated just like a differential operator to simplify things. Thank you for your input and time. Appreciated. – Kamran Ali Ahmed Aug 6 '18 at 17:53