Restrict $x$ in an equation, but keeping only one equation How do you put restrictions on the $x$ in an equation without writing more than one equation? This is a two part question:


*

*How to take out a section of the graph of an equation?

*How to take out everything but a section of the graph of an equation?


For example, to take out $x$ from $-1$ to $1$ in $y=|x|$, you can change the equation to $$y=|x|\times\dfrac{\sqrt{|x|-1}}{\sqrt{|x|-1}}$$
I need to take a function, say $f(x)$, and restrict it to $1 < x < 4$.
 A: You're on the right track. If you want to restrict the domain to $1 < x < 4$, simply multiply and divide by square root which would imply the two separate restrictions $x>1$ and $x<4$. In this case. Those would be $\sqrt{x-1}$ and $\sqrt{4-x}$. Put it all together and you have

 $f(x)_{restricted} = f(x) \cdot \frac{\sqrt{x-1}}{\sqrt{x-1}} \cdot \frac{\sqrt{4-x}}{\sqrt{4-x}}$.

The process for eliminating everything but a certain region is similar.
A: The function $\frac{\ln x}{\ln x}$ is the identity on $(0,\infty)$ and the function $\frac{1+\sqrt x}{1+\sqrt x}$ is the identity on $[0,\infty)$. These can be used to "retain" intervals with one endpoint at infinity. For example to restrict to $[a,b)$ we multiply by $\frac{1+\sqrt{x-a}}{1+\sqrt{x-a}} \cdot \frac{\ln b-x}{\ln b-x}$.
For more complicated unions of intervals, you can use polynomial equations with $p(x) \ge 0 \Rightarrow x\in \bar \Omega$ where $\Omega$ is your desired domain and then multiply by $\frac{\ln p(x)}{\ln p(x)}$ or $\frac{1+\sqrt{p(x)}}{1+\sqrt {p(x)}}$ depending on whether you want to include the endpoints or not. If these are also mixed, you can exclude a single point by using $\frac{\ln |x-a|}{\ln |x-a|}$ as a factor.
Restriction to $(1,4)$ as you ask, can be done with the $\ln$-template:
$$f|_{(1,4)}(x) = f(x) \cdot \frac{\ln(x-1)}{\ln(x-1)} \cdot \frac{\ln(4-x)}{\ln(4-x)}$$
Or, more elegantly, $f(x) \cdot \frac{\ln(\frac32 - |\frac52-x|)}{\ln(\frac32-|\frac52 - x|)}$ where $\frac52 = \frac12(1+4)$ and $\frac32 = \frac12(4-1)$ are the midpoint and radius of the interval.
A: The easiest thing to do is to introduce something like the characteristic function,the Kronecker delta function, or an Iverson bracket, or the heaviside step function. You can find information on those on wikipedia or proofwiki.org. They allow you to assign a variable that takes on $1$ under some condition and $0$ otherwise. Then your function won't be undefined otherwise, it will be zero, but in practical applications that's generally just fine, if not better.
Let's say you don't want to do that, for some reason.
For a restriction to an unbounded interval, start with a function that has an easy to manipulate domain. I'll use $\ln$, but $\sqrt{\phantom{x}}$ works just as well.
$$\ln x : x > 0$$
You can easily switch the direction of this by a minus sign:
$$\ln (-x) : -x > 0$$
and we have $-x > 0 \iff x < 0$
Let's say I want to limit my function to $x < -2$. Then I can multiply by:
$$\frac{\ln (-x-2)}{\ln (-x-2)} = 1: -x - 2 > 0$$ 
and we have $-x - 2 > 0 \iff x < -2$
You can do this more than once. Let's say I want to limit the function to $-10 < x < -2$. Then we can combine the restrictions of $x > -10$ and $x < -2$:

$$\frac{\ln (-x-2)}{\ln (-x-2)} \frac{\ln (x+10)}{\ln (x+10)} = 1: -x - 2 > 0,x+10 > 0$$ 

and we have $x < -2 \text{ and } x> -10$. 
Offhand, I can't think of a way to exclude the endpoints in the restriction, but if I think of one I'll update this answer.
Edit: AlexR has an excellent way to exclude the endpoints in the restriction.
