Skip to main content

⍣ — Power

Dyadic operator. Keys: Alt-1 8. Hanzi: 次/止

f⍣N Y applies f N times. N=0 returns Y. In dyadic calls the left argument stays fixed. The separator ⁝ keeps a literal count apart from a literal argument, as in ⊽⍣3⁝1. With a left argument, parentheses show the derived function between its arguments, as in 2(+⍣3)1.

⊽⍣3⁝1             ⍝ 8
2(+⍣3)1            ⍝ 7

Negative counts apply the known inverse. Bare ⁻ writes f⍣¯1 as f⁻. Repeat with f⍣2; f² instead means rank 2.

⊽⍣¯1⁝10           ⍝ 5
10 -\⍣¯1 [9 7 4]     ⍝ 1 2 3

Inverses propagate through Atop, dyadic After and Before, bound arguments, Each, rank, dyadic Commute and scans. Primitive inverses include arithmetic bindings, exp/log, circle, axis permutations, encode/decode, enclosure/mix/split, Where and replicate. Square roots and logs select branches.

f⍣g Y iterates until new g old is true, returning new.

≥⍣{⍺>4}0          ⍝ 5

A vector of counts gives one item for each count, holding the state after that many steps. Counts ⍳N give the first N states, starting with Y. A nested vector of counts gives a nested result, with one item for each inner vector. A scalar count gives a scalar. Computed counts go in parentheses or in the run after ⍣.

⊽⍣(⍳5ₓ) 1               ⍝ [1 2 4 8 16]
≥⍣(-⍳3ₓ) 5             ⍝ [5 4 3]
≥⍣3 ¯2 0 3⁝10        ⍝ 13 8 10 13
,↢1⍣ ⍳3ₓ [2]           ⍝ [[2] [2 1] [2 1 1]]
⍴ {÷'a'}⍣(0 2⍴0) "ab"  ⍝ [0 2]ₓ
⊽⍣[2 [4 ¯2 1]] 1        ⍝ [4 [16 0.25 2]]
⊽⍣(⊂3) 1               ⍝ ⊂8

Positive counts run first, then negative counts run the inverse, also from Y. A repeated count reuses its state. Empty counts give an empty result with the counts’ shape.

Fixed point

A count of ∞ runs until the state stops changing, the same test as ⍣≡. ¯∞ runs the inverse until it converges. ∞ can sit in a vector of counts. Here n is Newton’s step towards √2. It gives half of its argument (⊽⁻, the inverse of double) plus the argument’s reciprocal (÷).

n←⊽⁻+÷
n⍣∞⁝1                 ⍝ 1.414213562373095
n⍣[0 ∞]1               ⍝ 1 1.414213562373095

History

The until form keeps every state when its predicate is in a one-item vector: f⍣[g]. The states run from Y to the first state where g holds. f always runs at least once. For example, ⊢⍣[≡]4 gives 4 4.

≥⍣[{⍺=3}]0           ⍝ 0 1 2 3
⊢⍣[≡]4                ⍝ 4 4
n←⊽⁻+÷ ⋄ ≢n⍣[≡]1         ⍝ 7ₓ

See assigning an inverse.

Inverse

(f⍣n)⁻ is f⍣(-n).

(⊽⍣3)⁻16   ⍝ 2

Errors

  • DOMAIN: a count that is neither whole nor infinite, non-Boolean predicate, unknown inverse