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[Y - 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?