MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Suggestions on how to use standard engineering symbols

Hi Nasser,

honestly, I would just use different symbols anyway, since messing with
symbol names coinciding with System symbols  can bring more harm than good.
However, in case you really want to do it, here are few possibilities that
come to my mind.

If you are concerned about how your *input* code looks visually, one "quick
and dirty" method is to take those pieces of code where you have conflicting
symbols and wrap them in a Module, or better yet With (if symbol's values
are not going to change), (but never use Block for this purpose!) declaring
local symbols with the same names - like Module[{E=..., I =...,...},code] or
With[{E=..., I =...,...},code]. In this case, the global symbols will be
shadowed by local definitions. This option may be appropriate if you need to
assign (Own)values to the symbols in question (this refers to Module) - that
is, if you want to store some values in them.  The  advantage of this method
is that syntax coloring will always tell you whether or not you really
localized your symbol. It should be clear however that you won't be able to
refer to the original system symbols with the same names, within this code.
Also, the bindings are local to Module or With, so if you have some code
scattered across a notebook, you will have to wrap all relevant pieces in a
Module or With and keep all these Module or With constructs in sync.

OTOH, if all you care about is the way the *output*  looks, and you don't
need to store any values in the symbols of interest, then another option is
to define formatting rules for the output, something like this:

Format[youngModule] := "E"

In this case, while you will be using <youngModule>, in the output it will
look like E.

It is certainly possible (although does not seem to be easy to implement
reliably) to produce a more sophisticated general solution to this problem,
based for example on working in a different context and/or writing a
$PreRead - based custom preprocessor. Perhaps this problem has been
addressed before and others will suggest something nicer and simpler.


On Sun, Oct 18, 2009 at 2:22 AM, Nasser M. Abbasi <nma at> wrote:

> Hello
> This is a problem I am sure all of us had.
> It would be nice to use the same standard engineering/physics
> symbols/letters found in textbook to write the equations in mathematica.
> But some/many of those symbols conflict with existing Mathemtica symbols.
> For example, Young modulus is always written as E, but E in mathematica is
> reserved to the exponential constant, and I would like to use I (upper case
> I) to mean the moment of inertia, and not have it conflict with complex
> number I. And many other examples.
> I was wondering if there is a way to still use these letters in my
> equations
> but not conflict with Mathematica's?
> I thought may be I could make a bold versions of these letters with a new
> code, or find latine characters which "looks like" these from the palette,
> but have different ASCII code.
> Or may be I could tell mathematica somehow to "undefine" these symbols
> during some computation and restore them again, so it will not interpret
> them as its own standard symbols only during this computation, but was not
> sure if this is a good idea? (would this will cause a problem internally to
> Mathematica as it could very well use these symbols in its own package
> code.
> I could always use Exp[] instead of E and use Sqrt[-1] instead of "I" when
> I
> really mean to use the Mathematica letters and leave E and I etc... for my
> use.
> Any other ideas others have on this subject? I'd really like to write the
> equations as they appear in the textbook if possible and not have to rename
> standard engineering letters to something else.
> --Nasser

  • Prev by Date: Re: Suggestions on how to use standard engineering symbols in Mathematica
  • Next by Date: Re: Text cell formating blues. LineBreakWithin, PageWidth, WordWrapping
  • Previous by thread: Suggestions on how to use standard engineering symbols in Mathematica which conflict with Mathematica own symbols?
  • Next by thread: Re: Suggestions on how to use standard engineering symbols