# Multiplication¶

The multiplication operation, denoted '$$*$$', is a series of additions ("long multiplication"). The multiplier has different implementations, depending on the type of adder in use.

Note that integer and fixed-point numbers are represented in a two-complement method during function evaluation. The binary number is extended in the case of a register size mismatch. For example, the positive signed number $$(110)_2=6$$ is expressed as $$(00110)_2$$ when working with a five-qubit register. Similarly, the negative signed number $$(110)_2=-2$$ is expressed as $$(11110)_2$$.

## Examples¶

The calculation of -5 * 3 = -15.

The left arg -5 is represented as 1011 and 3 as 11. The number of digits needed to store the answer is 4+2-1 = 5. The multiplication is done in the 'regular' manner where each number is extended to five bits and only five digits are kept in the intermediary results.

$\begin{equation*}\begin{array}{c} \phantom{\times}11011\\ \underline{\times\phantom{000}11}\\ \phantom{\times}11011\\ \underline{\phantom\times1011\phantom9}\\ \phantom\times10001 \end{array}\end{equation*}$

## Syntax¶

Function: Multiplier

Parameters:

• left_arg: Union[float, int, RegisterUserInput] (see RegisterUserInput)
• right_arg: Union[float, int, RegisterUserInput]

Register names:

• left_arg: left_arg
• right_arg: right_arg
• result: product
{
"function": "Multiplier",
"function_params": {
"left_arg": 3,
"right_arg": { "size": 3 }
}
}


## Example 1: Two-Register Multiplication¶

{
"functions": [
{
"name": "main",
"body": [
{
"function": "Multiplier",
"function_params": {
"left_arg": {"size": 3},
"right_arg": {"size": 3}
}
}
]
}
]
}

from classiq import Model, QUInt, synthesize, show
from classiq.builtin_functions import Multiplier

params = Multiplier(
left_arg=QUInt(size=3).to_register_user_input(),
right_arg=QUInt(size=3).to_register_user_input(),
)
model = Model()
model.Multiplier(params)
quantum_program = synthesize(model.get_model())
show(quantum_program)


This code example generates a circuit that multiplies two arguments. Both left_arg and right_arg are defined as quantum registers of size three.

### Generated Circuit¶ ## Example 2: Float and Register Multiplication¶

{
"functions": [
{
"name": "main",
"body": [
{
"function": "Multiplier",
"function_params": {
"left_arg": 3.5,
"right_arg": {
"size": 3
}
}
}
]
}
]
}

from classiq import Model, RegisterUserInput, synthesize, show
from classiq.builtin_functions import Multiplier

params = Multiplier(left_arg=3.5, right_arg=RegisterUserInput(size=3))
model = Model()
model.Multiplier(params)
quantum_program = synthesize(model.get_model())
show(quantum_program)


This code example generates a circuit that multiplies two arguments. Here, left_arg is a fixed-point number $$(11.1)_2$$ and right_arg is a quantum register of size three.

### Generated Circuit¶ 