<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vDSP_vpythgD",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@F@vDSP_vpythgD"
  },
  "title" : "vDSP_vpythgD"
}
-->

# vDSP_vpythgD

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

```
extern void vDSP_vpythgD(const double *__A, vDSP_Stride __IA, const double *__B, vDSP_Stride __IB, const double *__C, vDSP_Stride __IC, const double *__D, vDSP_Stride __ID, double *__E, vDSP_Stride __IE, vDSP_Length __N);
```

## Parameters

`__A`

A vector that contains the first values of the first set of legs of the triangles.

`__IA`

The distance between the elements in the input vector `A`.

`__B`

A vector that contains the second values of the first set of legs of the triangles.

`__IB`

The distance between the elements in the input vector `B`.

`__C`

A vector that contains the first values of the second set of legs of the triangles.

`__IC`

The distance between the elements in the input vector `C`.

`__D`

A vector that contains the second values of the second set of legs of the triangles.

`__ID`

The distance between the elements in the input vector `D`.

`__E`

A vector that receives the result of the calculation.

`__IE`

The distance between the elements in the output vector `E`.

`__N`

The number of elements to process.

## 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((A[n]-B[n])**2 + (C[n]-D[n])**2);
```

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

```swift
    let stride = 1
    
    let a: [Double] = [3, 6, 5, 9]
    let b: [Double] = [0, 0, 0, 0]
    
    let c: [Double] = [0, 0, 0, 0]
    let d: [Double] = [4, 8, 12, 12]
    
    let hypotenuses = [Double](
        unsafeUninitializedCapacity: a.count) {
            buffer, initializedCount in
            
            vDSP_vpythgD(
                a, stride,
                b, stride,
                c, stride,
                d, stride,
                buffer.baseAddress!, stride,
                vDSP_Length(a.count)
            )
            
            initializedCount = a.count
        }
    
    // Prints "[5.0, 10.0, 13.0, 15.0]".
    print(hypotenuses)
```

---

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)