How can I make Mathematica consider Assumptions in FullSimplify also when applying custom Transformation Functions?
It works with the Automatic Transformation Functions:
FullSimplify[Sqrt[a^2], a < 0]
-a
FullSimplify[a < 0, a < 0]
True
It does not work with custom Transformation Functions:
custom Transformation function replacing negative terms by pi:
tf2[e_] := e /. a__ /; a < 0 -> π
custom complexity function making pi as a result attractive:
myCount = (-Count[#, π, {0, Infinity}]) &;
mySimplify = (FullSimplify[#, a < 0, TransformationFunctions -> {tf2},
ComplexityFunction -> myCount]) &;
This works for numbers
mySimplify[1]
1
mySimplify[-3]
π
It does however not consider the assumption that a<0
mySimplify[a]
a
tf2[e_] := e /. {a__ /; ToCharacterCode[ToString@a] == {97} -> Pi, a__ /; a < 0 -> Pi}
I don't know why your example doesn't work though. $\endgroup$Assuming[a < 0, TrueQ[a < 0]]
doesn't work, and/;
tests the truth of a condition. $\endgroup$tf2
is not using any function using assumptions. Trytf2[e_] := e /. a_ /; Refine[a < 0] -> \[Pi]
andmySimplify = Assuming[a < 0, FullSimplify[#, TransformationFunctions -> {tf2}, ComplexityFunction -> myCount]] &;
. $\endgroup$