Help / Phrases / 11. A. Inverse

From J Wiki
Jump to navigation Jump to search


>> << Pri JfC LJ Phr Dic Voc !: Rel NuVoc wd Help Phrases


11A. Inverse

J provides a comprehensive calculus of inverses:

a0=: I=: ^:_1 Inverse (adverb)
m1 =: ^ I Natural log (^.); Inverse exponential
m2 =: ^.I Exponential
m3 =: 10&^. Base 10 log
m4 =: m3 I Inverse base 10 log (10&^)
m5 =: ] -: m4@m3 Tautology (test that m4 is left inverse)
m6 =: ] -: m3@m4 Tautology (test that m4 is right inverse)
m7 =: ssc=: +/\ Sum scan (subtotals)
m8 =: ssc I Inverse sum scan; first differences
m9 =: (]-:m8@m7)*.(]-:m7@m8) Tautology
m10=: assc=: -/\ Alternating sum scan
m11=: assc I  
m12=: ] -:  
m13=: * /\ I e.g. * /\ m13 3 1 4 15 9 26 5 3
m14=: % /\ I e.g. % /\ m14 3 1 4 15 9 26 5 3
m15=: ~:/\ I e.g. ~:/\ m15 1 1 0 1 1 0 1 1
m16=: = /\ I e.g. = /\ m16 1 1 0 1 1 0 1 1
m17=: + /\. I e.g. + /\. m17 3 1 4 15 9 26 5 3
m18=: - /\. I e.g. - /\. m18 3 1 4 15 9 26 5 3
m19=: * /\. I e.g. * /\. m19 3 1 4 15 9 26 5 3
m20=: % /\. I e.g. % /\. m20 3 1 4 15 9 26 5 3
m21=: ~:/\. I e.g. ~:/\. m21 1 1 0 1 1 0 1 1
m22=: = /\. I e.g. =/\. m22 1 1 0 1 1 0 1 1
d23=: # I Expand; 'ab' -: 1 0 1 # 1 0 1 d23 'ab'
m24=: p: I p (n) the number of primes less than n
m25=: x: I Floating point approx. of a rational. e.g. m25 3r7
m26=: 1&+ I Inverse increment; decrement
m27=: +&1 I Inverse increment; decrement
m28=: >: I Inverse increment; decrement
m29=: _1&+ I Inverse decrement; increment
m30=: +&_1 I Inverse decrement; increment
m31=: -&1 I Inverse decrement; increment
m32=: <: I Inverse decrement; increment
m33=: 2&* I Inverse double; halve
m34=: *&2 I Inverse double; halve
m35=: +: I Inverse double; halve
m36=: 0.5&* I Inverse halve; double
m37=: *&0.5 I Inverse halve; double
m38=: %&2 I Inverse halve; double
m39=: -: I Inverse halve; double
m40=: ^&2 I Inverse square
m41=: ^&3 I Inverse cube
m42=: ^&0.5 I Inverse square root
m43=: ^&1r3 I Inverse cube root
m44=: 2&^ I Inverse 2 with power; base 2 log
m45=: 10&^ I Inverse 10 with power; base 10 log
m46=: 2&! I Inverse triangular number. e.g. +/i.<.2&! I m
m47=: +~ I Inverse double
m48=: *~ I Inverse square
m49=: ^~ I e.g. x^x=: ^~ I 12
m50=: (3&+)@(%&2)I -: (%&2 I)@(3&+ I) Inverse of composition is composition of inverses

These inverses may be illustrated as follows:

   x=: 2 3 5 7 
   ,.(] ; m1 ; m2 ; m1@m2) x
+---------------------------------+
¦2 3 5 7                          ¦
+---------------------------------¦
¦0.6931472 1.09861 1.60944 1.94591¦
+---------------------------------¦
¦7.38906 20.0855 148.413 1096.63  ¦
+---------------------------------¦
¦2 3 5 7                          ¦
+---------------------------------+

   (] ; m7 ; m8 ; m9) x
+---------------------------+
¦2 3 5 7¦2 5 10 17¦2 1 2 2¦1¦
+---------------------------+
   (];m10;m11;m11@m10) x
+-----------------------------------+
¦2 3 5 7¦2 _1 4 _3¦2 _1 2 _2¦2 3 5 7¦
+-----------------------------------+



>> << Pri JfC LJ Phr Dic Voc !: Rel NuVoc wd Help Phrases