2
$\begingroup$

I want to plot the solutions to Solve for various values of the parameter m. The trouble is that I can't simply find the solution in terms of m, and then use Table and ListLinePlot, because for some values of m my quartic reduces to a quadratic and so then I get division by zero when I substitute m into the general solution. So what I need to do is have the code sub in different values of m into Solve, prior to solving. I was thinking I might want to use some kind of for loop but I wasn't sure the best way to code this in Mathematica. Any suggestions? Below are the equations I am subbing into Solve.

bet = 0.001
fc1 = (2/8)^2;
fc2 = (3/8)^2
N1p = N1*(1 - m) + N2*m;
N2p = N2*(1 - m) + N1*m;
b1 = 1 - bet*N1p - fc1;
b2 = 1 - bet*N2p - fc2;
ans = Solve[{N1 == N1p*b1*2, N2 == N2p*b2*2}, {N1, N2}]

I would like to plot m for values between 0 and 1, and I am only interested in the real solutions.

$\endgroup$
2
  • $\begingroup$ Neither d nor alph appear in the equations. No effort to ask a reliable question. $\endgroup$
    – Artes
    Aug 13, 2016 at 15:12
  • $\begingroup$ Sorry, I missed d and alph. In what other ways could I make this question more reliable? $\endgroup$
    – MathJo
    Aug 14, 2016 at 10:33

2 Answers 2

3
$\begingroup$

You don't say what range you want, and when $m<0.3$, there are multiple solutions, but you might want to do something like this?

ans = Table[
   Solve[{N1 == N1p*b1*2, N2 == N2p*b2*2}, {N1, N2}, Reals][[2]], {m, 
    0.3, 20, 0.1}];

ListPlot[{N1, N2} /. ans]

enter image description here

$\endgroup$
3
$\begingroup$
bet = 1/1000;
fc1 = (2/8)^2;
fc2 = (3/8)^2;
N1p = N1*(1 - m) + N2*m;
N2p = N2*(1 - m) + N1*m;
b1 = 1 - bet*N1p - fc1;
b2 = 1 - bet*N2p - fc2;

ans = {N1, N2} /. 
    Solve[{N1 == N1p*b1*2, N2 == N2p*b2*2}, {N1, N2}, Reals] // 
   Simplify;

Grid[
 Partition[
  ParametricPlot[#, {m, -20, 20},
     Frame -> True, Axes -> False,
     FrameLabel ->
      (Style[#, Bold, 14] & /@ {"N1", "N2"}),
     PlotPoints -> 150,
     AspectRatio -> 1,
     ImageSize -> 252] & /@ ans, 2]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.