---
title: Superscripts and subscripts
description: Superscripts and subscripts written after a token, which apply an operation
  to it or select from it
---
A superscript, such as `²`, applies an operation to a number, array or function. A numeric subscript, such as `₁`, selects positions from an array or axes for a function. Both bind more tightly than function application. `v₁²` is the square of item 1 of `v`:

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

```bpl
v←10 20 30
v₁²
```

```output
400
```

On an array, an attached script applies to the preceding token. A modifying script on a function applies to the whole function on its left, as an ordinary monadic operator does: `f∘g⁻` is `(f∘g)⁻`. Enclosure `ˢ` instead applies to the preceding token: `f⍣gˢ` uses the scalar holding `g`; `(f∘g)ˢ` holds the whole composition. A separated script applies to the whole preceding run.

[Typing glyphs](glyphs.md#typing-glyphs) gives the keys for typing superscripts and subscripts. For bare inverse [`⁻`](https://bpl.fast.ai//glyphs/superscript-minus.html), type Alt-6, [`-`](https://bpl.fast.ai//glyphs/minus.html), then Space. Alt-6 then `-1` gives `⁻¹`, a negative power on numbers or a negative Rank on functions.

## Superscripts

### On an array

On a number or array, a superscript digit is a power:

```bpl
x←3
≥x²
```

```output
10
```

A power of `¯1`, written `⁻¹`, is the reciprocal:

```bpl
2⁻¹
```

```output
0.5
```

`ᵀ` swaps rows and columns:

```bpl
m←[1 2
   3 4]
mᵀ
```

```output
1 3
2 4
```

In `2 3²`, the superscript applies only to the `3`:

```bpl
2 3²
```

```output
2 9
```

In `[2 3]²`, it applies to the whole list:

```bpl
[2 3]²
```

```output
4 9
```

After a space, a superscript applies to the whole [run](terms.md#term-run) on its left:

```bpl
2 3 ²
```

```output
4 9
```

The run can be any expression, such as `≥x`:

```bpl
≥x ²
```

```output
16
```

In a strand of names, each name is a separate run, so `x y ²` applies `²` only to `y`:

```bpl
y←5
x y ²
```

```output
3 25
```

A spaced superscript also needs a space after it:

```bpl
2 3 ² + 1
```

```output
5 10
```

### On a function

On a function, numeric superscripts specify [cell ranks](glyphs/jot-diaeresis.md): `f¹` is `f⍤1`, `f⁰ ¹` is `f⍤[0 1]`, and `f⁰ ¹ ²` is `f⍤[0 1 2]`. Adjacent digits form one rank, so `f¹²` means rank 12. Spaces separate ranks. A negative rank counts back from the argument's rank, so `f⁻¹` works on cells with one fewer axis than the argument. Unlike [`⍤`](https://bpl.fast.ai//glyphs/jot-diaeresis.html), a superscript rank needs no separator before a numeric argument: `-⁰5`.

Here `+/¹` sums each row of `m`, `+⁰ ¹` adds one left scalar to each right row, and `⌽⁻¹` reverses each row:

```bpl
+/¹m
10 20+⁰ ¹m
⌽⁻¹m
```

```output
3 7
11 12
23 24
2 1
4 3
```

Bare `f⁻` is the inverse of `f`, the same as `f⍣¯1`. The minus has no superscript digit immediately after it: `f⁻¹` is rank ¯1, while `f⁻ ¹` applies the inverse at rank 1. Use `f⍣2` to repeat a function twice, because `f²` means rank 2.

`f⁻ Y` gives the `X` for which `f X` is `Y`. Inverses follow BQN's [specification of inferred properties](https://mlochbaum.github.io/BQN/spec/inferred.html). The inverse of the exponential [`*`](https://bpl.fast.ai//glyphs/star.html) is the natural logarithm:

```bpl
*⁻1
```

```output
0
```

Monadic Encode [`⊤`](https://bpl.fast.ai//glyphs/down-tack.html) gives a number's binary digits. Its inverse reads the digits back into a number:

```bpl
⊤⁻1 0 1
```

```output
5
```

In a dyadic call, `X f⁻ Y` is the `Z` for which `X f Z` is `Y`. The inverses of `2×` and `2*` are division by 2 and the base-2 logarithm:

```bpl
2×⁻10
2*⁻8
```

```output
5
3
```

Inverting [Replicate](glyphs/hash.md#expand) puts fill where the mask has zeros:

```bpl
1 0 1#⁻10 20
```

```output
10 0 20
```

`+\⁻` turns running sums back into the numbers they came from:

```bpl
+\⁻1 3 6
```

```output
1 2 3
```

The same goes for a derived function such as `-¨`:

```bpl
-¨⁻1 2 3
```

```output
¯1 ¯2 ¯3
```

A bound function such as `2↣×` is inverted as a whole too:

```bpl
2↣×⁻10
```

```output
5
```

Numeric superscripts just after a number remain powers: `+↢3⁻¹` adds a third. Bare `+↢3⁻` would instead try to invert the number `3`, which raises a `DOMAIN` error. To invert a function that ends in a number, put the function in parentheses:

```bpl
(+↢3)⁻ 10
```

```output
7
```

A space before the superscript applies it to the whole preceding run, so the parentheses can be left out:

```bpl
+↢3 ⁻ 10
```

```output
7
```

With the axis operator [`⍠`](https://bpl.fast.ai//glyphs/quad-colon.html), the inverse can also go before it: `#⁻⍠¯1` is the same function as `(#⍠¯1)⁻`.

Inverses follow the rules of [`⍣`](https://bpl.fast.ai//glyphs/star-diaeresis.html). A function built with Atop, After, Before, a bound argument, Each, Rank, Commute or a scan has an inverse when its parts do. `f⁻←g` [attaches](assignment.md#inverses-and-derivatives) `g` as the inverse of the function named by `f`.

[Bitwise](glyphs/superscript-b.md) [`ᵇ`](https://bpl.fast.ai//glyphs/superscript-b.html) is a monadic operator that applies a Boolean function to integer bits. For example, `6∧ᵇ3` is `2ₓ`.

[Unary](glyphs/superscript-u.md) [`ᵘ`](https://bpl.fast.ai//glyphs/superscript-u.html) calls a function with its right argument alone: `X fᵘ Y` is `f Y`. For example, `10-ᵘ3` is `¯3`.

### Making a scalar

`xˢ` is a scalar holding `x`, whether `x` is a [subject](terms.md#term-subject) or a function. Like [`⊂`](glyphs/left-shoe.md), it adds one layer of enclosure, and its tight postfix binding avoids parentheses on the left of a function (`1ˢι1`, `3ˢ+4`, `1 2ˢ+3`). On a function, `⊂+` forms a train instead, so `+ˢ` is the way to hold a function in a scalar (as [Power](glyphs/star-diaeresis.md#until) uses for a stopping predicate). Like any scalar, `+ˢ` has an empty shape:

```bpl
ρ+ˢ
```

```output
⍬ₓ
```

Its depth counts the one layer around the function:

```bpl
≡+ˢ
```

```output
1ₓ
```

### Errors

- `DOMAIN`: a function with no known inverse, or `ᵀ` on a function
- `SYNTAX`: a superscript after a space that doesn't stand alone, as in `2 3 ²+1`

## Subscripts

On an array, a subscript selects a major cell. `v₁` is `1⌷v`:

```bpl
v₁
```

```output
20
```

A negative subscript counts from the end:

```bpl
v₋₁
```

```output
30
```

A single subscript selects a matrix row. Numeric subscripts separated by spaces form one coordinate: `m₁ ₀` is `m.[1 0]`. Adjacent digits form one position: `v₁₂` selects position 12. Parentheses keep sequential selections separate: `(a₁)₂` selects item 2 of item 1:

```bpl
m₁
m₁ ₀
```

```output
3 4
3
```

After a dotted path, a subscript selects from the value at the end of that path:

```bpl
T←["a":[10 20]]
T.a₁
```

```output
20
```

With a space before it, a subscript selects from the whole run on its left:

```bpl
2 3 ₁
```

```output
3
```

As with a superscript, the run can be any expression:

```bpl
≥v ₁
```

```output
21
```

A spaced subscript also needs a space after it.

A subscripted item can be an assignment target:

```bpl
v₁←5
v
```

```output
10 5 30
```

Modified assignment works too:

```bpl
v₁+←1
v
```

```output
10 6 30
```

Use numeric subscripts for literal positions along successive axes. Use [Index](glyphs/squad.md) [`⌷`](https://bpl.fast.ai//glyphs/squad.html) or [bracket indexing](indexing.md) for computed positions, vectors of positions, keys or whole axes.

After a function, numeric subscripts choose axes, as [Axis](glyphs/quad-colon.md) does. `+/₀` is `+/⍠0`, and `+/₀ ₁` is `+/⍠[0 1]`:

```bpl
+/₀m
+/₀ ₁m
```

```output
4 6
10
```

In `f⁝x₁`, the subscript indexes `x` before the call. `(f⁝x)₁` indexes the call's result. An array of functions is still an array: `fs₁` selects its item 1.

The subscript letters `ₓ`, `ⱼ`, `ₑ` and `ᵣ` are parts of numbers, as in `3ₓ` and `1ᵣ3`. [Numbers](numbers.md) covers them. Between two items, `ⱼ`, `ₑ` and `ᵣ` form one [number](numbers.md#writing-numbers): `xⱼy` is `x+y×0ⱼ1`, `xₑy` is `x×10*y`, and `xᵣy` constructs a rational from integer components. A trailing `ᵣ` converts to the unbounded integer/rational domain: `3ᵣ` means `3ᵣ1`, and a result that is a whole number stays in that domain. [`÷`](https://bpl.fast.ai//glyphs/obelus.html) on ordinary integers floors. `÷ᵣ` gives the exact rational quotient of the same integers, and `÷ₐ` gives a float. After a name or any other item except a number or a list of literals, `ₓ` floors the value to machine integers. `xₓ` is `⌊ₓx`:

```bpl
x←3.7 ¯2.5
xₓ
```

```output
[3 ¯3]ₓ
```

After a function, `ₓ` floors its results to ordinary integers under either `kinds` setting. [Numbers](numbers.md#static-kinds) gives the static conversion rules.

`÷ₓ` floors the exact quotient as Python's `//` does and gives an ordinary integer, as `¯32768ₓ₂÷ₓ¯1ₓ₂` gives `32768ₓ`. `⌊ₓ`, `⌈ₓ` and `÷ₓ` each compute their integers in one pass:

```bpl
7 ¯7 7.5÷ₓ2
```

```output
[3 ¯4 3]ₓ
```

The sized integer markers `ₓ₁`, `ₓ₂`, `ₓ₄` and `ₓ₈` give fixed-width integers occupying 1, 2, 4 or 8 bytes. All the digits after `ₓ` form the width, so `ₓ₁₆` is invalid. Put parentheses around a conversion before indexing it, as in `(vₓ₁)₂`. [Fixed-width integers](numbers.md#fixed-width-integers) gives the conversion and promotion rules.

After a function, a sized marker converts the function's results:

```bpl
√ₓ₁ 17
```

```output
4ₓ₁
```

The float-width markers `ₕ`, `ₛ` and `ₚ` work the same way. After a function it makes the function's results floats of that width, and after an array it converts the array, as [`•float`](system/float.md) does:

```bpl
-ₛ 3
xₛ
```

```output
¯3ₛ
[3.7 ¯2.5]ₛ
```

`ₐ` (approximate) converts values to real floats. After an array, `ₐ` takes a complex number's real part at the width of its parts, converts an exact number or a Boolean to a float of the default width, and keeps a float's width:

```bpl
(3j4)ₐ
1r3ₐ
```

```output
3
0.3333333333
```

After a pervasive function other than [`√`](https://bpl.fast.ai//glyphs/radical.html), [`⊛`](https://bpl.fast.ai//glyphs/circle-star.html), [`*`](https://bpl.fast.ai//glyphs/star.html), [`○`](https://bpl.fast.ai//glyphs/circle.html) and `○⁻`, `ₐ` converts the arguments to real floats before the call, taking each complex argument's real part: `!ₐ25ₓ` computes in floats rather than in overflowing integers. The floats have the width that the arguments' float promotion gives, which never depends on their values. After a function that isn't pervasive, such as [`≢`](https://bpl.fast.ai//glyphs/equal-underbar-slash.html), `ₐ` converts the results. `÷ₐ` selects float division before computing, rather than converting a floored integer quotient. After [`√`](https://bpl.fast.ai//glyphs/radical.html), [`⊛`](https://bpl.fast.ai//glyphs/circle-star.html), [`*`](https://bpl.fast.ai//glyphs/star.html), [`○`](https://bpl.fast.ai//glyphs/circle.html) or `○⁻`, `ₐ` gives the real part of the principal value, including when the result is outside the real domain. `√ₐ¯4` is 0, the real part of `0j2`. `¯8*ₐ÷3` is 1, the real part of the principal root 1\+i√3. `√ₐ`, `⊛ₐ` and `*ₐ` each run as one [kernel](terms.md#term-kernel). Under [`∂`](glyphs/partial.md), their slopes are the slopes of their real parts. [Numbers](numbers.md#approximate) gives the rules:

```bpl
√ₐ¯4 9
¯8*ₐ÷3
```

```output
0 3
1
```

### Errors

- `SYNTAX`: a subscript after a space that doesn't stand alone, as in `2 3 ₁+1`, or that is an assignment target, as in `v ₁←5`
- `SYNTAX`: `₋` with no digit after it
- `SYNTAX`: `ⱼ` or `ₑ` beside a function or a space, as in `f←- ◇ fⱼ1`
- `INDEX`: the item is a unit, which has no axis to select from
- `DOMAIN`: `ₓ` on a complex number

## Differences from APL

BPL also accepts Dyalog's `x*2`, `f⍣2` and `f⍣¯1`. BQN writes the inverse as `𝔽⁼`. Neither language has subscripts.
