Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to use custom transformation functions in Simplify, but mathematica does not seem to use them properly. Consider the following

t1[a]:=1
t2[b]:=0
FullSimplify[a+b, TransformationFunctions->{t1,t2}]

As intended this evaluates to 1. However, if I add the standard transformation functions nothing happens:

FullSimplify[a+b, TransformationFunctions->{Automatic,t1,t2}]

This gives a+b. Why did Mathematica forget about my custom functions? Ideas?

share|improve this question
add comment

1 Answer 1

Interesting question. I don't know if this behavior is intended but I think I can at least give some insight into the problem.

We can use a custom ComplexityFunction with an embedded Print to take a look at what transformed expressions are tested.

cf = (Print[#]; LeafCount[#] + Count[#, _Symbol, {0, -1}]) &;

We will also need to make use of ClearSystemCache[] to see all simplification attempts.

First without Automatic:

ClearSystemCache[]
Simplify[a + b, TransformationFunctions -> {t1, t2}, ComplexityFunction -> cf]

Observe that for whatever reason t1 and t2 are not applied to atomic elements when Automatic is included:

ClearSystemCache[]
Simplify[a + b, TransformationFunctions -> {Automatic, t1, t2}, ComplexityFunction -> cf]

While the cause is not clear the solution is: write your transformation functions so that they work on compound expressions.

For example:

t3 = # /. {a -> 1, b -> 0} &;

Simplify[a + b, TransformationFunctions -> {Automatic, t3}]
 1
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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