Questions tagged [complex-numbers]

This challenge involves the manipulation of complex numbers, including parsing and printing them as well as performing complex arithmetic. This tag also encompasses generalised complex numbers like quaternions.

28 questions
3k views

The qvolume of an integer

It is ancient knowledge that every non-negative integer can be rewritten as the sum of four squared integers. For example the number 1 can be expressed as $0^2+0^2+0^2+1^2$. Or, in general, for any ...
2k views

Quaternion square root

Background Quaternion is a number system that extends complex numbers. A quaternion has the following form $$a + bi + cj + dk$$ where $a,b,c,d$ are real numbers and $i,j,k$ are three ...
3k views

Hermitian matrix?

Note that this challenge requires no handling or understanding of complex numbers. Given a non-empty square matrix where every element is a two-element (Re,Im) integer list, determine (giving any ...
1k views

Exponent of complex numbers

Given two integers, which may be negative, zero, or positive, a and b (taken in any reasonable format, including inputting a ...
447 views

Factorize a Gaussian integer

A Gaussian integer is a complex number whose real and imaginary parts are integers. Gaussian integers, like ordinary integers, can be represented as a product of Gaussian primes, in a unique manner. ...
905 views

Compute a complex power

The Rundown Given any input x and y, perform a complex operation, and print a corresponding result. How your program should work Given an input x and y in the form z = x+yi, find zi-z If the ...
5k views

Draw a graph of $y=(-n)^x$

Challenge Given an input of an integer, $n$ (where $0<n<50$), output the graph of $y=\mathrm{Re}((-n)^x)$ from $x = -3$ to $x = 3$ inclusive. Where $\mathrm{Re}(p)$ is the real ...
185 views

Imaginary Parts of Non-Trivial Riemann Zeroes

Introduction According to the Riemann Hypothesis, all zeroes of the Riemann zeta function are either negative even integers (called trivial zeroes) or complex numbers of the form ...
3k views

Complex Binary Numbers

Let's create a simple, surjective mapping from positive integers to Gaussian integers, which are complex numbers where the real and imaginary parts are integers. Given a positive integer, for example ...
254 views

Gauss to Eisenstein

Given a Gaussian integer A+B*i where A,B are integers and i = exp(2*pi*i/4) is the imaginary ...
413 views

Counting Eisenstein primes

Introduction Eisenstein integers are complex numbers of the form a+bω Where a,b are integers, and ...
2k views

Parse a Quaternion

If you don't know already, a quaternion is basically a 4-part number. For the purposes of this challenge, it has a real component and three imaginary components. The imaginary components are ...
4k views

Gaussian integers are complex numbers of the form a+bi where a and b are both integers. In ...
1k views

Evaluate the Riemann Zeta Function at a Complex Number

Introduction I found this question that was closed because it was unclear, yet it was a nice idea. I'll do my best to make this into a clear challenge. The Riemann Zeta function is a special ...
384 views

Primitive Roots of Unity

Let z be a complex number. z is an nth primitive root of unity if for a certain positive integer ...
483 views

Output quater-imaginary base numbers in binary

Write a function or program that outputs Quater-imaginary base displayed as binary digits. The number base is 2i, where i is the square root of -1. See Complex Number for more details on i. Each digit ...
358 views

The split-complex numbers, also known as "perplex numbers" are similar to the complex numbers. Instead of i^2 = -1, however, we have ...
909 views

What's the voltage over each component?

The picture below shows a RLC circuit. A RLC circuit is an electrical circuit consisting of a resistor (R), an inductor (L), and a capacitor (C), connected in series or in parallel. (1) In order to ...
451 views

Multiply Pauli Matrices

The Pauli matrices are a set of 2x2 matrices which appear very commonly in quantum physics (no, you don't need to know any quantum physics for this challenge). If we include the identity in the set, ...
1k views

Solve a 2x2 Eigensystem

For those with a little linear algebra background, the challenge is as simple as this: determine the eigenvalues and eigenvectors of a given complex 2x2 matrix. You may skip ahead to The Challenge for ...
1k views

Wait, but what's e^N?

Objective: The objective is to calculate e^N for some real or imaginary N (e.g. 2, -3i, 0.7, 2.5i, but not 3+2i). This is code golf, so, shortest code (in bytes) wins. So, for example: N = 3, e^N =...
5k views

Find i^n, given n

The Challenge In as few characters as possible, find the value of i^n, given n, a positive integer greater than 0. This should be outputted as a String. For those that don't know, i is defined such ...
1k views

Multiply Quaternions

Write a named function or program that computes the quaternion product of two quaternions. Use as few bytes as possible. Quaternions Quaternions are an extension of the real numbers that further ...
1k views

is_gaussian_prime(z)?

Task Write a function that accepts two integers a,b that represent the Gaussian integer z = a+ib (complex number). The program ...
3k views

Too Fast, Too Fourier: FFT Code Golf

Implement the Fast Fourier Transform in the fewest possible characters. Rules: Shortest solution wins It can be assumed that the input is a 1D array whose length is a power of two. You may use the ...
481 views

Perform basic operations on complex numbers in a language without native support for complex numbers

Your code has to provide the following functions: read(x) Reads a complex number from the standard input. It has to accept and evaluate something in the form ...