# Joining two graphs

Suppose I have $f_1(x)=x$

And i restrict its domain as $\color{blue}{(-\infty,0]}$ using $g_1(x)=\dfrac{x}{\frac{1}{2\left(x-0\right)}\left(x-0-\left|x-0\right|\right)}$

Resulting in :

Now, suppose i have $f_2(x)=\sin{(x)}$

And i restrict its domain to $\color{blue}{(0,\infty)}$ using $g_2(x)=\dfrac{\sin x}{\frac{1}{2\left(0-x\right)}\left(0-x-\left|0-x\right|\right)}$

Resulting in :

Now I want a new equation which can join $g_1(x)$ and $g_2(x)$ in one single equation. How should i achieve it?

I mean $\large g_{\text{joined 1+2}}(x)$ would look like :

Also i want a single equation which is NOT of the form of $\color{red}{ f(x)= \begin{cases} x& \text{if } x\leq 0\\ \sin{(x)}& \text{if } x> 0 \end{cases}}$

My attempt :

I tried using $(y-g_1(x))(y-g_2(x))=0$ but they don't seem to work...

They seem to be working with $y=x,x \in (-\infty,0]$ and $y=2x, x \in (-\infty,0]$ as :

So how to proceed?

• What's wrong with splitting casewise? Commented Jul 3, 2015 at 17:04
• @Meelo Just curious! The way i restricted the domain of x and sin(x) was also not using condition but was using single equation...!! Commented Jul 3, 2015 at 17:05
• @NeilRoy I have another answer you might like. Commented Dec 27, 2015 at 22:57

How about this? $$y=\frac{x-|x|}{2}+\sin\left(\frac{x+|x|}{2}\right)$$

• This feels like cheating in this case (because the absolute value is also defined piecewise), but I really like this answer. Commented Jul 3, 2015 at 17:11
• Can you suggest for $y=f_1(x) x \in (a,b)$ and $y=f_2(x) x \in (c,d)$ ? And Thanks a lot! Commented Jul 3, 2015 at 17:13
• @MichaelBurr Alternatively (though still cheaty), you could define it as $\sqrt{x^2}$. Commented Jul 3, 2015 at 18:30
• @mathlove I thought you might want to check my answer. Commented Dec 28, 2015 at 0:14
• @mathlove Your answer is a specific example of Archaik's answer so...... Commented Dec 29, 2015 at 16:19

When I was your age, I discovered a way to do this, although it's a bit artificial. Suppose that you want a function, that has an unrestricted domain, which takes on the values of a function $f(x)$ when $x<a$ and $g(x)$ when $x>a$. Then $h(x)$, the function we are looking for, can be given by $$h(x)=f\left(\frac{|x-a|-(x-a)}{2}\right)+g\left(\frac{|x-a|+(x-a)}{2}\right)-f(0)\left(\frac{|x-a|+(x-a)}{2}\right)-g(0)\left(\frac{|x-a|-(x-a)}{2}\right)$$

Suppose we wish to define a function which takes on the values of $f(x)$ for $x\in(a,b)$ and $g(x)$ for $x \in (c,d)$. Then we define $h(x)$, the function we are looking for, to be

$$h(x)=f\left(\left[\frac{|x-a|}{x-a}-\frac{|x-b|}{x-b}\right]\frac{x}{2}\right)+g\left(\left[\frac{|x-c|}{x-c}-\frac{|x-d|}{x-d}\right]\frac{x}{2}\right)-f(0)\left(\frac{|x+b|+(x+b)+|x-a|-(x-a)}{2}\right)-g(0)\left(\frac{|x-d|+(x-d)+|x-c|-(x-c)}{2}\right)$$

I used to think of these constructions to be made by 'switches'. There is a better way to do this if my memory serves me right but this is all I can remember right now. I'll be sure to edit if I remember how I did it before. Nice question!

• How about $f(x) \in (a,b)$ and $g(x) \in (c,d)$? I guess its a bit complex...! But thanks! Commented Jul 3, 2015 at 17:15
• I'll edit now to include this case. Commented Jul 3, 2015 at 17:16
• Please do! Thanks a lot! Commented Jul 3, 2015 at 17:20
• Sorry to ask another question but just give me a hint so as to what will happen if I want to use [ instead of ( as in $[a,b)$ ? Commented Jul 3, 2015 at 18:01
• Not at all. It's a pretty safe assumption that $f$ is continuous, so $\lim_{x\to a} f\left(\frac{|x-a|}{x-a}\right)=f\left(\lim_{x \to a}\frac{|x-a|}{x-a}\right)$. Let me know if you'd like another hint. Commented Jul 3, 2015 at 18:13

I found shorter ways of generalizing this. I am as old as you are so I am glad to know someone has a similar kind of interest as I do. I notice that when $f(0)\neq{0}$ and $g(0)\neq{0}$ my method could be quicker.

Basically you can take two functions and "fuse" them by the floor function with exponents (as long as the function does not have a restricted domain ex.$\sqrt{x}$). I found that using this I can bring $f(x)\in(-\infty,a)$ and $g(x)\in[a,\infty)$ to a single equation. $${{f(x)}^{\frac{-\text{sgn}{\lceil(x-a-1)+.5}\rceil+1}{2}}} {g(x)}^{\frac{{\text{sgn}\lceil(x-a-1)+.5}\rceil+1}{2}}$$

To switch which domain of the function $x=a$ is included in, replace the "ceil" function with the "floor" on your computer. Also you may need to use "sign" instead of "sgn" for the signum function.

Unfortunately this fusion works best when were fusing functions that have no undefined intervals. With $f(x)\in(a,b)$ and $g(x)\in(c,d)$, where $a<c$ and $b<c$ if there is a gap between $b$ and $c$ one must use manipulations to get...

$$\left({{\left(\left(f(x)\right)^{-1}+1\right)}^{\frac{\text{sgn}{\lceil(x-a-1)+.5}\rceil-\text{sgn}\lceil(x-b-1)+.5\rceil}{2}}}{{\left(\left(g(x)\right)^{-1}+1\right)}^{\frac{\text{sgn}{\lceil(x-c-1)}+.5\rceil-\text{sgn}\lceil(x-d-1)+.5\rceil}{2}}}-1\right)^{-1}$$

However this equation has an undefined region making it less artificial.

Now you can easily use this approach for more than one function. Here are the "switches" of my method as the exponents of functions.

$c_n(x)$ includes $f(x)$ and $g(x)$.

$\left(\left(\prod_{n=0}^{k}{\left({\left({c_n}(x)\right)}^{-1}+1\right)}^{{d_n}(x)}\right)-1\right)^{-1}\quad$ Union of all defined intervals ("undefining" unwanted intervals).

$d_0(x)=\frac{-\text{sgn}\lceil(x-a-1)+.5\rceil+1}{2}$ $(-\infty,a)$

$d_1(x)=\frac{\text{sgn}\lceil(x-a-1)+.5\rceil+1}{2}$ $(a,\infty)$

$d_2(x)=\frac{\text{sgn}\lceil(x-a-1)+.5\rceil-\text{sgn}\lceil(x-b-1)+.5\rceil}{2}$ $(a,b)$