---
title: "determinant: WGSL and GLSL examples, uses and input limits"
description: "A determinant is the signed volume scale of a square linear transformation. A zero determinant means the transformation collapses a dimension."
url: https://typeshade.dev/reference/functions/determinant/
language: en
---

# `determinant`

Function

A determinant is the signed volume scale of a square linear transformation. A zero determinant means the transformation collapses a dimension.

## Compare examples

Compare expansion, reflection, and a collapsed axis. Their determinants have different magnitudes or signs.

**Example 1`M = diag(2, 3, 4, 1)`**

`2` `0` `0` `0` `0` `3` `0` `0` `0` `0` `4` `0` `0` `0` `0` `1`

Matrix displayed by rows. Constructor arguments run down each column.

**Result**

`determinant(M) = 24`

**Example 2`M = diag(-1, 1, 1, 1)`**

`-1` `0` `0` `0` `0` `1` `0` `0` `0` `0` `1` `0` `0` `0` `0` `1`

Matrix displayed by rows. Constructor arguments run down each column.

**Result**

`determinant(M) = -1`

**Example 3`M = diag(1, 0, 1, 1)`**

`1` `0` `0` `0` `0` `0` `0` `0` `0` `0` `1` `0` `0` `0` `0` `1`

Matrix displayed by rows. Constructor arguments run down each column.

**Result**

`determinant(M) = 0`

The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.

## When to use it

Use it to detect a singular transform or an orientation reversal.

## Inputs and limits

Only square matrices have a determinant. A value close to zero can make inversion numerically unstable.

For shader input rules and precision, consult [WGSL](https://www.w3.org/TR/WGSL/) and [GLSL ES 3.00](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf).

## Related functions

- [`transpose`](https://typeshade.dev/reference/functions/transpose/)
- [`mat4`](https://typeshade.dev/reference/functions/mat4/)

**WGSL**

`determinant(a)`

**GLSL ES 3.00**

`determinant(a)`

The signature, the sentence and any message are the compiler's own text at commit af54ddad5.

Returns the determinant of a `mat4` as an `f32`.

## Syntax

```ts
declare function determinant(m: mat2x2): number
declare function determinant(m: mat3x3): number
declare function determinant(m: mat4x4): number
```

A `number` in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.

`type f32 = number & { readonly [f32Tag]?: true }`

A `number` you write as a type is inferred from its uses, and `f32`, `i32` and `u32` fix a width; [the TypeScript constructs page](https://typeshade.dev/guide/language/from-typescript/) carries that row with the compiler's emit.

## Parameters

- `m` `mat2x2``mat3x3``mat4x4`

## Return value

`number`

## Targets

**WGSL**

`determinant(a)`

**GLSL ES 3.00**

`determinant(a)`

## Examples

- [`gallery/capsule-corp-namek-class/capsule-corp-namek-class.shade.ts`](https://typeshade.dev/guide/examples/capsule-corp-namek-class/)
- [`gallery/bit-bump/bit-bump.shade.ts`](https://typeshade.dev/guide/examples/bit-bump/)
- [`gallery/normal-matrix/normal-matrix.shade.ts`](https://typeshade.dev/guide/examples/normal-matrix/)

## See also

- [Functions](https://typeshade.dev/reference/functions/)
- [Builtin table](https://typeshade.dev/guide/language/builtins/#geometry)
