<!--
{
  "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/linearInterpolate(_:_:using:result:)-55avl",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4vDSPO17linearInterpolate__5using6resultyx_q_Sfq0_ztAA0A6BufferRzAaGR_AA0a7MutableG0R0_Sf7ElementRtzSfAIRt_SfAIRt0_r1_lFZ"
  },
  "title" : "linearInterpolate(_:_:using:result:)"
}
-->

# linearInterpolate(_:_:using:result:)

Calculates the linear interpolation between the supplied single-precision vectors.

```
static func linearInterpolate<T, U, V>(_ vectorA: T, _ vectorB: U, using interpolationConstant: Float, result: inout V) where T : AccelerateBuffer, U : AccelerateBuffer, V : AccelerateMutableBuffer, T.Element == Float, U.Element == Float, V.Element == Float
```

## Discussion

Single-precision and double-precision [`linearInterpolate(_:_:using:result:)`](/documentation/Accelerate/vDSP/linearInterpolate(_:_:using:result:)-6o7a9) functions calculate a vector that’s the element-wise linear interpolation between the two supplied vectors.

For example, the following code creates two arrays, vectorA and vectorB, that contain sine waves:

```swift
let n = 1024

let vectorA: [Float] = (0 ... n).map {
    return 2 + sin(Float($0) * 0.07)
}

let vectorB: [Float] = (0 ... n).map {
    return -2 + sin(Float($0) * 0.03)
}
```

Use [`linearInterpolate(_:_:using:)`](/documentation/Accelerate/vDSP/linearInterpolate(_:_:using:)-71as1) with an interpolation constant of 0.5 to generate a new vector that’s the average of the two sine waves:

```swift
let result = vDSP.linearInterpolate(vectorA, vectorB,
                                    using: 0.5)
```

The following figure visualizes the two source vectors: the blue lines at the top and bottom, and the interpolation result: the red line in the center:

![Graphic illustrating two sine waves and a third vector that’s the linear interpolation between them.](images/com.apple.accelerate/media-3521338@2x.png)

---

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)