Does Mathematica understand the concept of infinitesimal increment?

Commonly, in textbooks, differential of differential increment vanishes, good example is how Euler-Lagrange equations are derived using the differential (from step 2 to step 3 here, you can see d[q(t) + e*eta(t)] becomes d[q(t)] because eta(t) is infinitesimal change). And it makes sense because such small changes are considered negligible, and that is essential to define derivative rules (to see why I recommend this video at 3:00).

I would like to replicate similar behaviour in Mathematica to check correctness of certain derivations I made. Without it vanishing, my expressions will grow and not exlude negligeable terms.

I used the DifferentialD operator to represent differential increment, however Mathematica doesn't seem to replicate such behaviour.

I started with the following

DifferentialD[x + DifferentialD[y]]


I also tried to check if following expression be equal to zero but it wasn't the case.

DifferentialD[DifferentialD[y]]


Could someone more experienced with Mathematica (or symbolic computation in general) comment on that?

EDIT:

It appears that problem of how to handle operations on infinitesimal quantities is more deep than just simple algebra. For reference I'd like to share this thread, it has a lot of good references and explanations.

• The documentation of DifferentialD says "DifferentialD[x] has no built-in meaning." – Henrik Schumacher Jun 15 '18 at 20:07
• There would be much less confusion in this world if people finally reached 20th century mathematics, left this "infinitesimal change" business, and learned what a (Fréchet or Gâteaux) derivative is. Actually, in the source you cite, $\eta$ is not infinitesimal at all. It is just a tangent vector and what is performed there is simply the directional derivative in that direction. – Henrik Schumacher Jun 15 '18 at 20:16
• I get what you're saying, @Henrik. Thank you for quick feedback. The source says "little variation η(t), although infinitesimal", which really is confusing. – Marek Jun 15 '18 at 22:15
• The infinitesimal part is $\epsilon$, not $\eta$. – Michael E2 Jun 16 '18 at 1:43

I don't really approve of your intention but anyway. You can use

DifferentialD[x_ + y_] := DifferentialD[x] + DifferentialD[y]
DifferentialD[DifferentialD[x_]] := 0


With this, DifferentialD[x + DifferentialD[y]] evaluates to DifferentialD[x], as required.

For completeness,

DifferentialD[x_^n_] := n x^(n - 1) DifferentialD[x]
DifferentialD[x_ y_] := x DifferentialD[y] + y DifferentialD[x]

• Note: there is a built-in that does almost what OP wants, Dt, but one has to unprotect it and make it nilpotent, Dt[Dt[x_]] := 0. – AccidentalFourierTransform Jun 15 '18 at 21:13
• Are you aware that this would make all functions linear? – Henrik Schumacher Jun 15 '18 at 21:59
• @AccidentalFourierTransform since you don't approve this initiative, could you provide some examples of derivations that don't require this? For instance in the example I provided with Euler-Lagrange equations, how could that step be skipped? Because I agree with you and Henrik that this formalism is really ugly and I would love to learn a better way. – Marek Jun 15 '18 at 22:19
• @Marek For E-L, you need Variational Methods. – AccidentalFourierTransform Jun 15 '18 at 22:28