# 06.算数函数
[toc]{type: "ol", level: [3,4,5]}
### 创建数组
```python
import numpy as numpy
a = numpy.arange(1, 13).reshape(3,4)
b = numpy.arange(2, 14).reshape(3, 4)
```
### 加 add()
```python
a + b
```
::: details result
array([[ 3, 5, 7, 9],
[11, 13, 15, 17],
[19, 21, 23, 25]])
:::
### 减 substract()
```python
a - b
```
::: details result
array([[-1, -1, -1, -1],
[-1, -1, -1, -1],
[-1, -1, -1, -1]])
:::
### 乘 multiply()
#### 数组相乘
```python
a * b
```
::: details result
array([[ 2, 6, 12, 20],
[ 30, 42, 56, 72],
[ 90, 110, 132, 156]])
:::
#### 数组与参数相乘
```python
numpy.multiply(a, 12, out=b)
```
::: details result
array([[ 12, 24, 36, 48],
[ 60, 72, 84, 96],
[108, 120, 132, 144]])
:::
### 除 divide()
```python
a / b
```
::: details result
array([[0.5 , 0.66666667, 0.75 , 0.8 ],
[0.83333333, 0.85714286, 0.875 , 0.88888889],
[0.9 , 0.90909091, 0.91666667, 0.92307692]])
:::
### 少对多
```python
c = numpy.arange(4)
a + c
```
::: details result
array([[ 1, 3, 5, 7],
[ 5, 7, 9, 11],
[ 9, 11, 13, 15]])
:::
### 取整
#### 四舍五入
```python
numpy.around(12.5)
numpy.around(12.51)
```
::: details result
12.0
13.0
:::
#### 向上取整
```python
numpy.ceil(12.24)
```
::: details result
13.0
:::
#### 向下取整
```python
numpy.floor(12.68)
```
::: details result
12.0
:::