# Simplify a composition of functions

How do I make Mathematica simplify, for example, (1-#&)@*(1-#&) into #&? Simplify and FullSimplify don't work. If I apply the composition to a symbolic expression x I get x back, but that isn't a function.

• (1-#&)@*(1-#&) is not grammatical in Mathematica. – David G. Stork Apr 1 '15 at 17:15
• Can you post a complete example of what you are exactly looking for? – Sumit Apr 1 '15 at 17:27
• Let f = (1-#)&, i.e. f(x)=1-x. Mathematica can easily simplify f(f(x))=1-(1-x)=x. How can I make it simplify $f\circ f$ into the function g = #&, i.e. g(x)=x? (I'm referring to simplifying $f\circ g$ in the arbitrary case where it can be simplified, not just this example.) – jcai Apr 1 '15 at 17:30
• @DavidG.Stork Is too! Try f=(1-#&)@*(1-#&);f[x] (returns x as expected) – 2012rcampion Apr 1 '15 at 17:42
• @2012racmpion Weird that the code includes @*... an unusual way to compose this function, but yes... functional. – David G. Stork Apr 1 '15 at 17:49

Since,

Attributes[Function]


{HoldAll, Protected}

Use Evaluate

f = Function[{x}, Evaluate[(1 - # &)@*(1 - # &)@x]]


Function[{x}, x]

f@x


x

Different version of Bob Hanlon's solution:

f = (1 - # &)@*(1 - # &)@(# &)
(*#1 &*)
f@x
(*x*)


Just another way to look

f = (1 - #) & (*your function*)
g[f__] := (a f@ # + b f@f@#)&   (*your arbitrary complicated function of function*)
h[x_] := Simplify[g[f][x]]  (*your final function*)


(I just wanted to use Simplify somehow)