Subtract: Difference between revisions

Jump to navigation Jump to search
12 bytes added ,  00:32, 13 January 2020
m
no edit summary
Miraheze>Marshall
(Created page with ":''This page describes the dyadic arithmetic function. For negation of a single argument, see Negate. For subtraction of sets, see Without.'' {{Built-in|Subtract|-}},...")
 
mNo edit summary
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
:''This page describes the dyadic arithmetic function. For negation of a single argument, see [[Negate]]. For subtraction of sets, see [[Without]].''
:''This page describes the dyadic arithmetic function. For negation of a single argument, see [[Negate]]. For subtraction of sets, see [[Without]].''


{{Built-in|Subtract|-}}, '''Minus''', '''Subtraction''', or '''Difference''' is a [[dyadic]] [[scalar function]] which gives the arithmetic [[wikipedia:Subtraction|difference]] of its [[argument]]s. Subtract shares the [[glyph]] <source lang=apl inline>-</source> with the arithmetic negation function [[Minus]], and its result is the left argument [[plus]] the negation of the right.
{{Built-in|Subtract|-}}, '''Minus''', '''Subtraction''', or '''Difference''' is a [[dyadic]] [[scalar function]] which gives the arithmetic [[wikipedia:Subtraction|difference]] of its [[argument]]s. Subtract shares the [[glyph]] <source lang=apl inline>-</source> with the arithmetic function [[Negate]], and its result is the left argument [[plus]] the negation of the right.


== Examples ==
== Examples ==
Line 28: Line 28:
7
7
</source>
</source>
In the absense of rounding error we have <source lang=apl inline>-/v {{←→}} <source lang=apl inline>+/v×(⍴v)⍴1 ¯1</source> for a [[vector]] <source lang=apl inline>v</source>.
In the absense of rounding error we have <source lang=apl inline>-/v</source> {{←→}} <source lang=apl inline>+/v×(⍴v)⍴1 ¯1</source> for a [[vector]] <source lang=apl inline>v</source>.


An interesting property of the alternating difference is that it can be used as a [[wikipedia:Divisibility rule|divisibility test]] for division by 11, a counterpart to the better-known test for divisibility by 9. A number is divisible by 11 if and only if the sum of its digits is divisible by 11, so repeatedly taking the alternating sum of the digits determines divisibility by 11.
An interesting property of the alternating difference is that it can be used as a [[wikipedia:Divisibility rule|divisibility test]] for division by 11, a counterpart to the better-known test for divisibility by 9. A number is divisible by 11 if and only if the sum of its digits is divisible by 11, so repeatedly taking the alternating sum of the digits determines divisibility by 11.
Line 41: Line 41:


[[Scan]] with subtraction produces a prefix of an [[wikipedia:Alternating series|alternating series]]. This property is one of the reasons why scan was designed to reduce [[prefix]]es rather than [[suffix]]es of the argument array. As an example, we can see that an alternating series using the [[power]]s of two begins to converge to a third:
[[Scan]] with subtraction produces a prefix of an [[wikipedia:Alternating series|alternating series]]. This property is one of the reasons why scan was designed to reduce [[prefix]]es rather than [[suffix]]es of the argument array. As an example, we can see that an alternating series using the [[power]]s of two begins to converge to a third:
<source lang=apl inline>
<source lang=apl>
       -\ ÷2*⍳6
       -\ ÷2*⍳6
0.5 0.25 0.375 0.3125 0.34375 0.328125
0.5 0.25 0.375 0.3125 0.34375 0.328125
Line 53: Line 53:
* [http://microapl.com/apl_help/ch_020_020_040.htm APLX]
* [http://microapl.com/apl_help/ch_020_020_040.htm APLX]
* J [https://www.jsoftware.com/help/dictionary/d120.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/minus#dyadic NuVoc]
* J [https://www.jsoftware.com/help/dictionary/d120.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/minus#dyadic NuVoc]
{{APL built-ins}}

Navigation menu