Ket API#

Types#

quant([size, dirty, qubits])

Create list of qubits

future(value)

64-bits integer on the quantum computer

dump(qubits)

Create a snapshot with the current quantum state of qubits

class quant(size: int = 1, dirty: bool = False, *, qubits: Optional[list[ket.clib.libket.qubit]] = None)#

Create list of qubits

Allocate size qubits in the state \(\left|0\right>\).

If dirty is True, allocate size qubits in an unknown state.

Warning

Using dirty qubits may have side effects due to previous entanglements.

Qubits allocated using the with statement must be free at the end of the scope.

Example:

a = H(quant())
b = X(quant())
with quant() as aux:
    with around(H, aux):
        with control(aux):
            swap(a, b)
    result = measure(aux)
    if result == 1:
        X(aux)
    aux.free()
Qubit Indexing:

Use brackets to index qubits as in a list and use + to concatenate two quant.

Example:

q = quant(20)
head, tail = q[0], q[1:]
init, last = q[:-1], q[-1]
even = q[::2]
odd = q[1::2]
reverse = reversed(q) # invert qubits order

a, b = quant(2) # |a⟩, |b⟩
c = a+b         # |c⟩ = |a⟩|b⟩
Parameters:
  • size – The number of qubits to allocate.

  • dirty – If True, allocate size qubits at an unknown state.

  • qubits – Initialize the qubit list without allocating. Intended for internal use.

at(index: list[int]) quant#

Return qubits at index

Create a new quant with the qubit references at the position defined by the index list.

Example:

q = quant(20)
odd = q.at(range(1, len(q), 2)) # = q[1::2]
Parameters:

index – List of indexes.

free(dirty: bool = False)#

Free the qubits

All qubits must be at the state \(\left|0\right>\) before the call, otherwise set the dirty param to True.

Warning

No check is applied to see if the qubits are at state \(\left|0\right>\).

Parameters:

dirty – Set True to free dirty qubits.

is_free() bool#

Return True when all qubits are free

class future(value: int | ket.clib.libket.libket_future)#

64-bits integer on the quantum computer

Store a reference to a 64-bits integer available in the quantum computer.

The integer value are available to the classical computer only after the quantum execution.

The following binary operations are available between future variables and int:

==, !=, <, <=, >, >=, +, -, *, /, <<, >>, and, xor, and or.

A new future variable is created with a (1) quantum measure; (2) binary operation with a future; or (3) directly initialization with a int.

q = H(quant(2))
a = measure(q) # 1
b = a*3        # 2
c = qc_int(42) # 3

Writing to the attribute value of a future variable passes the information to the quantum computer. Reading the attribute value triggers the quantum execution.

If the test expression of an if-then-else or while is type future, Ket passes the statement to the quantum computer.

Example:

q = quant(2)
with quant() as aux:
    # Create variable done on the quantum computer
    done = qc_int(False)
    while done != True:
        H(q)
        ctrl(q, X, aux)
        res = measure(aux)
        if res == 0:
            # Update variable done on the quantum computer
            done.value = True
        else:
            X(q+aux)
    aux.free()
# Get the measurement from the quantum computer
# triggering the quantum execution
result = measure(q).value
class dump(qubits: quant)#

Create a snapshot with the current quantum state of qubits

Gathering any information from a dump triggers the quantum execution.

Example:

a, b = quant(2)
with around(cnot(H, I), a, b):
    Y(a)
    inside = dump(a+b)
outside = dump(a+b)

print('inside:')
print(inside.show())
# inside:
# |01⟩    (50.00%)
#          -0.707107i     ≅     -i/√2
# |10⟩    (50.00%)
#           0.707107i     ≅      i/√2
print('outside:')
print(outside.show())
# outside:
# |11⟩    (100.00%)
#          -1.000000i     ≅     -i/√1
Parameters:

qubits – Qubits to dump.

get_quantum_state() dict[int, complex]#

Get the quantum state

This function returns a dict that maps base states to probability amplitude.

Note

Don’t use this function if your goal is just to iterate over the basis states. Use the attributes states, amplitudes, and probability instead.

Example:

q = quant(2)
cnot(H(q[0]), q[1])
print(dump(q).get_quantum_state())
# {3: (0.7071067811865476+0j), 0: (0.7071067811865476+0j)}
property states: list[int]#

List of basis states

property amplitudes: list[complex]#

List of probability amplitudes

property probability: list[float]#

List of measurement probability

show(format: Optional[str] = None) str#

Return the quantum state as a string

Use the format starting to change the print format of the basis states:

  • i: print the state in the decimal base

  • b: print the state in the binary base (default)

  • i|b<n>: separate the n first qubits, the remaining print in the binary base

  • i|b<n1>:i|b<n2>[:i|b<n3>...]: separate the n1, n2, n3, ... first qubits

Example:

q = quant(19)
X(ctrl(H(q[0]), X, q[1:])[1::2])
d = dump(q)

print(d.show('i'))
# |87381⟩ (50.00%)
#  0.707107               ≅      1/√2
# |436906⟩        (50.00%)
#  0.707107               ≅      1/√2
print(d.show('b'))
# |0010101010101010101⟩   (50.00%)
#  0.707107               ≅      1/√2
# |1101010101010101010⟩   (50.00%)
#  0.707107               ≅      1/√2
print(d.show('i4'))
# |2⟩|101010101010101⟩    (50.00%)
#  0.707107               ≅      1/√2
# |13⟩|010101010101010⟩   (50.00%)
#  0.707107               ≅      1/√2
print(d.show('b5:i4'))
# |00101⟩|5⟩|0101010101⟩  (50.00%)
#  0.707107               ≅      1/√2
# |11010⟩|10⟩|1010101010⟩ (50.00%)
#  0.707107               ≅      1/√2
Parameters:

format – Format string that matches (i|b)\d*(:(i|b)\d+)*.

property expected_values: tuple[float, float, float]#

X, Y, and Z expected values for one qubit

sphere()#

Result a Bloch sphere

QuTiP and Matplotlib are required for generating and plotting the sphere.

Quantum Gates#

Single Qubit Gates#

Gate

Function

Matrix

Effect

Identity

I(q)

\(\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\)

\(\begin{matrix} I\left|0\right> = & \left|0\right> \\ I\left|1\right> = & \left|1\right> \end{matrix}\)

Pauli-X

X(q)

\(\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\)

\(\begin{matrix} X\left|0\right> = & \left|1\right> \\ X\left|1\right> = & \left|0\right> \end{matrix}\)

Pauli-Y

Y(q)

\(\begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}\)

\(\begin{matrix} Y\left|0\right> = & i\left|1\right> \\ Y\left|1\right> =& -i\left|0\right> \end{matrix}\)

Pauli-Z

Z(q)

\(\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\)

\(\begin{matrix} Z\left|0\right> = & \left|0\right> \\ Z\left|1\right> = & -\left|1\right> \end{matrix}\)

Hadamard

H(q)

\(\frac{1}{\sqrt{2}}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}\)

\(\begin{matrix} H\left|0\right> = & \frac{\left|0\right>+\left|1\right>}{\sqrt{2}} = & \left|+\right> \\ H\left|1\right> = & \frac{\left|0\right>-\left|1\right>}{\sqrt{2}} = & \left|-\right> \\ H\left|+\right> = & \left|0\right> \\ H\left|-\right> = & \left|1\right> \\ \end{matrix}\)

S

S(q)

\(\begin{bmatrix} 1 & 0 \\ 0 & i \end{bmatrix}\)

\(\begin{matrix} S\left|0\right> = & \left|0\right> \\ S\left|1\right> = & i\left|1\right> \end{matrix}\)

S Dagger

SD(q)

\(\begin{bmatrix} 1 & 0 \\ 0 & -i \end{bmatrix}\)

\(\begin{matrix} S^\dagger\left|0\right> = & \left|0\right> \\ S^\dagger\left|1\right> = & -i\left|1\right> \end{matrix}\)

T

T(q)

\(\begin{bmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{bmatrix}\)

\(\begin{matrix} T^\dagger\left|0\right> = & \left|0\right> \\ T^\dagger\left|1\right> = & \frac{1+i}{\sqrt{2}}\left|1\right> \end{matrix}\)

T Dagger

TD(q)

\(\begin{bmatrix} 1 & 0 \\ 0 & e^{-i\pi/4} \end{bmatrix}\)

\(\begin{matrix} T^\dagger\left|0\right> = & \left|0\right> \\ T^\dagger\left|1\right> = & \frac{1-i}{\sqrt{2}}\left|1\right> \end{matrix}\)

Phase

phase(λ, q)

\(\begin{bmatrix} 1 & 0 \\ 0 & e^{i\lambda} \end{bmatrix}\)

\(\begin{matrix} P\left|0\right> = & \left|0\right> \\ P\left|1\right> =& e^{i\lambda}\left|1\right> \end{matrix}\)

X-axis Rotation

RX(θ, q)

\(\begin{bmatrix} \cos{\frac{\theta}{2}} & -i\sin{\frac{\theta}{2}} \\ -i\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} \end{bmatrix}\)

\(\begin{matrix} RX\left|0\right> = & \cos\frac{\theta}{2}\left|0\right> -i\sin\frac{\theta}{2}\left|1\right> \\ RX\left|1\right> =& -i\sin\frac{\theta}{2}\left|0\right> + \cos\frac{\theta}{2}\left|1\right> \end{matrix}\)

Y-axis Rotation

RY(θ, q)

\(\begin{bmatrix} \cos{\frac{\theta}{2}} & -\sin{\frac{\theta}{2}} \\ \sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} \end{bmatrix}\)

\(\begin{matrix} RY\left|0\right> = & \cos{\theta\over2}\left|0\right> + \sin\frac{\theta}{2}\left|1\right> \\ RY\left|1\right> =& -\sin\frac{\theta}{2}\left|0\right> + \cos\frac{\theta}{2}\left|1\right> \end{matrix}\)

Z-axis Rotation

RZ(θ, q)

\(\begin{bmatrix} e^{-i\theta/2} & 0 \\ 0 & e^{i\theta/2} \end{bmatrix}\)

\(\begin{matrix} RZ\left|0\right> = & e^{-i\theta/2}\left|0\right> \\ RZ\left|1\right> =& e^{i\theta/2}\left|1\right> \end{matrix}\)

Multiple Qubit Gates#

Gate

Function

Matrix

Controlled-NOT

cnot(c, t)

\(\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix}\)

SWAP

swap(a, b)

\(\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}\)

XX-axis Rotation

RXX(θ, a, b)

\(\begin{bmatrix} \cos\frac{\theta}{2} & 0 & 0 & -i\sin\frac{\theta}{2} \\ 0 & \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} & 0 \\ 0 & -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} & 0 \\ -i\sin\frac{\theta}{2} & 0 & 0 & \cos\frac{\theta}{2} \end{bmatrix}\)

YY-axis Rotation

RYY(θ, a, b)

\(\begin{bmatrix} \cos\frac{\theta}{2} & 0 & 0 & i\sin\frac{\theta}{2} \\ 0 & \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} & 0 \\ 0 & -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} & 0 \\ i\sin\frac{\theta}{2} & 0 & 0 & \cos\frac{\theta}{2} \end{bmatrix}\)

ZZ-axis Rotation

RZZ(θ, a, b)

\(\begin{bmatrix} e^{-i \frac{\theta}{2}} & 0 & 0 & 0 \\ 0 & e^{i \frac{\theta}{2}} & 0 & 0 \\ 0 & 0 & e^{i \frac{\theta}{2}} & 0 \\ 0 & 0 & 0 & e^{-i \frac{\theta}{2}} \end{bmatrix}\)

Flip to Control State

flipc(state, q)

\(\bigotimes_{\text{bit }\in\text{ state}}\begin{cases}X,&\text{for bit }=0\\I,&\text{for bit }=1\end{cases}\)

Phase on State

phase_on(state, q)

\(\sum\delta_k\left|k\right>\left<k\right|,\text{where }\delta_k=\begin{cases}-1,&\text{for }k= \text{state}\\1,&\text{for }k\neq\text{state}\end{cases}\)

Standard Operations#

ctrl(control, func, *args[, on_state, ...])

Add controll-qubits to a Callable

control(*ctr[, on_state])

Open a controlled-scope

adj(func, *args[, later_call])

Inverse of a Callable

inverse()

Open a inverse scope

around(func, *args, **kwargs)

Apply operation U around V and V inverse

measure(q[, free])

Quantum measurement

qc_int(value)

Instantiate an integer on the quantum computer

class inverse#

Open a inverse scope

Inside a with inverse scope, the the quantum operations backwards.

Usage:

with inverse():
    ...
class control(*ctr: quant, on_state: Optional[Union[int, list[int]]] = None)#

Open a controlled-scope

Inside a with control scope, the qubits of ctr control every quantum operation, only execution if all qubits are in the estate \(\left|1\right>\).

Optionally, you can change the state when applying the quantum operation with the Keyword Argument on_state. If on_state is an int, the number of qubits needs to be equal to or greater than the bit length of on_state. Else if on_sate is a List[int], its length needs to be equal to the number of qubits.

For example, execute when the qubits are in the state \(\left|\left[\dots0\right]11\right>\), use with control(ctr, on_state=3): or with control(ctr, on_state=[0, 1, 1]): if ctr has exactly 3 qubits.

Usage:

with control(*ctr[, on_state]):
    ...
Example:

c = quant(2)
a, b = quant(2)

# CNOT c[0] a
with control(c[0]):
    X(a)

# Toffoli c[0] c[1] a
with control(c):
    X(a)

# CSWAP c[0] a b
with control(c[0]):
    swap(a, b)
Parameters:
  • ctr – Control qubits.

  • on_state – Change the control state.

ctrl(control: ket.base.quant | list[ket.base.quant] | slice | int | list[int], func: Union[Callable, list[Callable]], *args, on_state: Optional[Union[int, list[int]]] = None, later_call: bool = False, **kwargs) Union[Callable, Any]#

Add controll-qubits to a Callable

Call with control qubits:

  • control type must be quant or [quant]

  • func type must be Callable or [Callable]

ret1 = ctrl(control_qubits, func, *args, **kwargs)
# Equivalent to:
# with control(control_qubits):
#     ret1 = func(*args, **kwargs)

ret2 = ctrl([q0, q1, q2, ...], func, *args, **kwargs)
# Equivalent to:
# with control(*control):
#     ret2 = func(*args, **kwargs)

ret3 = ctrl(control_qubits, [f0, f1, f2, ...], *args, **kwargs)
# Equivalent to:
# ret3 = []
# with control(control_qubits):
#     for f in func:
#         ret3.append(f(*args, **kwargs))
Create controlled-operation:

1. If the keyword argument later_call is True, return a Callable[[], Any]:

ctrl_func = ctrl(control_qubits, func, *args, **kwargs, later_call=True)
# Equivalent to:
# ctrl_func = lambda : ctrl(control_qubits, func, *args, **kwargs)

Example:

def increment(q):
    if len(q) > 1:
        ctrl(q[-1], increment, q[:-1])
    X(q[-1])

size = ceil(log2(len(inputs)))+1
with quant(size) as inc:
    with around(ctrl(q , increment, inc, later_call=True) for q in inputs):
        with control(inc, on_state=len(inputs)//2):
            X(output)
    inc.free()

2. If control and args type is int, slice, or [int], return a Callable[[quant], Any]:

ctrl_func = ctrl(ctrl_index, func, target_index)
# Equivalent to:
# ctrl_func = lambda q : ctrl(q[ctrl_index], func, q[target_index])

Example:

with around(ctrl(0, X, slice(1, None)), q): # ctrl(q[0], X, q[1:])
    H(q[0])                                 # H(q[0])
                                            # ctrl(q[0], X, q[1:])
Parameters:
  • control – Control qubits.

  • func – Functions to add control.

  • argsfunc arguments.

  • kwargsfunc keyword arguments.

  • on_state – Change the control state, same as for control.

  • later_call – If True, do not execute and return a Callable[[], Any].

adj(func: Union[Callable, list[Callable]], *args, later_call: bool = False, **kwargs) Union[Callable, Any]#

Inverse of a Callable

Call inverse:

ret1 = adj(func, *args, **kwargs)
# Equivalent to:
# with inverse():
#     ret1 = func(*args, **kwargs)

ret2 = adj([f0, f1, f2, ...], *args, **kwargs)
# Equivalent to:
# ret2 = []
# with inverse():
#     for f in func:
#         ret2.append(f(*args, **kwargs))
Create inverse operation:

1. If the keyword argument later_call is True, return a Callable[[], Any]:

adj_func = adj(func, *args, **kwargs, later_call=True)
# Equivalent to:
# adj_func = lambda : adj(func, *args, **kwargs)
  1. If any argument for func is provided, return the func inverse:

# def func(*args, *kwargs): ...
adj_func = adj(func)
# Equivalent to:
# adj_func = lambda *args, **kwargs : adj(func, *args, **kwargs)

Example:

rx_pi_inv = adj(RX(pi))
Parameters:
  • func – Function or list of functions to add control.

  • argsfunc arguments.

  • kwargsfunc keyword arguments.

  • later_call – If True, do not execute and return a Callable[[], Any].

class around(func: Union[Callable, list[Callable]], *args, **kwargs)#

Apply operation U around V and V inverse

With the quantum operations U and V, execute VUV \(\!^\dagger\), where V is defined as by func, *args, **kwargs and U is the open scope.

  • func must be a Callable or Iterable[Callable].

with around(V):
    U
Example:

# Grover diffusion operator
with around([H, X], s):
    with control(s[1:]):
        Z(s[0])
Parameters:
  • funcV operation.

  • argsfunc arguments.

  • kwargsfunc keyword arguments.

measure(q: ket.base.quant | list[ket.base.quant], free: bool = False) ket.base.future | list[ket.base.future]#

Quantum measurement

Measure the qubits of a quant and return a future or [future].

When measuring more than 64 qubits, Ket split the measure every 63 qubits.

Parameters:
  • q – Qubits to measure.

  • free – If True, free the qubits after the measurement.

qc_int(value: int) future#

Instantiate an integer on the quantum computer

Parameters:

value – Initial value.

Process Management#

run()

Execute in a new process

exec_quantum()

Call the quantum execution

quantum_exec_time()

Returns the quantum execution time in seconds of the last executed process

quantum_exec_timeout(timeout)

Set the quantum execution timeout

quantum_metrics()

Returns the metrics of the current process

quantum_metrics_last()

Returns the metrics of the last executed process

quantum_code()

Returns the quantum code of the current process

quantum_code_last()

Returns the quantum code of the last executed process

class run#

Execute in a new process

Run the quantum operations in a new separated process.

Usage:

with run():
    ...
quantum_metrics() dict[str, Any]#

Returns the metrics of the current process

The return is a json serialization of a struct Metrics from Libket. See https://gitlab.com/quantum-ket/libket/-/blob/main/src/ir.rs for more details.

quantum_metrics_last() dict[str, Any] | None#

Returns the metrics of the last executed process

If no processes have been run, this function returns None.

The return is a json serialization of a struct Metrics from Libket. See https://gitlab.com/quantum-ket/libket/-/blob/main/src/ir.rs for more details.

quantum_code_last() list[dict] | None#

Returns the quantum code of the last executed process

The return is a json serialization of a struct CodeBlock list from Libket. See https://gitlab.com/quantum-ket/libket/-/blob/main/src/code_block.rs for more details.

quantum_code() list[dict]#

Returns the quantum code of the current process

The return is a json serialization of a struct CodeBlock list from Libket. See https://gitlab.com/quantum-ket/libket/-/blob/main/src/code_block.rs for more details.

quantum_exec_time() float | None#

Returns the quantum execution time in seconds of the last executed process

If no processes have been run, this function returns None.

quantum_exec_timeout(timeout: int)#

Set the quantum execution timeout

Parameters:

timeout – timeout in seconds.

exec_quantum()#

Call the quantum execution

Import System#

import_ket(source)

Import Ket file

from_import_ket(source, *names)

Import names from Ket file

ket.code_ket(func)

Parse as Ket function

import_ket(source: PathLike) module#

Import Ket file

Import a Ket source file as a Python module.

Parameters:

source – Ket source file.

from_import_ket(source: PathLike, *names: list[str]) tuple#

Import names from Ket file

Parameters:
  • source – Ket source file.

  • names – Names to import from source.

code_ket(func: Callable) Callable#

Parse as Ket function

Decorator to parse a Python function as a Ket Function.

Warning

  • Do not use this decorator in a .ket file.

  • This decorator do not work with function defined inside a Jupyter Notebook or the Python interpreter.

  • This decorator is not part of Ket’s preamble.

Usage:

from ket import code_ket

@code_ket
def func(a : quant, b : quant, c : quant):
    m0 = measure(a)
    m1 = measure(b)
    if m1 == 1: # need @code_ket to properly execute
        x(c)
    if m0 == 1: # need @code_ket to properly execute
        z(c)

Quantum Library#

from ket import lib

qft(q[, invert])

Quantum Fourier Transformation

dump_matrix(u[, size])

Get the matrix of a quantum operation

bell([x, y, qubits])

Bell state preparation

ghz(qubits)

GHZ state preparation

w(qubits)

W state preparation

pauli(basis, q[, state])

Prepare in the +1 or -1 eigenstate of a given Pauli operator

qft(q: quant, invert: bool = True) quant#

Quantum Fourier Transformation

Apply a QFT on the qubits of q.

Parameters:
  • q – input qubits

  • invert – if True, invert qubits with swap gates

Returns:

Qubits in the reserved order

dump_matrix(u: Union[Callable, list[Callable]], size: int = 1) list[list[complex]]#

Get the matrix of a quantum operation

Parameters:
  • u – Quantum operation.

  • size – Number of qubits.

bell(x: int = 0, y: int = 0, qubits: Optional[quant] = None) quant#

Bell state preparation

Return two entangle qubits in the Bell state:

\[\left|\beta_{x,y}\right> = \frac{\left|0,y\right> + (-1)^x\left|1,¬y\right>}{\sqrt{2}}\]
Parameters:
  • x\(x\).

  • y\(y\).

  • qubits – if provided, prepare the state in qubits.

ghz(qubits: ket.base.quant | int) quant#

GHZ state preparation

Return qubits on the state:

\[\left|\text{GHZ}\right> = \frac{\left|0\dots0\right> + \left|1\dots1\right>}{\sqrt{2}}\]
Parameters:

qubits – Qubits to prepare the state, if it is an int allocate the number of qubits.

w(qubits: ket.base.quant | int) quant#

W state preparation

Return qubits on the state:

\[\left|\text{W}\right> = \frac{1}{\sqrt{n}} \sum_{k=0}^{n} \left|2^k\right>\]
Parameters:

qubits – Qubits to prepare the state, if it is an int allocate the number of qubits.

pauli(basis: Callable, q: quant, state: int = 1) quant#

Prepare in the +1 or -1 eigenstate of a given Pauli operator

Parameters:
  • basis – Pauli operator X, Y, or Z.

  • q – Input qubits.

  • state – Eigenstate.

Plugins#

from ket import plugins

plugin(name, args, qubits)

Apply plugin

pown(a, x, N)

Apply a modular exponentiation in a superposition

plugin(name: str, args: str, qubits: quant)#

Apply plugin

Note

Plugin availability depends on the quantum execution target.

Parameters:
  • name – Plugin name.

  • args – Plugin argument string.

  • qubits – Affected qubits.

pown(a: int, x: quant, N: int) quant#

Apply a modular exponentiation in a superposition

\[\left| x \right> \left| 1 \right> \rightarrow \left| x \right> \left| a^x\; \text{mod} \, N \right>\]

Note

Plugin availability depends on the quantum execution target.

Parameters:
  • a\(a\).

  • x\(x\).

  • N\(N\).

Returns:

quant with the operation result.