subtract¶
- subtract(x1: array | int | float | complex, x2: array | int | float | complex, /) array¶
Calculates the difference for each element
x1_iof the input arrayx1with the respective elementx2_iof the input arrayx2.- Parameters:
x1 (Union[array, int, float, complex]) – first input array. Should have a numeric data type.
x2 (Union[array, int, float, complex]) – second input array. Must be compatible with
x1(see Broadcasting). Should have a numeric data type.
- Returns:
out (array) – an array containing the element-wise differences. The returned array must have a data type determined by Type Promotion Rules.
Notes
At least one of
x1orx2must be an array.The result of
x1_i - x2_imust be the same asx1_i + (-x2_i)and must be governed by the same floating-point rules as addition (seeadd()).
Changed in version 2022.12: Added complex data type support.
Changed in version 2024.12: Added scalar argument support.