The documentation for Simplify[expr] says that it performs a sequence of algebraic and other transformations on expr, and returns the simplest form it finds. How can I see which transformations it applies?
Asked
Active
Viewed 754 times
1 Answers
21
I thought of this question while on the train but the solution appeared in my brain as soon as I got into work. All you need to do is create a ComplexityFunction that includes a side effect
f[x_] := (Print[x];
LeafCount[x])
Simplify[TrigExpand[Tan[x + y]], ComplexityFunction -> f]
This gives the following output
(Cos[y] Sin[x])/(Cos[x] Cos[y]-Sin[x] Sin[y])+(Cos[x] Sin[y])/(Cos[x] Cos[y]-Sin[x] Sin[y])
(Cos[y] Sin[x]+Cos[x] Sin[y])/(Cos[x] Cos[y]-Sin[x] Sin[y])
(Cos[y] Sin[x]+Cos[x] Sin[y])/(Cos[x] Cos[y]-Sin[x] Sin[y])
(Cos[y] Sin[x]+Cos[x] Sin[y])/(Cos[x] Cos[y]-Sin[x] Sin[y])
(Cos[y] Sin[x])/(Cos[x] Cos[y]-Sin[x] Sin[y])+(Cos[x] Sin[y])/(Cos[x] Cos[y]-Sin[x] Sin[y])
(1/2 Csc[x] Sin[2 x] Sin[y]+1/2 Csc[y] Sin[x] Sin[2 y])/(-Sin[x] Sin[y]+1/4 Csc[x] Csc[y] Sin[2 x] Sin[2 y])
(Cos[y] Sin[x]+Cos[x] Sin[y])/(Cos[x] Cos[y]-Sin[x] Sin[y])
Tan[x+y]
Tan[x+y]
x+y
x+y
x+y
x+y
x+y
x+y
x+y
x+y
x+y
x+y
x+y
Tan[x+y]
Tan[x+y]
(Cos[y] Sin[x])/(Cos[x] Cos[y]-Sin[x] Sin[y])+(Cos[x] Sin[y])/(Cos[x] Cos[y]-Sin[x] Sin[y])
Tan[x+y]
Note that this shows every expression that the ComplexityFunction is applied to. Clearly x+y is not equivalent to Tan[x+y]
It is interesting to also apply this to FullSimplify to see all of the extra transformations that get applied
FullSimplify[TrigExpand[Tan[x + y]], ComplexityFunction -> f]
WalkingRandomly
- 4,107
- 1
- 20
- 36
Simplify/FullSimplifya lot, some years ago. – Leonid Shifrin Nov 28 '12 at 09:53Simplifyand friends should not be doing if you want any results in reasonable time. These commands don't do things the way humans do, and lack the intuition which allows humans to pick the right routes to follow. – Leonid Shifrin Nov 28 '12 at 10:59