<!--
{
  "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/hypot(_:_:result:)-5d8pw",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4vDSPO5hypot__6resultyx_q_q0_ztAA0A6BufferRzAaFR_AA0a7MutableE0R0_Sf7ElementRtzSfAHRt_SfAHRt0_r1_lFZ"
  },
  "title" : "hypot(_:_:result:)"
}
-->

# hypot(_:_:result:)

Calculates the single-precision hypotenuses of right triangles with legs that are the lengths of corresponding elements of the two input vectors.

```
static func hypot<T, U, V>(_ x: T, _ y: U, result: inout V) where T : AccelerateBuffer, U : AccelerateBuffer, V : AccelerateMutableBuffer, T.Element == Float, U.Element == Float, V.Element == Float
```

## Parameters

`x`

An array that contains the lengths of the first set of legs of the triangles.

`y`

An array that contains the lengths of the second set of legs of the triangles.

`result`

An array that receives the result of the calculation.

## Discussion

This function calculates the square roots of the sum of the squares of corresponding elements of vectors `x` and `y`, using the following operation:

```objc
for (n = 0; n < N; ++n)
    C[n] = sqrt(x[n]*x[n] + y[n]*y[n]);
```

For example, the following code calculates the hypotenuse of four Pythagorean triples:

```swift
    let x: [Float] = [3, 6, 5, 9]
    let y: [Float] = [4, 8, 12, 12]
    
    let hypotenuses = [Float](
        unsafeUninitializedCapacity: x.count) {
            buffer, initializedCount in
            
            vDSP.hypot(x, y,
                       result: &buffer)
            
            initializedCount = x.count
        }
    
    // Prints "[5.0, 10.0, 13.0, 15.0]".
    print(hypotenuses)
```

## See Also

[`extern void vDSP_vdist(const float *__A, vDSP_Stride __IA, const float *__B, vDSP_Stride __IB, float *__C, vDSP_Stride __IC, vDSP_Length __N);`](/documentation/Accelerate/vDSP_vdist)

Calculates the single-precision hypotenuses of right triangles with legs that are the lengths of corresponding elements of two pairs of vectors.



---

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)