# If for every sequence $(x_n)$, $x_n \to x_0 \implies (f(x_n))$ is a Cauchy sequence, then is $f$ continuous? [duplicate]

Given $$f:D \subseteq \mathbb{R} \to \mathbb{R}$$, if for every sequence $$(x_n)$$ in $$D$$ such that $$x_n \to x_0$$ is true that $$(f(x_n))$$ is a Cauchy sequence, then is $$f$$ continuous?

This is what I know:

1. Every Cauchy sequence is a convergent sequence.
2. $$f$$ is continuous if and only if $$x_n \to x_0 \implies f(x_n) \to f(x_0)$$ for every sequence $$(x_n)$$.

However, I only know that $$f(x_n) \to a \in \mathbb{R}$$; how can I see that $$a = f(x_0)$$ and then have the continuity of $$f$$?

If the result is false, please show a counterexample, i.e., a discontinuous function such that for every $$x_n \to x_0$$ I have $$(f(x_n))$$ Cauchy.

The statement is correct. To see this, let $$x_0\in D$$ and $$(x_n)$$ a sequence in $$D$$ with $$x_n\to x_0$$. We want to show that $$f(x_n)\to f(x_0)$$. Define the sequence $$(y_n)=(x_1,x_0,x_2,x_0,x_3,x_0,\dots)$$. Then $$y_n\to x_0$$, so by assumption $$f(y_n)$$ is a Cauchy-sequence. It has the constant convergent subsequence $$f(x_0)$$, hence $$f(y_n)$$ converges to $$f(x_0)$$ (A Cauchy-sequence with convergent subsequence is itself convergent with the same limit). As $$f(x_n)$$ is a subsequence of $$f(y_n)$$ it follows that $$f(x_n)\to f(x_0)$$

Correct me if wrong.

Perhaps a bit of nitpicking.

1)If $$x_0 \in D;$$

Then consider $$x_n:=x_0$$ and you are done

2)Assume $$x_0\not \in D$$, and $$x_0$$ a limit point of $$D,$$ then

$$f(x_n) \rightarrow f(a);$$ i.e. $$f(x_n)$$ has a limit;

Continuity does not follow.

Example:

$$D_L=$$ { $$x|x<0$$ };

$$f:(x)=0$$ for $$x<0;$$

Define $$D'=$$ { $$0$$ }:

$$f(0)=1.$$

$$D_R$$ defined similarly.