# quatinv

Calculate inverse of quaternion

## Syntax

``n = quatinv(q)``

## Description

````n = quatinv(q)` calculates the inverse, `n`, for a given quaternion, `q`. Aerospace Toolbox uses quaternions that are defined using the scalar-first convention. For more information on quaternion forms, see Algorithms.```

## Examples

collapse all

Determine the inverse of `q = [1 0 1 0]`:

`qinv = quatinv([1 0 1 0])`
```qinv = 0.5000 0 -0.5000 0```

## Input Arguments

collapse all

Quaternion, specified as an m-by-4 matrix containing m quaternions.

Data Types: `double`

## Output Arguments

collapse all

Inverse of quaternion, returned as an m-by-4 matrix.

## Algorithms

The quaternion has the form of

`$q={q}_{0}+i{q}_{1}+j{q}_{2}+k{q}_{3}.$`

The quaternion inverse has the form of

`${q}^{-1}=\frac{{q}_{0}-i{q}_{1}-j{q}_{2}-k{q}_{3}}{{q}_{0}^{2}+{q}_{1}^{2}+{q}_{2}^{2}+{q}_{3}^{2}}.$`

 Stevens, Brian L., Frank L. Lewis, Aircraft Control and Simulation, Wiley–Interscience, 2nd Edition.
{"ft_lang_label":"__label__en","ft_lang_prob":0.56871897,"math_prob":0.9996024,"size":1174,"snap":"2023-40-2023-50","text_gpt3_token_len":307,"char_repetition_ratio":0.15213676,"word_repetition_ratio":0.0,"special_character_ratio":0.2350937,"punctuation_ratio":0.1262136,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9993486,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-21T12:51:50Z\",\"WARC-Record-ID\":\"<urn:uuid:c76cf58a-a158-4a87-9c2e-9970c984702d>\",\"Content-Length\":\"83880\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9bb09d18-95ec-4832-ade4-9f599ed9942f>\",\"WARC-Concurrent-To\":\"<urn:uuid:f4b685e6-aac1-4764-802e-c03efc938e4f>\",\"WARC-IP-Address\":\"23.34.160.82\",\"WARC-Target-URI\":\"https://au.mathworks.com/help/aerotbx/ug/quatinv.html\",\"WARC-Payload-Digest\":\"sha1:F3ANGCLKWESXB3RLGOJBXJM53QZEYQY3\",\"WARC-Block-Digest\":\"sha1:OW4PEV3ROHKTLGCJWFSTHYL4722WC4LO\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233506027.39_warc_CC-MAIN-20230921105806-20230921135806-00184.warc.gz\"}"}