# Evaluate function entrywise on high dimensional array [closed]

I have defined a function $f$ from number to number. I want to tell Mathematica to apply that function to each entry of a high dimensional array $A$, to get a new array $f(A)$ in the same form of $A$. Mathematica automatically does that for simple functions like sine, powers, logarithms, etc. How do I do it for my defined functions?

• You may want to look at Map[f, expr, levelspec] as in the documentation. – dr.blochwave Oct 6 '15 at 9:05
• Also, lookup Listable. – yohbs Oct 6 '15 at 9:07
• @yohbs Listable is exactly what I needed! Thanks. – geodude Oct 6 '15 at 9:11

Set the attribute Listable on the function.

SetAttributes[f, Listable]


Then it will auto-thread over arrays:

f[{1, 2, 3}]
(* {f[1], f[2], f[3]} *)


Sin, Cos, etc. also have this attribute:

Attributes[Sin]
(* {Listable, NumericFunction, Protected} *)