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

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

Returns the single-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>(x0: R, x1: S, y0: T, y1: U) -> [Float] where R : AccelerateBuffer, S : AccelerateBuffer, T : AccelerateBuffer, U : AccelerateBuffer, R.Element == Float, S.Element == Float, T.Element == Float, U.Element == Float
```

## 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.

## Discussion

This function returns 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((x0A[n]-x1[n])**2 + (y0[n]-y1[n])**2);
```

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

```swift
    let x0: [Float] = [3, 6, 5, 9]
    let x1: [Float] = [0, 0, 0, 0]
    
    let y0: [Float] = [0, 0, 0, 0]
    let y1: [Float] = [4, 8, 12, 12]
    
    let hypotenuses = vDSP.hypot(x0: x0, x1: x1,
                                 y0: y0, y1: y1)
    
    // 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)