# 15. Complex Numbers

### Complex Type

`complex` types are used to work with complex numbers. Go has  Go two types of complex numbers, `complex64` and `complex128`

To create complex number, we use build in `complex` function.

### Declaring Complex Number

Complex numbers can be declared using any of the below way

{% code title="main.go" %}

```
var c1 complex128 = complex(2, 3)
var c2 complex64 = complex(3, 4)
var c1 = complex(2, 3)
c1 := complex(2, 3)
```

{% endcode %}

When type is not specified, complex number defaults to `complex128`

Since complex numbers must be created using `complex()` function, these do not have a corresponding zero value.

&#x20;Go provides two sizes of complex numbers, `complex64` and `complex128` . These are used to represent complex numbers.

### Declaring Complex Type

We need to use in-build `complex` function to create complex type.

{% code title="main.go" %}

```go
var x  = complex(2, 2)
var x complex128 = complex(2,2)
var y complex64 = complex(3,4)
```

{% endcode %}

If no type is specified, it defaults to `complex128`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.codewithgo.com/complex-numbers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
