# Essays/Under

The conjunction under f&.g is defined as

f&.g y ${\displaystyle \leftrightarrow }$ gi f g y
x f&.g y ${\displaystyle \leftrightarrow }$ gi (g x) f (g y)

where gi is the inverse of g . "Under" elucidates the important but often mysterious concept of duality in mathematics.

The "under anaesthetics" example provides a graphic illustration. Several steps are composed:

apply anaesthetics
cut open
do procedure
sew up
wake up from anaesthetics

The inverse steps are pretty important! The "pipe laying" example provides another illustration: dig a trench, lay the pipe, cover the trench. Finally, a more poetic example: ashes to ashes, dust to dust.

Some examples of "under" in J:

• each:  f&.>
• Logic (De Morgan's Laws)
+.&.-. and
*.&.-. or
• Arithmetic
+&.^. times
+&.(10&^.) times
-&.^. reciprocal, divide
+:&.^. square
-:&.^. square root
*&.^ plus
%&.^ minus
>.&.- floor, minimum
<.&.- ceiling, maximum
,&0&.#: double
}:&.#: integer quotient of division by 2
+/\. -: +/\&.|.
x&<.&.(+/\) y usage in reservoirs y to a maximum of x; see J Forum msg
>:&.% gives x%x+y for a ratio x%y
• Trigonometric identities
|@sin -: -.&.*:@cos
|@cos -: -.&.*:@sin
sin -: sinh&.j.
tan -: tanh&.j.
sinh -: sin&.j.
tanh -: tan&.j.
sin -: ^ .: - &.j.
• Geometry
-.&.*: length of opposite from adjacent when hypotenuse is 1
+&.*: diagonal from rectangle sides
+/&.(*:"_) ${\displaystyle L_{2}}$ norm
+/&.(^&p) ${\displaystyle L_{p}}$ norm
• Primes and factoring
i.&.(p:^:_1) all the primes less than a number
<:&.(p:^:_1) the largest prime less than a number
[&.(p:^:_1) y or next prime
*/@(i.&.(p:^:_1))@>: primorial (see Prime APVs)
+:&.(_&q:) square
-:&.(_&q:) square root
<./&.(_&q:)@, GCD
>./&.(_&q:)@, LCM
+ /&.(_&q:)@, times
- /&.(_&q:)@, divide
(- ~:)&.q: Euler's totient function
* -.@%@~.&.q: Euler's totient function
>:@#.~/.~&.q: sum of divisors
~.&.q: the square-free part of a number
>:&.(q:^:_1) demonstration that there is no largest prime
• Various means
am=: +/ % # arithmetic mean
am&.:^. geometric mean
am&.:% harmonic mean
am&.:*: root mean square
• Arithmetic on sequences of bits:
+&.#.
-&.#.
*&.#.
<.@%&.#.
• Matrix algebra
%. -: %.&.|: real matrices
%. -: %.&.(+@|:) complex matrices
%. -: %.&.(M&(+/ .*)) M is an invertible matrix
• Identities for matrix products ${\displaystyle M=M_{1}M_{2}\dots M_{n}}$
x=: +/ .*
x/ -: x/&.(|:"2"_)@|. i.e. ${\displaystyle M^{T}=M_{n}^{T}M_{n-1}^{T}\dots M_{1}^{T}}$
x/ -: x/&.(%."_)@|. i.e. ${\displaystyle M^{-1}=M_{n}^{-1}M_{n-1}^{-1}\dots M_{1}^{-1}}$
[try e.g.  (x/ ; x/&.(|:"2"_)@|. ; x/&.(%."_)@|.) ?.5 2 2\$0 ]
• Round to p decimal places
([: <. +&0.5) &. (*&(10^p))
] &. ((j.p)&":)
• Decimal digits of an integer: ,.&.":
• Reverse bits and digits
|.&.(10&#.^:_1) reversing base 10 digits
|.&.": reversing base 10 digits
1&|.&.#: survivor number in the Josephus problem
/:~&.(|."1@#:) arrange a list of distinct positive integers so that no average is spanned
• Reverse the words of a sentence: |.&.;:
• Caesar cipher (Julius Caesar used n=:13)
A=: 'abcdefghijklmnopqrstuvwxyz'
(#A)&|@(+&n) &. (A&i.) encrypt
(#A)&|@(-&n) &. (A&i.) decrypt
• Operate on text as integer:  'ibm' -: >:&.:(a.&i.)'hal'
• Extend verb domain: =&0`(0 ,:~ %)}&.,: under itemize succeeds with scalar argument
• The e.g.f. of the Fibonacci sequence is ${\displaystyle {1 \over \phi }e^{x/2}\,{\sinh \phi x}}$ . Thus:  (^@-: * 5&o.&.((-:%:5)&*)) t:
• ack is Ackermann's Function. If x ack y is f&.(3&+) y , then (x+1) ack y is f^:(1+y)&.(3&+) 1
• The next Gray code word:  >: &. #. &. (~:/\)
• n-th Chebyshev polynomials
acos=: _2&o.
n&*&.acos the first kind
(n+1)&*&.acos %&(-.&.*:) ] absolute value of the second kind
• The square-free part of a polynomial:  ({. , ~.&.>@{:)&.p.
• The inverse of a permutation
|:&.({=)
%.&.({=)
|.&.>&.C.
• The next/previous permutation
rfd=: +/@(<{.)\."1 reduced from direct, from Permutation Index
dfr=: /:@/:@,/"1 direct from reduced
b=: (-i.)# p
>:&.(b&#.)&.(rfd :. dfr) p the next    permutation
<:&.(b&#.)&.(rfd :. dfr) p the previous permutation
• Fast Fourier Transform
+//.@(*/) = *&.FFT polynomial multiplication on arguments of length 2^n

Contributed by Roger Hui, with further contributions by Raul Miller, Ewart Shaw, and David Lambert.