# Solve implicit equations, input and plot the solution in a different equation

I have two implicitly defined variables, $$\sigma_D$$ and $$\sigma_M$$ one of which is a function of the parameter $$v$$. In particular, $$\sigma_D = F(\sigma_D,v)$$ where $$F(\sigma_D,v)=0$$ if $$c_D < -0.1$$, $$F(\sigma_D,v)=\frac{c_D+0.1}{2.1}$$ if $$-0.1 \leq c_D \leq 2$$ and $$1$$ for $$c_D > 2$$, and

$$c_{D} =0.5((\frac{\sigma_D^2 + (1-\sigma_D)(2-\sigma_D)(.6)^2 }{\sigma_D^2 + (2-\sigma_D)^2 (.6)^2} - \frac{1-\sigma_D}{2-\sigma_D})(\sigma_D - (2-\sigma_D)(.6)^2)+1) -0.5v$$

$$\sigma_M = \frac{0.4}{2.1} \big[\frac{\sigma_M + .6(1-\sigma_M) }{\sigma_M + .6(1-\sigma_M) + 0.6} - \frac{1-\sigma_M}{2-\sigma_M}\big] + \frac{.1}{2.1}.$$

I need to get the solutions for $$v \in [0,5]$$, then replace those values in the following two equations: $$V_{1} = \frac{1}{2}(1+0.6\mu) + \frac{1}{2}[\sigma_M \mu + (1-\sigma_M)(1+ 0.6\mu )]$$

$$V_{2} = \frac{1}{4}(1+0.6\mu) + \frac{1}{4}[1 + 0.6\mu (\sigma_D + (1-\sigma_D))] 2 + \frac{1}{4}[(1-\sigma_D)^2 (1+ 0.6\mu)) + 2 \sigma_D (1-\sigma_D)(1+\mu) + \sigma^{2}_D \mu]$$

Finally, I need to plot both $$V_{1}$$ and $$V_{2}$$ on the same graph in the $$\mu-v$$ space with $$\mu \in [0,5]$$ and $$v \in [0,5]$$, or at least to produce a graph that shows when $$V_2 > V_1$$.

    c=2;
e=0.1;
f=0.6;
gD=(sD^2 + (1 - sD) f^2 (2 - sD))/(sD^2 + f^2 (2 - sD)^2);
XD=(1 - sD)/(2 - sD);
cD = -0.5 v + 0.5 ((gD - XD) (sD - (2 - sD) f^2) + (2 - sD) (1 - XD));
FD = Piecewise[{{0, cD <= -e}, {(cD + e)/(c + e), cD > -e && cD < c}, {1,
cD >= c}}];
gM= (sM + (1 - sM) f)/(sM + (1 - sM) f + f);
XM=(1 - sD)/(2 - sD);
RHSM=(1 - f) (gM - XM);
V1=.5(1+.6m) + .5(sM m + (1-sM)(1+.6m));
V2-.25(1+.6m) + .5[1 + m(sD + .6(1-sD))] + .25[(1-sD)^2(1+.6m) + 2 sD (1-sD)(1+m) + sD^2 m ];
Clear[e,c,f,gD,XD,cD,FD,gM,XM,RHSM];


I know how to get solutions for a particular value of v, but not how to input automatically the solution into $$V_1$$ and $$V_2$$ and then compare them in the $$\mu - v$$ space. Note also that $$\sigma_M \in [0,1]$$ and $$\sigma_D \in [0,1]$$.

Any help will be greatly appreciated! Thanks a lot!!

• There is no definition of $\mu$. Add this definition and write both functions $V_1, V_2$. $\sigma_M$ is it just a number (root of the equation)? – Alex Trounev Sep 20 '19 at 3:37
• $\mu$ is merely a scalar and lies between 0 and 5. I have edited the above to reflect the change -- it is not a function. $v$ is also a scalar and lies between 0 and 5. Finally, yes, $\sigma_M$ is the root of the equation and does not depend on $v$. – A. Pant Sep 20 '19 at 8:57
• This is strange. I got the roots of the equation from Mathematica, and they turn out to be $-2.90447$, $0.051765$ and $1.90033$. Although, I apologize for not being clear earlier that both $\sigma_D$ and $\sigma_M$ should be between $0$ and $1$.  Format[s] := [Sigma]; f = 0.6; c = 2; e = 0.1; gR = (s + (1 - s) f)/(s + (1 - s) f + f); X = (1 - s)/(2 - s); TM = (1 - f) (gR - X); Solve[(TM + e)/(c + e) == s, s]  – A. Pant Sep 20 '19 at 16:46
• Yes, you're right, the roots are there {{s -> -2.90447}, {s -> 0.051765}, {s -> 1.90033}}. Need to take 0.051765? Can you add this to your message? And write down the expression for V1,V2. – Alex Trounev Sep 20 '19 at 17:17
• Done! Let me know if there any further clarifications. Thanks a ton. – A. Pant Sep 20 '19 at 17:35

You can use this code here (need to fix [] to () in V2 as Bob suggested)

c = 2;
e = 0.1;
f = 0.6;
gD = (sD^2 + (1 - sD) f^2 (2 - sD))/(sD^2 + f^2 (2 - sD)^2);
XD = (1 - sD)/(2 - sD);
cD = -0.5 v + 0.5 ((gD - XD) (sD - (2 - sD) f^2) + (2 - sD) (1 - XD));
FD = Piecewise[{{0, cD <= -e}, {(cD + e)/(c + e),
cD > -e && cD < c}, {1, cD >= c}}];
gM = (sM + (1 - sM) f)/(sM + (1 - sM) f + f);
XM = (1 - sD)/(2 - sD);
RHSM = (1 - f) (gM - XM);
V1 = .5 (1 + .6 m) + .5 (sM m + (1 - sM) (1 + .6 m));
V2 = .25 (1 + .6 m) + .5 (1 +
m (sD + .6 (1 - sD))) + .25 ((1 - sD)^2 (1 + .6 m) +
2 sD (1 - sD) (1 + m) + sD^2 m);

sig = Table[{x, sD /. FindRoot[sD == FD /. v -> x, {sD, 1}]}, {x,
0, .5, .005}];