# Math Methods

Anonymous contributor

Anonymous contributor1 total contribution

Anonymous contributor

Published May 1, 2024

Contribute to Docs

In NumPy, **Math Methods** are used to perform mathematical operations on arrays. These methods encompass arithmetic operations, trigonometric functions, exponential and logarithmic functions, and more. They play a crucial role in scientific computing, data analysis, and machine learning, making NumPy indispensable across scientific research, engineering, finance, and data analysis domains.

## Syntax

The generic syntax for the NumPy math methods is as follows:

```
numpy.math_method()
```

## Example

import numpy as np# Perform element-wise addition of two arrays using numpy.add() methodresult = np.add([1, 2, 3], [10, 20, 30])print("Result of addition:", result)

Result of addition: [11 22 33]

## Basic Categories of Math Methods

### 1. Basic Arithmetic Operations

- Addition
`numpy.add()`

: Performs element-wise addition of arrays. - Subtraction
`numpy.subtract()`

: Performs element-wise subtraction of arrays. - Multiplication
`numpy.multiply()`

: Performs element-wise multiplication of arrays. - Division
`numpy.divide()`

: Performs element-wise division of arrays. - Power
`numpy.power()`

: Performs element-wise exponentiation of arrays.

### 2. Trigonometric Functions

- Sine
`numpy.sin()`

: Computes the sine of each element in the array. - Cosine
`numpy.cos()`

: Computes the cosine of each element in the array. - Tangent
`numpy.tan()`

: Computes the tangent of each element in the array. - Inverse Sine
`numpy.arcsin()`

: Computes the inverse sine of each element in the array. - Inverse Cosine
`numpy.arccos()`

: Computes the inverse cosine of each element in the array. - Inverse Tangent
`numpy.arctan()`

: Computes the inverse tangent of each element in the array.

### 3. Exponential and Logarithmic Functions

- Exponential
`numpy.exp()`

: Computes the exponential of each element in the array. - Natural Logarithm
`numpy.log()`

: Computes the natural logarithm of each element in the array. - Base-10 Logarithm
`numpy.log10()`

: Computes the base-10 logarithm of each element in the array.

### 4. Miscellaneous Functions

- Absolute Value
`numpy.absolute()`

: Computes the absolute value of each element in the array. - Square Root
`numpy.sqrt()`

: Computes the non-negative square root of each element in the array. - Ceiling
`numpy.ceil()`

: Rounds each element of the array to the nearest integer greater than or equal to that element. - Floor
`numpy.floor()`

: Rounds each element of the array to the nearest integer less than or equal to that element. - Rounding
`numpy.round()`

: Rounds each element of the array to the nearest integer.

## Math Methods

- .abs()
- Calculates the absolute value of a given number or each element in an array.
- .arccos()
- Calculates the inverse cosine of each element in an array or a single value.
- .arcsin()
- Calculates the inverse sine of each element in an array.
- .cos()
- Computes the cosine of each element in an array or a single value.
- .degrees()
- Converts angles expressed in radians into degrees.
- .exp()
- Computes the exponential of all elements in the input array.
- .log()
- Calculates the natural logarithm of each element in an array.
- .log10()
- Calculates the base-10 logarithm of each element in an array.
- .power()
- Raises each element in the first array to the power of the corresponding element in the second array.
- .round()
- Rounds a number or an array of numbers to a specified number of decimal places.
- .sin()
- Calculates the trigonometric sine of each element in an array.
- .sqrt()
- Calculates the square root of each element in an array.
- .tan()
- Calculates the tangent of each element in an array or a single value in radians.

## All contributors

- Anonymous contributorAnonymous contributor1 total contribution

- Anonymous contributor

### Looking to contribute?

- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.