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?

enter image description here


1 Answer 1


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 @@ System`Private`NameCodeLookup @ 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.)

  • $\begingroup$ Slick! Thanks! Also, btw, it seems like phi and curlyphi got switched. I can't tell why. $\endgroup$
    – jmbejara
    Feb 14, 2015 at 12:51
  • $\begingroup$ @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. $\endgroup$
    – Mr.Wizard
    Feb 14, 2015 at 13:00
  • $\begingroup$ 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). $\endgroup$
    – jmbejara
    Feb 14, 2015 at 13:05
  • $\begingroup$ @jmbejara In my browser both look like curly phi, but \[CurlyPhi] is larger. I hadn't noticed before. $\endgroup$
    – Mr.Wizard
    Feb 14, 2015 at 13:10
  • 1
    $\begingroup$ Also, System`Private`CharacterNames[] lists all the named characters and FromCharacterCode@System`Private`NameCodeLookup@System`Private`CharacterNames[] gives a string of them (i.e., System`Private`NameCodeLookup 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.) $\endgroup$ Feb 14, 2015 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.