Is it true that $f(z)=u(z,0)+iv(z,0)$ for complex $z$ and why? As in the title, i came across this equivalence
$$f(z)=f(x+iy)=u(x,y)+iv(x,y)=u(z,0)+iv(z,0)$$ while reading my notes on complex analysis, and tried to see why is it true, but i couldn't figure it out. Maybe it could be true only in the case that f is holomorphic.
As pointed out by many, as written this doesn't make much sense (unless $z$ is real, in which case it's trivial). However, I think what is trying to be communicated is a certain calculational trick.

Let's start with the example $f(z) = e^z$. Then $u(x,y) = e^x \cos (y)$ and $v(x,y) = e^x \sin (y)$, so if we now redefine $u,v$ using these same formulae as functions of two complex variables, we see

$$ u(z,0) + i v(z,0) = e^z \cos(0) + i e^z \sin(0) = f(z).$$

In general, for any analytic function

$$f(z) = \sum_{n=0}^\infty (a_n + i b_n) z^n,$$ 

with $a_n,b_n$ real, for real $z$ we have

$$ u(z,0) = \sum_n a_n z^n \; \text{ and } \; v(z,0) = \sum_n b_n z^n.$$

Reinterpreting these now as complex analytic functions (i.e. defining $\tilde u : \mathbb C \to \mathbb C : z \mapsto \sum_n a_n z^n$ and likewise $\tilde v$) we have $$f(z) = \tilde u (z) + i \tilde v(z).$$

Thus we get the trick: if you can write down $u(x,0)$ and $v(x,0)$ as some formulae in terms of elementary analytic functions, replacing $x$ with $z$ in $u(x,0) + i v(x,0)$ will give you the correct formula for $f(z)$ on the whole plane.
It suffices to check when $f(z) = z^n$. Observe
\begin{align}
(x+iy)^n =&amp; \sum^n_{k=1} \binom{n}{k}x^{n-k}(iy)^k = \sum_{k \text{ even}}\binom{n}{k}x^{n-k}(iy)^k + \sum_{k\text{ odd}}\binom{n}{k}x^{n-k}(iy)^k \\
=&amp;\ \sum \binom{n}{2\ell}(-1)^\ell x^{n-2\ell}y^{2\ell} + i\sum \binom{n}{2\ell+1}(-1)^\ell x^{n-2\ell-1}y^{2\ell+1} \\ 
=&amp;\ u(x, y) + iv(x, y)
\end{align} 
and observe 
\begin{align}
u(z, 0) + iv(z, 0) = z^n. 
\end{align}
Thus, when $f(z) = z^n$, we have $f(z) = u(z, 0) + iv(z, 0)$. 

In the case when $f$ is not analytic the claim is false. For instance, 
\begin{align}
f(z) = \bar z  = x-iy  \ \ \text{ but } \ \ u(z, 0)+iv(z, 0) = z \neq \bar z. 
\end{align}