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?
Please help. Thanks!
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!