How to calculate the evolution of ket states through a simple quantum circuit?

I am having difficulties with the calculations of qubits. I think I can do them, but it feels so massivly inefficient!

In this tutorial grover's algorithm for example, there's a simple oracle given for the binary bitcombination '110': (bit-order is as usual swapped, so most significant bit is q2 - at least I think so) what I've tried so far:

let $$a = |110>$$

the first step I thought would be to apply the x on the top bit and the Hadamard on the bottom bit so:

$$a' = |111>$$

$$a'' = \frac{1}{\sqrt{2}}(|011> - |111>)$$

next I would think: only when the second and third bit are equal to 1 then the first bit swaps:

$$a''' = \frac{1}{\sqrt{2}}(|111> - |011>)$$

next I negate the top (third) bit:

$$a^{4'} = \frac{1}{\sqrt{2}}(|110> - |010>)$$

and finally I use Hadamard on the bottom (first) bit:

$$\displaystyle a^{5'} = \frac{1}{2} \Big(|010> - |110> -\big(|010> + |110>\big)\Big)$$

$$= -|110>$$

and yes, thats exactly what I want. But is there a way to calculate this alternively with some matrices or tensors? where I can use the form of

$$|110> = \begin{pmatrix} 0\\0\\0\\0\\0\\0\\1\\0 \end{pmatrix}$$

How can I represent the layer with X() and H() mixed?

First of all: the bit-order that you use is not the conventional one in quantum computing. We usually use the convention that $$|x_1 x_2 \dots x_n \rangle = |x_1\rangle \otimes |x_2\rangle \otimes \dots \otimes |x_n\rangle,$$ i.e. the "first" bit $$x_1$$ corresponds to the "first" qubit which is usually the top one in the circuit notation. I agree, this is completely arbitrary.
Now to your actual question: There is nothing wrong with you calculation. You could have noticed that conjugating by $$H$$ on the target qubit turns $$CCX$$ into $$CCZ$$. This would have saved two steps in your calculation.
Of course, you can instead express everything in terms of 3-qubit matrices (which are of size $$2^3\times 2^3 = 8\times 8$$). Then, the $$X$$ / $$H$$ layer would be represented by the matrix $$X\otimes \mathbb{I}\otimes H$$ where $$\mathbb{I}$$ is the identity matrix.
But please don't do this. This is highly inefficient, especially if you deal with an arbitrary amount of qubits. The whole point of local gates is that they can be applied locally. This only requires to update the local states which can be done efficiently as long as the number of terms in you superposition is not too big. On the contrary, multiplying $$n$$-qubit matrices is always inefficient.
• @eli44 It's only a matter of convention. First of all, we usually call the top-most qubit in a quantum circuit the "first" qubit, that's why it's called $q$ in your picture. Next, and independent from circuits, we simply say that the leftmost bit is the first one and that it should correspond to the first qubit. Whether this first bit is the least or most significant bit is irrelevant at this level. It is only needed when data shall be encoded. I don't see the difference to how this is handled in classical computing ... Apr 28 '21 at 13:42