# How can I replace the Greek symbols in an expression with their plain text names?

Suppose I have an expression with Greek symbols in it. How would I convert that expression to another expression where the Greek symbols have been replaces with their names in plain text? I've included a small example of what I mean in the picture. Does anybody know of an easy way to do this?

• Related: (25305) Mar 5 '15 at 1:24
• Strongly related: (a/135959). May 18 '17 at 9:44

Extract all Greek letters from the documentation and make replacement rules:

nb = Get @ FileNameJoin[{\$InstallationDirectory, "Documentation", "English", "System",
"Tutorials", "LettersAndLetterLikeForms.nb"}];

letters = Cases[nb, StyleBox[s_String, "TR"] :> s, {-2}];

letters = DeleteCases[letters, "π" | "∈"];  (* reserved Symbols *)

names = StringTake[ToString @ FullForm @ #, {4, -3}] & /@ letters;

rules = MapThread[Symbol@# -> Symbol@ToLowerCase@#2 &, {letters, names}];


Then simply:

α x + β y /. rules

alpha x + beta y


If any of the Symbols may already have assignments and you are working with held expressions use instead:

rulesHeld = MapThread[HoldPattern @@ MakeExpression@# :>
Evaluate[Unevaluated @@ MakeExpression@ToLowerCase@#2] &, {letters, names}];


In a comment Oleksandr posted an undocumented System function which could be used as follows:

names = Join @@ SystemPrivateNameCodeLookup @ ToCharacterCode @ letters;


Complete replacement rules in case anything goes wrong with the extraction:

{α->alpha,  ρ->rho, Ε->capitalepsilon,  Ψ->capitalpsi
β->beta,    ϱ->curlyrho,    Ζ->capitalzeta, Ω->capitalomega
γ->gamma,   σ->sigma,   Η->capitaleta,  Ϝ->capitaldigamma
δ->delta,   ς->finalsigma,  Θ->capitaltheta,    Ϟ->capitalkoppa
ϵ->epsilon, τ->tau, Ι->capitaliota, Ϛ->capitalstigma
ε->curlyepsilon,    υ->upsilon, Κ->capitalkappa,    Ϡ->capitalsampi
ζ->zeta,    ϕ->phi, Λ->capitallambda,   Σ->capitalsigma
η->eta, φ->curlyphi,    Μ->capitalmu,   Π->capitalpi
θ->theta,   χ->chi, Ν->capitalnu,   ϵ->epsilon
ϑ->curlytheta,  ψ->psi, Ξ->capitalxi,   μ->mu
ι->iota,    ω->omega,   Ο->capitalomicron,  Υ->capitalupsilon
κ->kappa,   ϝ->digamma, Π->capitalpi,   ς->finalsigma
ϰ->curlykappa,  ϟ->koppa,   Ρ->capitalrho,  ϝ->digamma
λ->lambda,  ϛ->stigma,  Σ->capitalsigma,    ϟ->koppa
μ->mu,  ϡ->sampi,   Τ->capitaltau,  ϛ->stigma
ν->nu,  Α->capitalalpha,    Υ->capitalupsilon,  ϡ->sampi
ξ->xi,  Β->capitalbeta, ϒ->curlycapitalupsilon,
ο->omicron, Γ->capitalgamma,    Φ->capitalphi,
ϖ->curlypi, Δ->capitaldelta,    Χ->capitalchi}


(Sorry for the formatting; I can't think of a nice way to paste this here.)

• Slick! Thanks! Also, btw, it seems like phi and curlyphi got switched. I can't tell why. Feb 14 '15 at 12:51
• @jmbejara They seem to be correct. I suspect a font issue? Try copying and pasting the rules into Mathematica -- they appear to work correctly for me. Feb 14 '15 at 13:00
• You're right. It's a font thing (just on my end?). When I copy-past the last code block into Mathematica, everything is correct. However, in this post, they appear switched (for me). Feb 14 '15 at 13:05
• @jmbejara In my browser both look like curly phi, but \[CurlyPhi] is larger. I hadn't noticed before. Feb 14 '15 at 13:10
• Also, SystemPrivateCharacterNames[] lists all the named characters and FromCharacterCode@SystemPrivateNameCodeLookup@SystemPrivateCharacterNames[] gives a string of them (i.e., SystemPrivateNameCodeLookup is a bidirectional function). Extracting the Greek ones may be more difficult. (I also found that LetterQ recognises Greek letters, but contrary to its documentation, LetterCharacter does not.) Feb 14 '15 at 19:21