# Variable substitution - PGML

Jump to navigation
Jump to search

## Variable Substitution

Frequently, you will have computed or randomly generated values that you want to include in the text of your problem. To insert the value of a `$a`

into PGML, use `[$a]`

. Such values can be inserted into the text anywhere, including inside math delimiters.

Suppose a manufacturer produces [$n] cars at a cost of [$cost] per car.

or

Suppose [`f(x) = [$f]`]. Then [`f'(x) = `] [_________________].

or

Suppose [: f(x) = [$f] :]. Then [: f'(x) = :] [_________________].

In the first example, the values of `$a`

and `$cost`

are inserted as plain text. In the second, example, if `$f`

is a MathObject Formula, then its TeX form will be inserted and processed as TeX code (due to the `[`...`]`

delimiters. In the third example, the Formula object's algebra string will be inserted into the math and processed in the Typeset Context to generate the mathematical output.