---
title: "hypot(_:_:result:)"
framework: accelerate
role: symbol
role_heading: Type Method
path: "accelerate/vdsp/hypot(_:_:result:)-1z10j"
---

# hypot(_:_:result:)

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

## Declaration

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

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

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: 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:     let x: [Double] = [3, 6, 5, 9]     let y: [Double] = [4, 8, 12, 12]          let hypotenuses = [Double](         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

### Related Documentation

- [vDSP_vdist](accelerate/vdsp_vdist.md)

### Type Methods

- [absolute(_:)](accelerate/vdsp/absolute(_:)-9c3ge.md)
- [absolute(_:)](accelerate/vdsp/absolute(_:)-5ehc1.md)
- [absolute(_:result:)](accelerate/vdsp/absolute(_:result:)-9x5jn.md)
- [absolute(_:result:)](accelerate/vdsp/absolute(_:result:)-1wu9x.md)
- [absolute(_:result:)](accelerate/vdsp/absolute(_:result:)-657bd.md)
- [absolute(_:result:)](accelerate/vdsp/absolute(_:result:)-4pigo.md)
- [add(_:_:)](accelerate/vdsp/add(_:_:)-9mv1a.md)
- [add(_:_:)](accelerate/vdsp/add(_:_:)-2ftxc.md)
- [add(_:_:)](accelerate/vdsp/add(_:_:)-53nh9.md)
- [add(_:_:)](accelerate/vdsp/add(_:_:)-7swvf.md)
- [add(_:_:result:)](accelerate/vdsp/add(_:_:result:)-2531u.md)
- [add(_:_:result:)](accelerate/vdsp/add(_:_:result:)-2w0o9.md)
- [add(_:_:result:)](accelerate/vdsp/add(_:_:result:)-338hl.md)
- [add(_:_:result:)](accelerate/vdsp/add(_:_:result:)-3vzwi.md)
- [add(_:to:count:result:)](accelerate/vdsp/add(_:to:count:result:)-g1dk.md)
