# Difference between function definitions [duplicate]

Possible Duplicate:
Functions vs. patterns

I thought about describing the context in which I faced this problem, but I figured it is general enough and clear enough to pose it as it is.

What is the difference between the two following definitions:

f[x_]:=Sin[x]
g=Sin[#]&


Under what circumstances will the two behave differently? Is any of them preferable as a general practice?

## marked as duplicate by Leonid Shifrin, Yves Klett, Mr.Wizard♦Dec 4 '12 at 11:42

• @LeonidShifrin True that. Googling with site:mathematica.stackexchange.com added to the search terms is often better. – Sjoerd C. de Vries Dec 4 '12 at 12:52
A pure function like g will be faster performance-wise, because it gets rid of all the overhead (e.g. pattern matching) involved in the definition of f.