To show that $f$ is 1-1, you could show that $$f(x)=f(y)\Longrightarrow x=y.$$
So, for example, for $f(x)={x-3\over x+2}$:
Suppose ${x-3\over x+2}= {y-3\over y+2}$. Then:
\begin{align*}
&{x-3\over x+2}= {y-3\over y+2} \\
\Longrightarrow& (y+2)(x-3)= (y-3)(x+2)\\
\iff& yx+2x-3y-6= yx-3x+2y-6\\
\iff&2x-3y =-3x+2y\\
\iff&2x+3x =2y+3y\\
\iff&5x =5y\\
\iff&x=y
\end{align*}
So $f(x)={x-3\over x+2}$ is 1-1.
I'll leave showing that $f(x)={{x-3}\over 3}$ is 1-1 for you.
Alternatively, to show that $f$ is 1-1, you could show that $$x\ne y\Longrightarrow f(x)\ne f(y).$$
Or, for a differentiable $f$ whose derivative is either always positive or always negative, you can conclude $f$ is 1-1 (you could also conclude that $f$ is 1-1 for certain functions whose derivatives do have zeros; you'd have to insure that the derivative never switches sign and that $f$ is constant on no interval).
You would discover that a function $g$ is not 1-1, if, when using the first method above, you find that the equation is satisfied for some $x\ne y$. For example, take $g(x)=1-x^2$. Then
$$
\eqalign{
&g(x)=g(y)\cr
\iff&{1-x^2}= {1-y^2} \cr
\iff&-x^2= -y^2\cr
\iff&x^2=y^2\cr}
$$
The above equation has $x=1$, $y=-1$ as a solution. So, there is $x\ne y$ with $g(x)=g(y)$; thus $g(x)=1-x^2$ is not 1-1.
Of course, to show $g$ is not 1-1, you need only find two distinct values of the input value $x$ that give $g$ the same output value.
Although you rightfully point out that the graphical method is unreliable; it is still instructive to consider the methods used and why they work:
Graphically, you can use either of the following:
- Use the "Horizontal Line Test":
$f$ is 1-1 if and only if every horizontal line intersects the graph
of $f$ in at most one point. Note that this is just the graphical
interpretation of "if $x\ne y$ then $f(x)\ne f(y)$"; since the
intersection points of a horizontal line with the graph of $f$ give
$x$ values for which $f(x)$ has the same value (namely the $y$-intercept of the line).
- Use the fact that a continuous $f$ is 1-1 if and only if $f$ is either
strictly increasing or strictly decreasing. This, of course, is the case if $f$ is differentiable and the derivative is always positive or always negative (with perhaps being zero at "isolated" points).
(Note this method applies to only the green function below.)
You are correct. Both $f$ and $g$ are one-to-one on the given intervals.
Note that:
$$
(f+g)(0)=\sin0+\cos0=0+1=1+0=\sin\pi/2+\cos\pi/2=(f+g)(\pi/2)
$$
Hence, $f+g$ is not one-to-one. Here's a graph that verifies that $f+g$ indeed fails the horizontal line test. Note that by using trig identites we can rewrite $f+g$ as:
$$
\sqrt{2}\sin\left(x+\dfrac{\pi}{4}\right)
$$
which suggests that $f+g$ has an axis of symmetry at $x=\pi/4$.
Best Answer
First, let me answer your question; but please keep reading, because there's lots more to say.
Yes: there is an analytic way to see if a function is one-to-one. For this, you need the "analytic definition" of being one-to-one. The definition is:
$$f\text{ is one-to-one if and only if for all }a,b\text{ if }a\neq b\text{ then } f(a)\neq f(b).$$ Logically, this is equivalent to: $$f\text{ is one-to-one if and only if for all }a,b\text{ if }f(a)=f(b)\text{ then }a=b.$$
So this provides a way to check if the function is one-to-one: if you can find $a\neq b$ such that $f(a)=f(b)$, then $f$ is not one-to-one; and this is essentially the best way of doing it: exhibit a pair of distinct numbers that map to the same thing. To prove that $\sin(x)$ is not one-to-one, all I need to do is say: "Look, $0$ and $\pi$ are different, but $\sin(0)=\sin(\pi)$."
To prove that a function is one-to-one, you can do it in any of two (equivalent) ways: show that if $a$ and $b$ are any numbers with the property that $f(a)=f(b)$, then it must be the case that $a=b$; or show that if $a\neq b$, then $f(a)$ must be different from $f(b)$.
For instance, to show that $f(x)=x^3$ is one to one, we can note that if $f(a)=f(b)$, then $a^3=b^3$, and taking cubic roots we conclude that $a=\sqrt[3]{a^3} = \sqrt[3]{b^3} = b$. So if $f(a)=f(b)$, then $a=b$. QED.
Or we can argue that if $a\neq b$, then either $a\lt b$ or $a\gt b$. If $a\lt b$, then $a^3\lt b^3$ (you can prove this easily using the properties of real numbers and inequalities), so $f(a)\neq f(b)$. If $a\gt b$, then $f(a)=a^3\gt b^3=f(b)$, hence $f(a)\neq f(b)$. Either way, $a\neq b$ implies $f(a)\neq f(b)$, so $f$ is one-to-one.
This is the standard way of showing, analytically, that a function is one-to-one. How one establishes the implication will depend on the function.
That said, there are some things you may want to remember:
First: to specify a function, we usually need to specify at least two things: the domain of the function, and the value of the function at any point in the domain.
More often, we are interested in functions between two specific sets. In that case, we actually need to specify three things: the domain, the set in which the images will lie, and the value of the functions at any point of the domain.
So, if we say that we have a function $f\colon X\to Y$ between two sets, then we mean that:
For every $x\in X$, there is an element of $y\in Y$ such that $f(x)=y$; and
For each $x\in X$, there is only one $y\in Y$ with $f(x)=y$ (unique value).
So, we need every element of $X$ to have a unique image. Different elements of $X$ may have the same image, but a single element should not have multiple images. We call $X$ the domain of $f$, and we call $Y$ the codomain of $f$.
In calculus, however, we are usually a bit sloppy. We almost never mention either the domain or the codomain! Instead, we agree that if we will either specify the domain explicitly, or else we will mean "the natural domain". And we almost never mention the codomain at all.
Now, if you have a function $f\colon X\to Y$, then we say that a function $g\colon Y\to X$ "going the other way" is "the inverse of $f$" if and only if two things happen:
Now, for this to actually work, we need two things:
Given an element $y\in Y$, there can be at most one $x\in X$ such that $y=f(x)$. This is the "one-to-one" condition. If you think in terms of calculus and the graph, it is precisely the "horizontal line test": for each value of $y$ (each horizontal line), there is at most one point in the domain where $f$ takes value $y$ (it cuts the graph in at most one point).
Given any element $y\in Y$, there is at least one $x\in X$ such that $y=f(x)$. This is the "onto" or "surjective" part people have mentioned.
So: if $f\colon X\to Y$ has an inverse, then it must be both one-to-one, and onto the set $Y$. This is necessary. In fact, it is also sufficient, and one can show that if there is an inverse, then there is one and only one inverse, so we call it $f^{-1}$ instead of $g$.
Now, here's the thing: if your function satisfies the first condition (one-to-one), but not the second, then you can "cheat": instead of thinking of $f$ as a function from $X$ to $Y$, we let $Y'=\mathrm{Image}(f)$, and then look at the function $\mathfrak{f}\colon X\to Y'$, with $\mathfrak{f}(x)=f(x)$ for every $x$; the only thing we changed is what we want the set $Y$ to be. This is not really the same as $f$: $\mathfrak{f}$ one is both one-to-one and onto, so $\mathfrak{f}$ does have an inverse, even though $f$ does not.
For instance, if you think of the function $f\colon\mathbb{R}\to \mathbb{R}$ given by $f(x)=e^x$, then $f$ is one-to-one, but is not onto ($f(x)$ does not take negative values). So this function is not invertible. However, if we tweak the function and think of it instead as $\mathfrak{f}\colon\mathbb{R}\to (0,\infty)$, given by $\mathfrak{f}(x)=e^x$, then $\mathfrak{f}$ is onto, is also one-to-one, so $\mathfrak{f}$ is invertible. The inverse is a function $f^{-1}\colon (0,\infty)\to\mathbb{R}$, so the only valid inputs are positive numbers. (You may know who $f^{-1}$ is: it's the natural logarithm).
Now, notice that to check if a function has an inverse, you need to know both what $X$ and what $Y$ is. But in Calculus we almost never mention $Y$. So what can we do?
Well, we agree that we will take $Y$ to be "the image of $f$"; that is, the collection $$\{ f(x) \mid x\text{ is in the domain of }f\}.$$ That means that we always "automatically" assume our functions are "onto". We say this by saying that the function is "onto its image".
Given that agreement, in order to figure out if $f$ has an inverse, we just need to know if $f$ is one-to-one, which is why your calculus book says things like "a function has an inverse if and only if it is one to one, if and only if it passes the horizontal line test." They are referring exclusively to functions whose codomain is always taken to be the image.