# Let $f,g:[a,b]\to [c,d]$ be continous functions. Suppose that $f$ is surjective. Prove that there exists $x\in[a,b]$ such that $f(x)=g(x)$

Problem: Let $$f,g:[a,b]\to [c,d]$$ be continous functions. Suppose that $$f$$ is surjective. Prove that there exists $$x\in[a,b]$$ such that $$f(x)=g(x)$$

My solution and proof: Given $$f,g:[a,b]\to[c,d]$$ are both continous functions. Let $$h(x)=f(x)-g(x)$$. Then clearly $$h$$ is a continous function from $$[a,b]$$ into $$[c,d]$$, and it's the difference between two continous functions. Since $$f$$ is surjective, $$\exists x$$ such that $$f(x_2)=d$$. Also, $$g(x_1),g(x_2)\in[c,d]$$. Therefore $$h(x_1)=f(x_1)-g(x_1)\leq0$$ as $$f(x_1)=c$$ and $$h(x_2)=f(x_2)-g(x_2)\geq$$ as $$f(x_2)=d$$. Thus $$h$$ is a continous function having $$h(x_1)\leq0$$ and $$h(x_2)\geq0$$, then by intermediate value theorem $$\exists x\in[x_1,x_2]\subseteq[a,b]$$ such that $$h(x)=0$$ and $$f(x)=g(x)$$. Hence, $$\exists x\in[a,b]$$ such that $$f(x)=g(x)$$

Does my proof look correct? Anything missing?

• It looks fine to me. Commented Apr 28, 2021 at 21:32
• It's not true that $h$ is a continuous function from $[a, b]$ to $[c, d]$. In particular, the codomain isn't correct. For example, you could imagine that $c = 1$ and $d = 2$, but you're examining spots when $h(x) = 0$, and $0 \not \in [1, 2]$. Commented Apr 28, 2021 at 21:50
• @davidlowryduda is correct, but this doesn't really affect your argument. Rather than figure out how small you can make the codomain of $h$, just say $h\colon[a,b]\to\mathbb R$. It's important that $\operatorname{ran}f=[c,d]$ and that $\operatorname{ran}g\subseteq[c,d]$, but $\operatorname{ran}h$ is not so important. (Well, it's important that $\operatorname{ran}h\ni0$, but the rest of it doesn't matter.) Commented Apr 28, 2021 at 22:15
• You seem to have a typo where you write ‘$\exists x$ such that $f(x_2)=d$’. You talk about $x_1$ and $x_2$, not just $x$, and use a property of $x_1$ later too. There's another typo where you have $\geq$ with nothing after it. So fix these, the codomain of $h$ (as noted above), and the missing period at the very end, and you have a good proof. Commented Apr 28, 2021 at 22:21
• One more minor error here is that you write $\exists x\in[x_1,x_2]$, but you don't know whether $x_1<x_2$ or $x_1>x_2$, so you should write $\exists x\in[\min(x_1,x_2),\max(x_1,x_2)]$ (or use words like ‘there is an $x$ between $x_1$ and $x_2$’). Commented Apr 29, 2021 at 3:52