Math.Arithmetic.Addition

From Fōrmulæ dictionary
Jump to: navigation, search

Math.Arithmetic.Addition is the tag for the expression representing the mathematical addition.

Definition

Math.Arithmetic.Addition is the tag for the expression representing the mathematical addition.

Notice that the string concatenation uses other tag, this is String.Text.Concatenation

Notice that there is no subtraction expression. A subtraction is an addition operation where the sustraend is a negative expression, it is

Behavior

This expression must have at least two children.

Children names

The subexpressions should be named "Addend 1", "Addend 2", etc. First addend must be numbered as one, contrary to several programming languages, in which first element is numbered as zero.

Localization packages could be created in order to provide the names in languages other than English.

Visualization

There could be different visualizations, being the most popular the infix one, that us, using the (+) symbol between each consecutive pair of addends

Other form of visualization could exist, like the prefix form and rarely the postfix form.

Edition

There could be several editions. The most obvious is: Given a selected expression, it is replaced by a new addition expression with two children, the first one is the expressions that was selected, and the second one is a new Null expression. The latter becomes the new selected expression.

Reduction

Ther could be several reductions, see below.

Known implementations

The Standard Arithmetic Package

Visualization

There is one visualization on this package. It is a infix one.

It aligns the horizontal baselines of the addends, and the vertical baseline is located in the middle of the width of the expression. See the following example:

MetricsAddition.png

Negative addends

If an addend is a Math.Arithmetic.Negative expression, and it is not the first child, the minus sign (-) is drawn instead or the plus (+) one. The visualization of the Math.Arithmetic.Negative expression is not invoked, but its child's visualization is instead invoked, this is, the visualization of the unique child of the Math.Arithmetic.Negative expression. In the following example the middle addend is a Math.Arithmetic.Negative expression. The minus sign (-) was drawn by the Math.Arithmetic.Addition expression not the Math.Arithmetic.Negative one.

Addition1.png

Parentheses awareness

This visualization awares whether some of its children belong to the parentheses category Parentheses as operator. In such that case, these children are drawn between parentheses.

In the following example, the second addend is also an addition. Because this expression also belongs to the parentheses category Parentheses as operator (see below), the parent addition shows its children addition between parentheses.

Addition2.png

Parentheses categories

This visualization belongs to the category Parentheses as operator. It means that if this visualization is a child of a parent visualization that awares of this, that such parent expression will show this child between parentheses.

In the following example, the Math.Arithmetic.Negative visualization awares of its unique child to belong of that category, to show it between parentheses:

Negative8.png

This visualization belongs to the category Parentheses as super/subscripted. It means that if this visualization is a child of a parent visualization that awares of this, that such parent expression will show this child between parentheses.

In the following example, the Math.Arithmetic.Exponentiation visualization awares of either its base or exponent to belong of that category, to show either the base or the exponente between parentheses (in this case is the base):

Addition3.png

Edition

There are several editions in this package, which are the combinations of a default edition with three variants:

Variation Meaning
default (no variation) Creates a new Math.Arithmetic.Addition Expression, the current selected expression becomes the first addend, a new Null expression is created and becomes the second addend.
Subtraction A Math.Arithmetic.Negative expression containing a Null expression is created as the second addend, in order to resemble a subtraction. Remember that, according to the Arithmetic canon, subtraction does not exist, the expression is an addition with a negative addend, such like
Before The new expression (usually a Null expression) will be created as the first addend, instead of the second one
Forced Usually, if the current selected expression is already a Math.Arithmetic.Addition expression, or an addend of a Math.Arithmetic.Addition expression, a new addend is not created. With this option an addition is always created.

In the following examples, the selected expression is neither a Math.Arithmetic.Addition or an addend, so the "Forced" variant behaves as the default edition.

Example Edition performed Result
Addition34.png Addition.png Addition Addition35.png
AdditionStrict.png Addition (forced)
AdditionBefore.png Addition (before) Addition36.png
AdditionBeforeStrict.png Addition (forced, before)
Minus.png Subtraction Addition37.png
MinusStrict.png Subtraction (forced)
AdditionBefore.png Subtraction (before) Addition38.png
MinusBeforeStrict.png Subtraction (forced, before)

In the following examples, the selected expression is a Math.Arithmetic.Addition or an addend one, so the "Forced" variation applies:

Example Edition performed Result
Addition4.png Addition.png Addition Addition8.png
AdditionBefore.png Addition (before) Addition10.png
AdditionStrict.png Addition (forced) Addition9.png
AdditionBeforeStrict.png Addition (forced, before) Addition11.png
Minus.png Subtraction Addition12.png
AdditionBefore.png Subtraction (before) Addition13.png
MinusStrict.png Subtraction (forced) Addition14.png
MinusBeforeStrict.png Subtraction (forced, before) Addition15.png
Addition5.png Addition.png Addition Addition16.png
AdditionBefore.png Addition (before) Addition8.png
AdditionStrict.png Addition (forced) Addition17.png
AdditionBeforeStrict.png Addition (forced, before) Addition18.png
Minus.png Subtraction Addition19.png
MinusBefore.png Subtraction (before) Addition20.png
MinusStrict.png Subtraction (forced) Addition21.png
MinusBeforeStrict.png Subtraction (forced, before) Addition22.png
Addition6.png Addition.png Addition Addition23.png
AdditionBefore.png Addition (before) Addition16.png
AdditionStrict.png Addition (forced) Addition24.png
AdditionBeforeStrict.png Addition (forced, before) Addition25.png
Minus.png Subtraction Addition26.png
MinusBefore.png Subtraction (before) Addition27.png
MinusStrict.png Subtraction (forced) Addition28.png
MinusBeforeStrict.png Subtraction (forced, before) Addition29.png
Addition7.png Addition.png Addition Addition23.png
AdditionBefore.png Addition (before) Addition10.png
AdditionStrict.png Addition (forced) Addition30.png
AdditionBeforeStrict.png Addition (forced, before) Addition31.png
Minus.png Subtraction Addition26.png
MinusBefore.png Subtraction (before) Addition13.png
MinusStrict.png Subtraction (forced) Addition32.png
MinusBeforeStrict.png Subtraction (forced, before) Addition33.png

Reduction

Addition of numeric addends

This reducer searches on the Math.Arithmetic.Addition children, for numeric expressions. If there are more than one, performs a numeric addition. According to Arithmetic canon, a numeric expression is either:

The following are examples. In these examples, expressions , and are supposed not to be numeric expressions.

Expression before reduction Expression after reduction Explanation
The same It does not reduce, there are no numeric expressions as addends.
The same It does not reduce, there are not two or more numeric expressions as addends.
According to Arithmetic canon, if any operand is a decimal number, the result must be either.
According to Arithmetic canon, if any operand is a decimal number, the result must be either.

If there is a reduction, and the numeric result of this reduction is zero, it will be removed of the Math.Arithmetic.Addition expression, unless it remains as the only expression.

The following are examples. Again, and are supposed not to be numeric expressions.

Expression before reduction Expression after reduction Explanation
Zero is removed.
Zero is not removed, it remains as the only child.

According to Arithmetic canon, if any operand is a decimal number, the result must be either.

Flatten nested additions

This reducer searches into the current Math.Arithmetic.Addition for children being also Math.Arithmetic.Addition expressions. For each one of them, it integrates their addends as addends of the current Math.Arithmetic.Addition expression.

For example, the following -three addends- addition:

reduces to the following -five addends- addition:

In the above example, and expressions are supposed not to be Math.Arithmetic.Addition expressions.

Flatten negative additions as negative addends

This reducer searches into the current Math.Arithmetic.Addition for children being a Math.Arithmetic.Negative expression containing a Math.Arithmetic.Addition expressions. For each one of them, it integrates their addends as negative addends -math.Arithmetic.Negative- of the current Math.Arithmetic.Addition expression.

For example, the following -three addends- addition:

reduces to the following -five addends- addition:

In the above example, and expressions are supposed not to be Math.Arithmetic.Addition expressions.

The Standard list package

This package does not contain visualizers nor editors for the Math.Arithmetic.Addition expression.

Reduction

Matrix addition

This reducer searches for Structure.List addends. These lists must also contain identical number of Structure.List expressions also containing identical number of sub-lists. Then they are matrices of same dimension. If there are two or more such matrices, a matrix addition is performed

The following are examples. In these examples, expressions , and are supposed not to be matrices, according to the definition already given.

Expression before reduction Expression after reduction Explanation
The same It does not reduce, there are no matrix expressions as addends.
The same It does not reduce, there are not two or more matrix expressions as addends.
The same It does not reduce, matrices are of different sizes.
Only matrices of same size are added