I want to produce a Mathematica Computable Document in which N appears as a variable in my formulae. But N is a reserved word in the Mathematica language. Is there a way round this other than using a different symbol? It seems a severe limitation if you cannot use Mathematica to generate papers in which N is employed as a variable.
|
|
||||
| show 4 more comments |
|
You could use capital Nu,
The following shows how the input is displayed on screen.
|
|||||||||
|
|
As it is often voiced here, modifying built-in variables is not a good idea most of the times, especially in case of such fundamental symbols as On the other hand, the name of the variable and the way it is displayed could be completely different. You can use
2.4 (Note, that since |
||||
|
|
The methods suggested by David and István already do the job perfectly, but one could add something to the collection: As described in the documentation on Operators without Built-in Meanings, there are some two-dimensional forms such as For these kinds of symbols you don't re-define
The last line shows how the definition is stored as a definition associated with To erase the definition, I can either use
The shortcut to input the subscript is to type You can also use strings in the subscript, instead of numbers. That allows you to get a "variable" that displays as $N$ without decoration by entering
Again you could assign things to this subscripted form as well. Another use for a string subscript would be (here I'll copy the two-dimensional form in box notation, it should look nicer when copied into the notebook):
Of course one can use these re-defined operators as a substitute for
You can then keep working with But you can also do numerical substitutions in the usual way, as here:
(again, all the expressions looking like Finally, everything I said here about The
For even better formatting, you could replace |
||||
|
|
|
Ok, I'm late here, but the first thing I would have answered hasn't been answered already. If it's a one-cell-er, you can use
This can never bring you trouble with internal definitions since that N you see is not actually N. If it comprises multiple cells, you can use contexts, and interpret the RED N as a reminder that you're doing weird things. You can always access the regular N function by
|
|||
|
To continue with Ajasja's land mine theme, it's not so problematic to use
as long as you keep the following in mind:
But frankly, this probably isn't the best idea to go for. Land mines may be safer. |
|||
|
|




\[FormalCapitalN]instead ofN. It looks almost likeN. – Artes Jun 22 '12 at 10:46\[ScriptCapitalN], or\[CapitalNu], or... why do you need $N$ to be a variable anyway? How sure are you that your paper won't need the actual functionality ofN[]? – J. M.♦ Jun 22 '12 at 10:59nin intermediate steps and in the final display step do a replacement./.n->"N"should be save – Sjoerd C. de Vries Jun 22 '12 at 11:13