The conjunction under f&.g is defined as
f&.g y
gi f g y
x f&.g y
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 msgTrigonometric 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
+/&.(*:"_)
norm
+/&.(^&p)
norm
Primes and factoring
i.&.(p:^:_1) all the primes less than a number
<:&.(p:^:_1) the largest prime less than a number
*/@(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: 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
x=: +/ .*
x/ -: x/&.(|:"2"_)@|. i.e.
x/ -: x/&.(%."_)@|. i.e.
[try e.g. (x/ ; x/&.(|:"2"_)@|. ; x/&.(%."_)@|.) ?.5 2 2$0 ]Round to p decimal places
([: <. +&0.5) &. (*&(10^p))
] &. ((j.p)&":)
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 spannedReverse the words of a sentence: |.&.;:
Caesar cipher (Julius Caesar used n=:3)
A=: 'abcdefghijklmnopqrstuvwxyz'
(#A)&|@(+&n) &. (A&i.) encrypt
(#A)&|@(-&n) &. (A&i.) decrypt
The e.g.f. of the Fibonacci sequence is
. 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 kindThe 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 RogerHui, with further contributions by Raul Miller, EwartShaw, and DavidLambert.
