Documentation for arithmetic operations (+, -, *, /, ^)

The documentation for the basic operations was not written.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
Christophe de Dinechin 2023-08-07 22:32:14 +02:00
parent 4331d7a623
commit 453753490d
2 changed files with 102 additions and 1 deletions

View file

@ -1,3 +1,104 @@
# Arithmetic
## + (add)
Add two values.
* For integer, fractional, decimal or complex numbers, this performs the
expected numerical addition. For example, `1 2 +` is `3`.
* For equations and symbols, build a sum, eliminating zero additions if
[autosimplify](#autosimplify) is active.
* For lists, concatenate lists, or add objets to a list. For example, `{ A } { B
} +` is `{ A B }`, and `{ A B C } "D" +` is `{ A B C "D" }`.
* For text, concatenate text, or concatenate the text representation of an
object to an existing text. For example `"X" "Y" + ` gives `"XY"`, and
`"X=" 1 +` gives `"X=1"`.
## - (sub)
Subtract two values
* For integer, fractional, decimal or complex numbers, this performs the
expected numerical subtraction. For example, `1 2 -` is `-1`.
* For equations and symbols, build a difference, eliminating subtraction of 0 if
[autosimplify](#autosimplify) is active.
## + (add)
Add two values.
* For integer, fractional, decimal or complex numbers, this performs the
expected numerical addition. For example, `1 2 +` is `3`.
* For vectors and matrices, add individual elements. For example,
`[ 1 2 3 ] [ 4 5 6 ] +` is `[ 5 7 9 ]`.
* For equations and symbols, build a sum, eliminating zero additions
when [autosimplify](#autosimplify) is active.
* For lists, concatenate lists, or add objets to a list. For example, `{ A } { B
} +` is `{ A B }`, and `{ A B C } "D" +` is `{ A B C "D" }`.
* For text, concatenate text, or concatenate the text representation of an
object to an existing text. For example `"X" "Y" + ` gives `"XY"`, and
`"X=" 1 +` gives `"X=1"`.
## - (sub)
Subtract two values
* For integer, fractional, decimal or complex numbers, this performs the
expected numerical subtraction. For example, `1 2 -` is `-1`.
* For vectors and matrices, subtract individual elements. For example,
`[ 1 2 3 ] [ 1 3 0 ] -` is `[ 0 -1 3 ]`.
* For equations and symbols, build a difference, eliminating subtraction of 0
when [autosimplify](#autosimplify) is active.
## × (*, mul)
Multiply two values.
* For integer, fractional, decimal or complex numbers, this performs the
expected numerical multiplication. For example, `3 2 *` is `6`.
* For vectors, multiply individual elements (this is a deviation from HP48).
For example, `[ 1 2 3 ] [ 4 5 6 ] +` is `[ 4 10 18 ]`.
* For matrices, perform a matrix multiplication.
* For a matrix and a vector, apply the matrix to the vector.
* For equations and symbols, build a product, eliminating mulitplication by 1
or 0 when [autosimplify](#autosimplify) is active.
* For a list and a positive integer, repeat the list For example, `{ A } 3 *`
is `{ A A A }`.
* For a text and a positive integer, repeat the text. For example `"X" 3 * `
gives `"XXX"`.
## ÷ (/, div)
Divide two values two values
* For integer, build a fraction. For example `1 7 /` gives `1/7`.
* For fractional, decimal or complex numbers, this performs the
expected numerical division. For example, `1. 2. /` is `0.5`.
* For vectors, divide individual elements. For example,
`[ 1 2 3 ] [ 3 2 1 ] /` is `[ 1/3 1 3 ]`.
* For equations and symbols, build a ratio, eliminating division by one
and division of 0 when [autosimplify](#autosimplify) is active.
## ↑ (^, pow)
Raise to the power
* For integer, fractional, decimal or complex numbers, this raises the
value in level 2 to the value in level 1. For example, `2 3 ↑` is `8`.
* For vectors, raise individual elements in the first vector to the power of the
corresponding element in the second vector.
* For equations and synbols, build an expression, eliminating special cases
when [autosimplify](#autosimplify) is active.
## xroot
Raise to the inverse power. `X Y xroot` is equivalent to `X Y inv pow`.
# Integer arithmetic and polynomials
## SETPREC

View file

@ -3387,7 +3387,7 @@ static const byte defaultSecondShiftedCommand[2*user_interface::NUM_KEYS] =
// All the default assigned commands fit in one or two bytes
{
OP2BYTES(KEY_SIGMA, menu::ID_MainMenu),
OP2BYTES(KEY_INV, 0),
OP2BYTES(KEY_INV, command::ID_xroot),
OP2BYTES(KEY_SQRT, menu::ID_RealMenu),
OP2BYTES(KEY_LOG, function::ID_expm1),
OP2BYTES(KEY_LN, function::ID_log1p),