Help in expressing derivative for this example

Let, $y = f(x) = x^2 -2$ be a function and $x$ is related to variable $b$ through the following operation: if $x \ge 0.5$, then $b = 1$ else $b=0$. Thus, the new relation is $g(x) = b = 1$, if $x \ge 0.5$.

I can take the derivative of $y$ w.r.t $x$ as $x' = dy/dx = 2x$. Can I write

$b' = 2g(x)$ or

$b' = g(x')$ ?

$g(.)$ is a discontinuous function, so I cannot find its derivative.

What is the correct way to express $b'$? I cannot understand how to express $b'$ in terms of $x$

It looks like your "$b$" is just another name for "$g$". So I would forget about $b$, it's just muddling the question.

You have two unrelated functions, $f$ and $g$:

$$f(x)=x^2-2$$ $$g(x)=\begin{cases} 0, & x<\frac12\\ 1, & x\geq\frac12 \end{cases}$$

$f$ is differentiable everywhere; $g$ is differentiable everywhere except at $x=\frac12$ (because it isn't continuous there--differentiable implies continuous); and

$$f'(x)=2x$$ $$g'(x)= 0, \,\,\,\, x\neq\tfrac12$$

(in other words, $\tfrac12$ is not in the domain of $g'$).

The function $g$ is "piecewise constant", so its derivative is "piecewise zero" (where it exists).