<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vDSP/multiply(addition:subtraction:)-6h89l",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4vDSPO8multiply8addition11subtractionSaySfGx1a_q_1bt_q0_1c_q1_1dttAA0A6BufferRzAaLR_AaLR0_AaLR1_Sf7ElementRtzSfAMRt_SfAMRt0_SfAMRt1_r2_lFZ"
  },
  "title" : "multiply(addition:subtraction:)"
}
-->

# multiply(addition:subtraction:)

Returns the single-precision element-wise product of the sum of two vectors and the difference of two vectors.

```
static func multiply<R, S, T, U>(addition: (a: R, b: S), subtraction: (c: T, d: U)) -> [Float] where R : AccelerateBuffer, S : AccelerateBuffer, T : AccelerateBuffer, U : AccelerateBuffer, R.Element == Float, S.Element == Float, T.Element == Float, U.Element == Float
```

## Parameters

`addition`

A tuple that contains the vectors `A` and `B` in `E = (A + B) * (C - D)`.

`subtraction`

A tuple that contains the vectors `C` and `D` in `E = (A + B) * (C - D)`.

## Return Value

The output vector `E` in `E = (A + B) * (C - D)`.

## Discussion

This function calculates the products of the first `N` elements of the addition of vectors `A` and `B` and the subtraction of vectors `C` and `D`.

```swift
 for (n = 0; n < N; ++n)
    E[n] = (B[n]+A[n]) * (C[n]-D[n]); 
```

![A diagram showing the operation of this function. There are four rows. The top row represents the input vectors, A, B, C, and D, with three boxes of each. The second row represents the operations that add vectors A and B, and subtract vectors C and D, with three boxes of each. The third row represents the multiplication operation as three boxes.  The bottom row represents the output vector E as three boxes. The diagram has connecting lines from the input vectors to the operations, and from the operations to the output vectors. ](images/com.apple.accelerate/media-4337126@2x.png)

The following code shows an example of using this function:

```swift
    let a: [Float] = [ 1,  2,  3,  4,  5]
    let b: [Float] = [10, 20, 30, 40, 50]
    let c: [Float] = [ 5,  4,  3,  2,  1]
    let d: [Float] = [50, 40, 30, 20, 10]
    
    
    let e = vDSP.multiply(addition: (a, b),
                          subtraction: (c, d))
    
    // Prints "[-495.0, -792.0, -891.0, -792.0, -495.0]".
    print(e)
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)