26
$\begingroup$

I noticed that Mathematica has a set of special 'Formal' characters such as \[FormalA], \[FormalB] , etc.. In the front end, it looks like a character with a dot above and below:

formal characters

It is not clear from the built-in documentation how these characters are to be used.

Would someone demonstrate?

$\endgroup$
4
  • 3
    $\begingroup$ Formal symbols are Protected, so they can't be assigned values (by default). So you can use it as a way of ensuring that your definitions don't have stray values. It has been used several times on this site (see some of the posts here for examples), although I don't think a question has been asked explicitly about it. $\endgroup$
    – rm -rf
    Commented Feb 5, 2013 at 20:50
  • 1
    $\begingroup$ Version 10 now has formal Greek letters, too. $\endgroup$ Commented Nov 19, 2015 at 11:08
  • 2
    $\begingroup$ @R.M. Not all formal symbols are protected: \[FormalDelta] is but \[FormalPhi] is not Protected. According to TechSupport, this is by design, as some formal symbols are used internally, some are not. This is aggrevating, as one cannot rely on that a formal symbol has no global value set by the user. $\endgroup$ Commented Dec 2, 2015 at 10:25
  • $\begingroup$ @R.M. Out of curiosity, would you know in which version of Mathematica \[Formal] characters were introduced? $\endgroup$
    – QuantumDot
    Commented Dec 26, 2015 at 20:47

2 Answers 2

25
$\begingroup$

Very often, especially new Mathematica users stumble over the following error: They gave, maybe hours ago, a symbol a value like x=3, and later they try to use it where a function really expects a symbol:

Mathematica graphics

This leads of course to an error, because the Minimize call does not see the x, but only its value. The same happens when you try to derive this with D or Dt or Integrate expressions. Although the error message is very clear, most people get very confused and try to change their whole calculation.

Exactly for those situations, the formal parameter characters are made. They all share the attribute Protected which states that you cannot simply assign a value to them. Therefore, you can use them in situations where you maybe derive expressions or proof formulas or where you minimize an expression

Mathematica graphics

$\endgroup$
1
  • 2
    $\begingroup$ This is a nice issue for the beginner's pitfalls question too $\endgroup$ Commented Feb 6, 2013 at 2:41
8
$\begingroup$

I would like to point out that the shortcut to write out formal symbols is :$a:, where : is typed using Esc. See the documentation here.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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