FindRoot and piecewise

I want to solve numerically for a variable, let's say x. The equation that defines x has as argument a piecewise function that has its pieces depending on x itself. Moreover, some parts of this piecewise function are non-linear solutions of x. Let me try to better explain with an example.

The easiest example I could come up with is given below:

a = 1;
b = 0.1;
y = 1 - x[p] - (b + a - 1);
FG[p_?NumericQ] =
FindRoot[1 - x + a*Log[1 + x] - x[p] == 0, {x, 0.5}][[1, 2]];
V[p_?NumericQ] :=
Piecewise[{{p*x[p] + (1 - p)*y,
x[p] < 1 + a*Log[b + a] - (b + a - 1) &&
b*Log[b + a] < y < 1 + b*Log[b + a] - (b + a - 1)}, {p*
x[p] + (1 - p)*y,
x[p] < 1 + a*Log[b + a] - (b + a - 1) &&
y < b*Log[b + a]}, {p*x[p] + (1 - p)*y,
x[p] < 1 + a*Log[b + a] - (b + a - 1) &&
y >= 1 +
b*Log[b + a] - (b + a - 1)}, {p*(1 - FG[p] +
a*Log[1 + FG[p]]) + (1 - p)*y,
x[p] >= 1 + a*Log[b + a] - (b + a - 1) &&
b*Log[b + a] < y < 1 + b*Log[b + a] - (b + a - 1)}}, 0]

I want to solve:

p = 1;

FindRoot[x + a*Log[b + a] +
V[p] - (1 + 0.56*(1 - p) + 0.5*p), {x, -.5}]

This is not working and I can't figure out way. I have tried to inactivate FG[p] and or V[p] but it doesn't help. I am not sure what exactly I am doing wrong. Anyone has any idea?

• In the definition of FG, x is used as both a variable (x) and as a function (x[p]). Also, in this definition, what is Y? Should it be y? – Bob Hanlon Feb 5 '18 at 2:12
• Actually the x in FG is a function of p. Sorry for the misunderstand. Also, Y=1, that was a typo, I have just fixed. – Laura K Feb 5 '18 at 2:15
• You still have x used as both a variable and as a function. You cannot use FindRoot to solve for a function. – Bob Hanlon Feb 5 '18 at 2:21
• Uf, of course not! Thank you very much, Bob Harlon. My problem would be fixed by not having x[p] but x. – Laura K Feb 5 '18 at 2:29