# Wrong output from det(Array{Complex})

**URL:** https://discourse.julialang.org/t/wrong-output-from-det-array-complex/10022
**Category:** General Usage
**Tags:** linearalgebra
**Created:** [March 27, 2018, 10:18pm UTC](https://discourse.julialang.org/t/wrong-output-from-det-array-complex/10022 "2018-03-27T22:18:20Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)
#### Post date: [March 27, 2018, 11:33pm UTC](https://discourse.julialang.org/t/wrong-output-from-det-array-complex/10022/2 "2018-03-27T23:33:26Z")

</div>

Note that `Complex32` stores its real and imaginary components as `Float16`s (so that the total size of a `Complex32` is 32 bytes). `Float16` is a _really_ small floating point type, so large errors can be expected. For `Complex128`, the determinant is `-4.654054919228656e-11 + 4.618527782440645e-12im`, which isn’t too bad. Floating point math is just different from math with real numbers, so you may have to lower your expectations a bit when using them. See also this excellent post: [PSA: floating-point arithmetic - #5 by Tamas\_Papp](https://discourse.julialang.org/t/psa-floating-point-arithmetic/8678/5).

If you really need a lot of precision (at the cost of performance), you could use `Complex{BigFloat}`. If you want to go that route, note that something like `26.0-52.0im` constructs a `Complex{Float64}`, and if the number you want isn’t exactly representable as a `Complex{Float64}`, you’ll lose precision already before converting to `BigFloat`. Alternatively, in your specific case, the real and imaginary parts are integers, so if you replace e.g. `26.0-52.0im` with `26-52im` and construct an `Array{BigFloat}`, you won’t lose precision.

See also: [Accuracy of Computing Determinants - #3 by andreasnoack](https://discourse.julialang.org/t/accuracy-of-computing-determinants/6782/3).

---

_[View the full topic](https://discourse.julialang.org/t/wrong-output-from-det-array-complex/10022)._
