divide

divide(x1, x2, out=None, **kwargs)

Returns a true division of the inputs, element-wise.

Parameters:
x1 : ndarray or scalar

Dividend array.

x2 : ndarray or scalar

Divisor array.

out : ndarray

A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.

Returns:
out : ndarray or scalar

This is a scalar if both x1 and x2 are scalars.

Notes

This operator now supports automatic type promotion. The resulting type will be determined according to the following rules:

  • If both inputs are of floating number types, the output is the more precise type.
  • If only one of the inputs is floating number type, the result is that type.
  • If both inputs are of integer types (including boolean), the output is of float32 type.

Examples

>>> np.true_divide(x, 4)
array([0.  , 0.25, 0.5 , 0.75, 1.  ])