Numpy – Math Operations

Summation

We can add value to our array element based.

We can add same shaped array to anothher array:

Substraction

We can substract value to our array element based.

We can substract same shaped array to another array:

Muliplication

We can multiply value to our array element based.

We can multiply same shaped array to another array:

Division

We can divide our array to any value element based.

We can divide same shaped array to another array which does not contain 0:

Powers/Roots

We can take power of any array:

or we can use method:

we can take square by using power ** operator or numpy method:

Math Functions

Exp

exp(x)= e^x

Takes nth power of euler constant

sum

We can sum any array row based, column based or array based.

cumsum

cumsum computes the cumulative sum of elements along a specified axis of an array

Other statisctical function in the statsic section.

Constans

There is already defined constants in Numpy:

  1. π (pi): np.pi
  2. e (Euler’s number): np.e
  3. NaN (Not a Number): np.nan
  4. Infinity: np.inf

Trigonometrical Functions

  1. np.sin(x): Computes the sine of the array x.
  2. np.cos(x): Computes the cosine of the array x.
  3. np.tan(x): Computes the tangent of the array x.
  4. np.arcsin(x): Computes the inverse sine (arcsin) of the array x.
  5. np.arccos(x): Computes the inverse cosine (arccos) of the array x.
  6. np.arctan(x): Computes the inverse tangent (arctan) of the array x.
  7. np.deg2rad(x): Converts angles from degrees to radians.
  8. np.rad2deg(x): Converts angles from radians to degrees.

Apply Custom Function

We can apply any custom function:

ibrahim tunc
ibrahim tunc
Articles: 13

Leave a Reply

Your email address will not be published. Required fields are marked *