Convert symbols in an expression into their formal versions
Contributed by:
Paco Jain (Wolfram Research)
Examples
Basic Examples (3)
Convert symbols to their formal counterparts:
FormalizeSymbols works on Latin, Greek and other symbols for which there exists a formal version in the Wolfram Language:
FormalizeSymbols works on both uppercase and lowercase letters:
Scope (2)
FormalizeSymbols does not affect symbols with multi-character symbol names:
By default, FormalizeSymbols only affects symbols in the current context (here Global`). To allow replacement of symbols in other contexts, use the option "ReplacementContexts":
Options (4)
ReplacementContexts (4)
The default setting of "ReplacementContexts"→Automatic replaces only symbols in $Context (here Global`):
The "ReplacementContexts" option can be set to a list of contexts for which symbols should be formalized:
With the setting "ReplacementContexts"→All, symbols in any context other than System` are replaced:
Non-default settings of "ReplacementContexts" can result in unwanted symbol collisions:
Properties and Relations (2)
FormalizeSymbols has the HoldFirst attribute to prevent evaluation of defined symbols prior to replacement:
Symbols within the System` context are never replaced. In particular, this includes Pi, N and C:
Related Links
Version History
-
2.4.0
– 21 July 2023
-
2.3.0
– 28 June 2023
-
2.2.0
– 24 June 2021
Related Resources