I wonder why it is faster to square a matrix with the `A2=A^2` command (`A` being a `LxL` matrix) than to just do a double `for` loop and assign the value to a zeroed matrix. 
I have run the following code to check the first case 

```
tic
psi2=psi.^2;
T1=toc;

```

and the following for the second

```
psi2=zeros(L,L);
tic 
for i=1:L
    for j=1:L
        psi2(i,j)=psi(i,j)^2;
    end
end
T2=toc;

```

In [this figure](https://i.stack.imgur.com/HGhPC.png) the elapsed time for several matrices sizes (`L`) are shown and the speedup is clear. 

I would not be surprised to see that MATLAB has a very efficient implementation of matrix multiplication as it what is it made for, but I can't understand how there's a faster way to do element-wise operations than just looping over it. 

Thanks for time.