Add: Difference between revisions

Jump to navigation Jump to search
108 bytes added ,  21:26, 10 September 2022
m
Text replacement - "</source>" to "</syntaxhighlight>"
m (Text replacement - "</source>" to "</syntaxhighlight>")
Line 1: Line 1:
{{Built-in|Add|+}}, '''Plus''', '''Addition''', or '''Sum''', is a [[dyadic]] [[scalar function]] that [[wikipedia:Addition|adds]] numbers together. As a basic arithmetic operation, Add is subject to the language's [[number]] specification. Add shares the glyph <source lang=apl inline>+</source> with the [[monadic]] function [[Conjugate]], and is closely related to [[Subtract]] (<source lang=apl inline>-</source>).
{{Built-in|Add|+}}, '''Plus''', '''Addition''', or '''Sum''', is a [[dyadic]] [[scalar function]] that [[wikipedia:Addition|adds]] numbers together. As a basic arithmetic operation, Add is subject to the language's [[number]] specification. Add shares the glyph <source lang=apl inline>+</syntaxhighlight> with the [[monadic]] function [[Conjugate]], and is closely related to [[Subtract]] (<source lang=apl inline>-</syntaxhighlight>).


== Examples ==
== Examples ==
Line 8: Line 8:
       0.1 + 3 4 5
       0.1 + 3 4 5
3.1 4.1 5.1
3.1 4.1 5.1
</source>
</syntaxhighlight>


== Properties ==
== Properties ==
Line 14: Line 14:
Addition is [[wikipedia:Commutative property|commutative]] in almost all number systems. It is [[wikipedia:Associative property|associative]] when performed with no rounding, but is unlikely to be associative when rounded to an inexact precision (see [[#Floating point error|Floating point error]]).
Addition is [[wikipedia:Commutative property|commutative]] in almost all number systems. It is [[wikipedia:Associative property|associative]] when performed with no rounding, but is unlikely to be associative when rounded to an inexact precision (see [[#Floating point error|Floating point error]]).


The [[identity element]] for Add is <source lang=apl inline>0</source>. The [[inverse]] of the function <source lang=apl inline>n∘+</source> or the equivalent function <source lang=apl inline>+∘n</source> is <source lang=apl inline>-∘n</source>. Using [[Commute]] (<source lang=apl inline>⍨</source>), we can write <source lang=apl inline>+⍣¯1</source> {{←→}} <source lang=apl inline>-⍨</source>.
The [[identity element]] for Add is <source lang=apl inline>0</syntaxhighlight>. The [[inverse]] of the function <source lang=apl inline>n∘+</syntaxhighlight> or the equivalent function <source lang=apl inline>+∘n</syntaxhighlight> is <source lang=apl inline>-∘n</syntaxhighlight>. Using [[Commute]] (<source lang=apl inline>⍨</syntaxhighlight>), we can write <source lang=apl inline>+⍣¯1</syntaxhighlight> {{←→}} <source lang=apl inline>-⍨</syntaxhighlight>.


Since adding a number to itself is equivalent to doubling that number, we can express the ''double'' function as <source lang=apl inline>+⍨</source>.
Since adding a number to itself is equivalent to doubling that number, we can express the ''double'' function as <source lang=apl inline>+⍨</syntaxhighlight>.


=== Reduction ===
=== Reduction ===
Line 40: Line 40:
       (1e20 + ¯1e20) + 1      ⍝ Not equivalent
       (1e20 + ¯1e20) + 1      ⍝ Not equivalent
1
1
</source>
</syntaxhighlight>


Addition of floating-point numbers may also be subject to [[overflow]], resulting in a [[DOMAIN ERROR]] or an [[infinite]] result.
Addition of floating-point numbers may also be subject to [[overflow]], resulting in a [[DOMAIN ERROR]] or an [[infinite]] result.

Navigation menu