JPhrases/Duality
< JPhrases
Jump to navigation
Jump to search
11B. Duality
h -: f&.g asserts that h is the dual of f under (or with respect to) g
m0 =: A=: +/ % # Arithmetic mean m1 =: H=: A &. (%"_) Harmonic mean m2 =: M=: A &. (^&p) Generalized mean a3 =: N=: (^&) (A&.) L-x norm; 3-norm is 3 N y m4 =: +/ &. (*:"_) @ +. Magnitude | e.g. m4 3j4 a5 =: each=: &.> Each (f each applies f to each box) m6 =: ^ .: -&.j. Sine m7 =: sin -: sinh&.j. Tautology m8 =: tan -: tanh&.j. " m9 =: sinh -: sin&.j. " m10=: cosh -: cos& j. " m11=: tanh -: tan&.j. " v12=: <. -: >.&.- Tautology v13=: >. -: <.&.- Tautology d14=: * -: +&.^. Tautology d15=: * -: +&.(10&^.) Tautology v16=: % -: -&.^. Tautology d17=: + -: *&.^ Tautology d18=: + -: *&.(10&^) Tautology v19=: - -: %&.^ Tautology v20=: %. -: %.&.|: Tautology v21=: %. -: %.&.(+@|:) Tautology m22=: +/\ -: +/\.&.|. Tautology m23=: +/\. -: +/\ &.|. Tautology a24=: BW=: 1 : 'u./&.#:' Bitwise adverb m25=: *. BW Bitwise AND. e.g. m25 _1 100 200 m26=: +. BW Bitwise OR e.g. m26 100 200 m27=: ~: BW Bitwise XOR e.g. m27 100 200 m28=: i.&.(p:^:_1) The primes less than n m29=: totient=: * -.@%@~.&.q: Euler's totient function m30=: |.&.;: Reverse the words; e.g. m30 'three score and ten years' n31=: a=: ' abcdefghijklmnopqrstuvwxyz' Space and alphabet m32=: encrypt=: (#a)&|@>: &. (a&i.) Julius Caesar's cypher. e.g. m33=: decrypt=: (#a)&|@<: &. (a&i.) decrypt encrypt x=:'from sea to sea' m34=: J=: 1&|.&.#: Survivor number in the Josephus problem of order n d35=: ack=: c1`c1`c2`c3 @. (#.@(,&*)) Ackermann's function d36=: c1=: >:@] d37=: c2=: <:@[ ack 1: d38=: c3=: <:@[ ack [ ack <:@] m39=: 0&ack -: >:&.(3&+) Tautology m40=: 1&ack -: 2&+&.(3&+) Tautology m41=: 2&ack -: 2&*&.(3&+) Tautology m42=: 3&ack -: 2&^&.(3&+) Tautology m43=: 4&ack -: ^/@#&2&.(3&+) Tautology m44=: 5&ack -: 3 : '^/@#&2^:(1+y)&.(3&+) 1' Tautology