\documentclass[a4paper,border=2pt]{standalone}
\usepackage{tikz}

\usetikzlibrary{math,calc,intersections,arrows.meta}
\tikzset{every picture/.style={samples=300,smooth,line join=round,thick,>=Stealth,font=\small}}

\begin{document}

  \begin{tikzpicture}[scale=.45]
    \tikzmath{\ai=2;\aii=-1;}
    \draw[->](-2.5,0)--(3.5,0)node[below]{$x$};
    \draw[->](0,-2)--(0,3.5)node[right]{$y$};
    \coordinate[label=45:$O$](O)at(0,0);
    \path[cyan,name path=fx,draw,domain=-2.5:2.5]plot(\x,{abs(\x)-1});
    \path[blue,name path=gx,draw,domain=0.5:3.5]plot(\x,{\x*\x-2*\ai*\x+\ai+2});
    \path[name intersections={of=fx and gx,by={[label=]A}}] let \p1=(A) in
    \pgfextra
      \xdef\xA{\x1/28.45274}\xdef\yA{\y1/28.45274}
    \endpgfextra;
    \draw[red,domain=-2.5:\xA]plot(\x,{abs(\x)-1});
    \draw[red,domain=\xA:3.5]plot(\x,{\x*\x-2*\ai*\x+\ai+2});
    \node[below]at(-1.2,0){$-1$};
    \node[below]at(1,0){$1$};
    \node[below]at(2,0){$2$};
  \end{tikzpicture}

\end{document}

