Reserved names
A few names have a fixed meaning in Nerdamer, and you can't assign to them:
| Name | Meaning |
|---|---|
e | Euler's number |
pi | π |
i | the imaginary unit |
_n | "any integer", in a family of solutions |
all | "every value", for an equation that is always true |
Check a name with isReserved rather than copying this list, because the list can change:
import nerdamer from 'nerdamer';
import { Parser } from 'nerdamer/parser';
nerdamer.isReserved('pi'); // true
Parser.isReserved('_n'); // true
nerdamer.isReserved('x'); // false
Using i as a variable
The imaginary unit can be moved to another symbol. The new symbol becomes reserved and i is freed:
import { Parser } from 'nerdamer/parser';
const previous = Parser.getI(); // 'i'
Parser.setI('j');
Parser.isReserved('j'); // true
Parser.isReserved('i'); // false
Parser.setI(previous); // put it back
The change applies to everything parsed afterwards in your app, so choose a symbol you don't otherwise use.
A constant you define with setConstant is not a reserved name: it is replaced by its value, but isReserved doesn't report it.
_n and all in solutions
solve uses these two names in its results.
_n stands for any integer in a periodic family:
solve(sin(x),x)
{_n*pi}
To pick one member, give _n a value for a single evaluation, as in evaluate(sol,{_n=>0}), or substitute into the result. Don't assign _n itself; _n:0 is an error.
all means every value of the variable is a solution. It isn't a variable either.
