Power: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
Line 4: Line 4:
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td>successively applies the function <apll><i>f</i></apll> (or, if there is a Left argument, the function <apll>L∘<i>f</i></apll>) to <apll>R</apll> until the expression <apll>Z<sub>n</sub> <i>g</i> Z<sub>n-1</sub></apll> returns a singleton <apll>1</apll>.  <apll>Z<sub>n</sub></apll> and <apll>Z<sub>n-1</sub></apll> represent two consecutive applications of <apll><i>f</i></apll> (or <apll>L∘<i>f</i></apll>) to <apll>R</apll> where <apll>Z<sub>n</sub> ←→ <i>f</i> Z<sub>n-1</sub></apll> (or <apll>Z<sub>n</sub> ←→ L∘<i>f</i> Z<sub>n-1</sub></apll>).</td>
   <td>successively applies the function <apll><i>f</i></apll> (or, if there is a Left argument, the function <apll>L∘<i>f</i></apll>) to <apll>R</apll> until the expression <apll>Z<sub>n</sub> <i>g</i> Z<sub>n-1</sub></apll> returns a singleton <apll>1</apll>.  <apll>Z<sub>n</sub></apll> and <apll>Z<sub>n-1</sub></apll> represent two consecutive applications of <apll><i>f</i></apll> (or <apll>L∘<i>f</i></apll>) to <apll>R</apll> where <apll>Z<sub>0</sub>←R</apll> and <apll>Z<sub>n</sub><i>f</i> Z<sub>n-1</sub></apll> (or <apll>Z<sub>n</sub>←L∘<i>f</i> Z<sub>n-1</sub></apll>).</td>
</tr>
</tr>



Revision as of 21:19, 29 June 2018

Z←{L} fg R successively applies the function f (or, if there is a Left argument, the function L∘f) to R until the expression Zn g Zn-1 returns a singleton 1. Zn and Zn-1 represent two consecutive applications of f (or L∘f) to R where Z0←R and Znf Zn-1 (or Zn←L∘f Zn-1).
Z←{L} fb R for non-negative singleton integer b, successively applies the function f (or, if there is a Left argument, the function L∘f) to R, b number of times.
L and R are arbitrary arrays.
In the first case, Zn g Zn-1 must return a Boolean-valued singleton; otherwise a DOMAIN ERROR is signaled.
In the second case, b must be a non-negative integer singleton. If b is a negative integer singleton, a NONCE ERROR is signaled as Function Inverses haven't been implemented as yet; otherwise a DOMAIN ERROR is signaled.


For example,

      sqrt←{{0.5×⍵+⍺÷⍵}⍣=⍨⍵} ⍝ Calculate square root using Newton's method
      sqrt 2
1.414213562373095
      fib←{⍵,+/¯2↑⍵} ⍝ Calculate a Fibonacci sequence
      fib⍣15 ⊢ 1 1
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 
      pow←{⍵=0:,1 ⋄ ⍺+⍡×⍣(⍵-1) ⍺} ⍝ Raise a polynomial to a non-negative integer power
      1 ¯1 pow 5
1 ¯5 10 ¯10 5 ¯1
      phi←1+∘÷⍣=1 ⍝ Calculate the Golden Ratio
      phi
1.618033988749894