Power: Difference between revisions

From NARS2000
Jump to navigationJump to search
(Created page with "<table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> <tr> <td valign="top"><apll>Z←{L} <i>f</i/>⍣<i>g</i> R</apll></td> <td></td> <td></td> <...")
 
No edit summary
Line 15: Line 15:


<tr>
<tr>
   <td colspan="4"><apll>L</apll> and <apll>R</apll> are arbitrary arrays</td>
   <td colspan="4"><apll>L</apll> and <apll>R</apll> are arbitrary arrays.</td>
</tr>
</tr>


Line 23: Line 23:


<tr>
<tr>
   <td colspan="4">In the second case, <apll><i>b</i></apll> must be a non-negative integer singleton; otherwise a <apll>DOMAIN ERROR</apll> is signaled.</td>
   <td colspan="4">In the second case, <apll><i>b</i></apll> must be a non-negative integer singleton.  If <apll><i>b</i></apll> is a negative integer singleton, a <apll>NONCE ERROR</apll> is signaled as Function Inverses haven't been implemented as yet; otherwise a <apll>DOMAIN ERROR</apll> is signaled.</td>
</tr>
</tr>



Revision as of 20:39, 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 Zn ←→ f 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