# Symbols

A symbol is an identifier representing a named mathematical object. It belongs to a domain and it may hold a value. A symbol without a value represents a mathematical unknown in an expression.

To change the value or domain of a symbol, use the `value` and `domain` properties of the symbol.

A symbol does not have to be declared before it can be used. The domain of a symbol will be inferred based on its usage or its value.

```const n = ce.box("n");
n.value = 5;
console.log("n =", n.value.json);```

To get a list of all the symbols in an expression use `expr.symbols`.

## Scope

Symbols are defined within a scope.

## Unknowns and Constants

A symbol that has been declared, but has no values associated with it, is said to be an unknown.

A symbol whose value cannot be changed is a constant. Constants are identified by a special flag in their definition.

To check if a symbol is a constant, use the `expr.isConstant` property.

``````console.log(ce.box("x").isConstant);
// ➔ false

console.log(ce.box("Pi").isConstant);
// ➔ true
``````

The value of constants may depend on settings of the Compute Engine. For example, the value of `Pi` is determined based on the value of the `precision` property. The values of constants in scope when the `precision` setting is changed will be updated.

``````ce.precision = 4;
const smallPi = ce.box("Pi"); // π with 4 digits
console.log(smallPi.latex);
// ➔ 3.1415

ce.precision = 10;
const bigPi = ce.box("Pi"); // π with 10 digits
console.log(bigPi.latex);
// ➔ 3.1415926535

ce.precision = 100; // Future computations will be done with 100 digits

console.log("pi = ", smallPi.numericValue, "=", bigPi.numericValue);
// ➔ pi  = 3.1415 = 3.1415926535
``````

## Automatic Declaration of Symbols

An unknown symbol is automatically declared when it is first used in an expression.

The new definition has a domain of `undefined` and no value associated with it, so the symbol will be an unknwon.

``````const symbol = ce.box("m"); // m for mystery
console.log(symbol.domain);
// ➔ undefined

symbol.value = 5;
console.log(symbol.numericValue);
// ➔ 5
``````

## Forgetting a Symbol

To reset what is known about a symbol use the `ce.forget()` function.

The `ce.forget()` function will remove any assumptions associated with a symbol, and remove its value. Howeve, the symbol will remained declared, since other expressions may depend on it.

To forget about a specific symbol, pass the name of the symbol as an argument to `ce.forget()`.

To forget about all the symbols in the current scope, use `ce.forget()` without any arguments.

Note that only symbols in the current scope are forgotten. If assumptions about the symbol existed in a previous scope, those assumptions will be in effect when returning to the previous scope.