Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can't get any function defined in $UserBaseDirectory/Kernel/init.m to work. For example:

SinDeg[d_] := Sin[d * Degree]; (* Only line in init.m *)


(* => SinDeg[90] *)

However when copying the code and executing it inside a Mathematica notebook, it works fine:

SinDeg[d_] := Sin[d * Degree];
(* => 1 *)

The Mathematica front-end can definitely see the function definitions as it displays SinDeg as an autocompletion suggestion, when typing SinD.

I'm using Mathematica 9 Home Edition on OS X.

share|improve this question
To eliminate the obvious: you have restarted Mathematica after adding this line to init.m? – Sjoerd C. de Vries Mar 11 '13 at 23:50
@SjoerdC.deVries yes. – Tyilo Mar 11 '13 at 23:51
What do you get when you type ?SinDeg directly after Mathematica starts up? – Sjoerd C. de Vries Mar 12 '13 at 0:42
@SjoerdC.deVries I get this error: Information::notfound: Symbol SinDeg not found. >> – Tyilo Mar 12 '13 at 0:44
Could you check whether you really have an underscore in your definition in the init.m file? – Sjoerd C. de Vries Mar 12 '13 at 0:44
up vote 5 down vote accepted

This has to do with the Notebook's default context setting in the evaluation menu. If it isn't set to Global`, the definitions made in init.m are not seen.

As rm-rf says, a good way to put custom definitions in the init.m would be to use Begin and End to create an Init` context and append that context to the context path so that the definitions are available regardless of the notebook's context. (better still, use packages)

share|improve this answer

Your Answer


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.