In [Brubeck, Nakatsukasa, and Trefethen - Vandermonde with Arnoldi](https://arxiv.org/abs/1911.09988) (example 3) they solve the following linear system:
$$\operatorname{Re}\left(\begin{array}{ccc}1 & \cdots & z\_{1}^{n} \\ 1 & \cdots & z\_{2}^{n} \\ \vdots & \ddots & \vdots \\ 1 & \cdots & z\_{m}^{n}\end{array}\right)\left(\begin{array}{c}a\_{0} \\ \vdots \\ a\_{n}\end{array}\right)-\operatorname{Im}\left(\begin{array}{ccc}z\_{1} & \cdots & z\_{1}^{n} \\ z\_{2} & \cdots & z\_{2}^{n} \\ \vdots & \ddots & \vdots \\ z\_{m} & \cdots & z\_{m}^{n}\end{array}\right)\left(\begin{array}{c}b\_{1} \\ \vdots \\ b\_{n}\end{array}\right)\approx\left(\begin{array}{c}f\_{1} \\ f\_{2} \\ \vdots \\ f\_{m}\end{array}\right).$$


$A=\left(\begin{array}{ccc}1 & \cdots & z\_{1}^{n} \\ 1 & \cdots & z\_{2}^{n} \\ \vdots & \ddots & \vdots \\ 1 & \cdots & z\_{m}^{n}\end{array}\right)$.


For solving it, they use the following MATLAB code:



```
c = [real(A) imag(A(:,2:n+1))]\f;
c = c(1:n+1) - 1i*[0; c(n+2:2*n+1)];

```

The first line is equivalent to creating a vector `c=[a,b]` where $\operatorname{Re}(A)a\approx f$ and $\operatorname{Im}(A(:,2:n+1))b \approx f$ and the second one means $c=a-[0,bi]$. I was wondering how it can be solved in this way, in fact I reproduced the code of the paper in Mathematica and the results are not the same. Is there any typo in this procedure?



Solution of complex linear system
No, the first line is not equivalent to what you claim in the text, I believe: that's *one* linear system containing a subtraction and not two separate linear systems.


In detail, the matrix of this linear system is obtained by concatenating horizontally `M = real(A)` and `N = imag(A(:,2:n+1))`. If you split the unknown into
$$
c = \begin{bmatrix}
a\\-b
\end{bmatrix}
$$
then this linear system is
$$
f = 
\begin{bmatrix}M & N\end{bmatrix}
\begin{bmatrix}
a\\-b
\end{bmatrix}
=
Ma - Nb,
$$
which corresponds to your first formula. But, ultimately, you are solving *one* linear system with matrix $\begin{bmatrix} M & N\end{bmatrix}$. The instruction `[real(A) imag(A(:,2:n+1))]` stacks matrices one next to the another; it is not a "vectorized" syntax to solve two linear systems with different matrices and the same RHS.


I suspect that's the source of the issue (and, also, possibly, not solving the linear system in the least-squares sense.)


