<!--
{
  "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(x0:x1:y0:y1:result:)-4pizr",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4vDSPO5hypot2x02x12y02y16resultyx_q_q0_q1_q2_ztAA0A6BufferRzAaJR_AaJR0_AaJR1_AA0a7MutableI0R2_Sd7ElementRtzSdALRt_SdALRt0_SdALRt1_SdALRt2_r3_lFZ"
  },
  "title" : "hypot(x0:x1:y0:y1:result:)"
}
-->

# hypot(x0:x1:y0:y1:result:)

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

```
static func hypot<R, S, T, U, V>(x0: R, x1: S, y0: T, y1: U, result: inout V) where R : AccelerateBuffer, S : AccelerateBuffer, T : AccelerateBuffer, U : AccelerateBuffer, V : AccelerateMutableBuffer, R.Element == Double, S.Element == Double, T.Element == Double, U.Element == Double, V.Element == Double
```

## Parameters

`x0`

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

`x1`

An array that contains the second values of the first set of legs of the triangles.

`y0`

An array that contains the first values of the second set of legs of the triangles.

`y1`

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

`result`

An array that receives the result of the calculation.

## Discussion

This function calculates the length of the hypotenuse of *n* number of triangles, where *n* is the number of elements in the supplied vectors. The differences between corresponding elements of vectors `x0` and `x1` and vectors `y0` and `y1` define the lengths of the two legs of each triangle.

The functions use the following operation:

```swift
for (n = 0; n < N; ++n)
    E[n] = sqrt((x0[n]-x1[n])**2 + (y0[n]-y1[n])**2);
```

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

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

## See Also

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

Calculates the single-precision hypotenuses of right triangles with legs that are the differences 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)