# Introducing Complex Numbers Update

**URL:** <https://forums.swift.org/t/introducing-complex-numbers-update/24598>\
**Category:** Discussion\
**Created:** [May 16, 2019, 9:30pm UTC](https://forums.swift.org/t/introducing-complex-numbers-update/24598 "2019-05-16T21:30:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bartchr808](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bartchr808/32/7394_2.png) [@bartchr808](https://forums.swift.org/u/bartchr808)\
**Post date:** [May 16, 2019, 9:30pm UTC](https://forums.swift.org/t/introducing-complex-numbers-update/24598/1 "2019-05-16T21:30:00Z")

</div>

Hey @scanon ,

From what I understand, you were planning on implementing complex numbers at some point, and was wondering if you had any update on the progress.

The reason why I ask is that I'm planning on introducing complex number differentiation into the Swift for TensorFlow project. So I wanted to see if you have any prototype I can work from while you finalize it and introduce it through Swift Evolution.

---

<div class="post-metadata">

**Author:** ![Nevin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nevin/32/617_2.png) [@Nevin](https://forums.swift.org/u/Nevin)\
**Post date:** [May 16, 2019, 10:00pm UTC](https://forums.swift.org/t/introducing-complex-numbers-update/24598/2 "2019-05-16T22:00:35Z")

</div>

I can’t speak for Steve, but I’d expect a `Complex` type to be similar to that in @xwu’s [Numeric Annex](https://github.com/xwu/NumericAnnex).

• • •

However, I am not convinced that complex numbers necessarily belong in the standard library. If we ever create an official `Math` library, I might expect them there (alongside linear algebra and signal processing).

---

<div class="post-metadata">

**Author:** ![bartchr808](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bartchr808/32/7394_2.png) [@bartchr808](https://forums.swift.org/u/bartchr808)\
**Post date:** [May 16, 2019, 11:25pm UTC](https://forums.swift.org/t/introducing-complex-numbers-update/24598/3 "2019-05-16T23:25:15Z")

</div>

Thanks for pointing me to that library @Nevin!

I'm still pretty new to the community, so I haven't been following along what everyone has been saying until recently. However, I did notice that [SE-0246: Generic Math Functions](https://forums.swift.org/t/accepted-with-modifications-se-0246-generic-math-functions/22244) was accepted, which introduced the `Real` protocol as standard in Swift without name spacing it in `Math`. So it seems there could be a possibility of adding `Complex` type as part of the standard library.

However, for what I'll be doing (differentiating complex numbers), I don't have a strong opinion on where it will exist, and the decision about where it will exist can be made when it's brought up in Swift Evolution when/if complex numbers are added. So I think the topic of where it will belong can be discussed later in the future.

---

<div class="post-metadata">

**Author:** ![scanon](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/scanon/32/2445_2.png) [@scanon](https://forums.swift.org/u/scanon)\
**Post date:** [May 17, 2019, 12:14am UTC](https://forums.swift.org/t/introducing-complex-numbers-update/24598/4 "2019-05-17T00:14:36Z")

</div>

It's reasonable to expect that the complex type and basic arithmetic operations will go in the standard library eventually, because we want to be able to import C API that uses C's `_Complex` type. It's also reasonable to expect that more sophisticated complex API might end up in a separate library.

It's definitely a post-5.1 feature, though.

---

<div class="post-metadata">

**Author:** ![bartchr808](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bartchr808/32/7394_2.png) [@bartchr808](https://forums.swift.org/u/bartchr808)\
**Post date:** [May 17, 2019, 1:09am UTC](https://forums.swift.org/t/introducing-complex-numbers-update/24598/5 "2019-05-17T01:09:16Z")

</div>

> It's definitely a post-5.1 feature, though.

Okay that sounds good thanks for letting me know! While I investigate the capability of differentiating complex numbers, I'll work with @xwu's library then. But then if everything is successful on my end, I'll replace it with your implementation of complex numbers once it lands on master and thus can be merged downstream into the tensorflow branch.

---

<div class="post-metadata">

**Author:** ![Chris\_Lattner3](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/chris_lattner3/32/348_2.png) [@Chris\_Lattner3](https://forums.swift.org/u/Chris_Lattner3)\
**Post date:** [May 18, 2019, 7:54pm UTC](https://forums.swift.org/t/introducing-complex-numbers-update/24598/6 "2019-05-18T19:54:33Z")

</div>

> [@scanon](#):
>
> It's reasonable to expect that the complex type and basic arithmetic operations will go in the standard library eventually, because we want to be able to import C API that uses C's `_Complex` type. It's also reasonable to expect that more sophisticated complex API might end up in a separate library.

Yeah, I agree. This will likely go into the Swift stdlib directly, not in an add on package. The core team recently had a discussion with this and had a tentative agreement that "stuff in c99 libm" is in scope for the Swift standard library, and that includes C `_Complex`.

-Chris
