3
$\begingroup$

I want to simplify a expression with a even function Df[x] == Df[-x]

  FullSimplify[-(1/2) Df[x - x4] J[x] - 1/2 Df[-x + x4] J[x],  
    Assumptions -> {Df[x] == Df[-x]}]

This code can not give the desired result which is -Df[-x + x4] J[x]. The strange thing here is that if I replace x4 with x2, it works well.

FullSimplify[-(1/2) Df[x - x2] J[x] - 1/2 Df[-x + x2] J[x], 
   Assumptions -> {Df[x] == Df[-x]}]

which gives -Df[-x + x2] J[x].

So any solutions here for x4 or arbitrary symbol?

$\endgroup$

3 Answers 3

3
$\begingroup$

Probably the simplest approach is:

Simplify[-(1/2) Df[x - x4] J[x] - 1/2 Df[-x + x4] J[x], Df[x - x4] == Df[-(x - x4)]]
-Df[-x + x4] J[x]
$\endgroup$
1
$\begingroup$

First of all, both of your cases did not work as intended in my version of Mathematica (12.2). I'm not sure if it's what you're looking for, but here are two methods of defining an even function which is to be used in FullSimplify

Using upvalues based on this answer:

Df[x_] + Df[y_] /; x == -y ^:= 2 Df[x];
FullSimplify[-(1/2) Df[x - x4] J[x] - 1/2 Df[-x + x4] J[x]]

that gives -Df[x - x4] J[x]. You could have used them in one line as in

Assuming[{Df[x_] + Df[y_] /; x == -y ^:= 2 Df[x]}, 
 FullSimplify[-(1/2) Df[x - x4] J[x] - 1/2 Df[-x + x4] J[x]]]

or alternatively:

FullSimplify[-(1/2) Df[x - x4] J[x] - 1/2 Df[-x + x4] J[x], 
 Assumptions -> {Df[x_] + Df[y_] /; x == -y ^:= 2 Df[x]}]

And here's another method:

ClearAll[Df];
Df[0] = 0;
Df[x_] /; Internal`SyntacticNegativeQ[x] := Df[-x];
FullSimplify[-(1/2) Df[x - x4] J[x] - 1/2 Df[-x + x4] J[x]]

which gives -Df[x - x4] J[x] which is the same as -Df[-x + x4] J[x].

$\endgroup$
0
$\begingroup$

Consider first reducing the arguments of Df to canonical form:

Simplify[-(1/2) Df[x - x4] J[x] - 1/2 Df[-x + x4] J[x] /. 
  Df[x_] :> Df@First@Sort[Simplify[{x, -x}]]]
$\endgroup$

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