0
$\begingroup$

So I want to use the NestList[] function, but i'm not sure how to achieve this for a system of equations like I have here $P_{n+1} = (rP_n +sQ_n)(1 - \frac{P_n + Q_n}{100}), \; Q_{n+1} = P_n$. Does anyone know how to do this?

I have (where x is P and y is Q)

PP[s_, x_, y_] := (rx + s y) (1 - (x + y)/100)
QQ[x_] := x

where r is a constant and s is a variable. This means the equilibrium of this system will depend on s.

but don't know how to set up the NestList[] function for this. If this was one function I would do something like NestList[f,x,5]. So in the end I want to have a list of coordinates.

As another example of what I want, see the first example in this

$\endgroup$
3
  • $\begingroup$ What do you mean by (where x is P and y is Q)? $\endgroup$ Mar 21, 2016 at 15:18
  • $\begingroup$ @Dr.belisarius Sorry, it seems I had neglected to include the original system I was given. I meant that I am using the symbol $x$ instead of $P$ and the symbol $y$ instead of $Q$ for my Mathematica code. It doesn't really matter I suppose. $\endgroup$
    – Ozera
    Mar 21, 2016 at 15:21
  • $\begingroup$ I'm not sure I understand your question @JasonB. The QQ[] function represents the $Q_{n+1} = P_n$ equation. $\endgroup$
    – Ozera
    Mar 21, 2016 at 15:30

3 Answers 3

1
$\begingroup$

You have a recurrence relation, so use RecurrenceTable

RecurrenceTable[{Q[n + 1] == P[n],
  P[n + 1] == (r P[n] + s Q[n]) (1 - (P[n] + Q[n])/100),
  P[0] == 1,
  Q[0] == 1}, {P, Q}, {n, 2}]

(* {{1, 1}, {(49 (r + s))/50, 1}, 
    {(s + 49/50 r (r + s)) (1 + 1/100 (-1 - (49 (r + s))/50)), (49 (r + s))/50}} *)
$\endgroup$
2
  • $\begingroup$ Very neat! I didn't know about the RecurrenceTable command. It seems like what you wrote gives the exact same output as what @Dr.Belisarius wrote. $\endgroup$
    – Ozera
    Mar 21, 2016 at 15:39
  • 1
    $\begingroup$ @Ozera Next time ask what you want. And if you don't know what you want, say it. $\endgroup$ Mar 21, 2016 at 15:50
2
$\begingroup$
NestList[Function[{p, q}, {(r p + s q) (1 - (p + q)/100), p}][Sequence @@ #] &, 
        {1, 1}, 2]

(* {{1, 1}, {(49 (r + s))/50, 1}, 
    {(s + 49/50 r (r + s)) (1 + 1/100 (-1 - (49 (r + s))/50)), (49 (r + s))/50}}*)
$\endgroup$
1
  • 1
    $\begingroup$ Thank you for answering! Do you mind explaining what [Sequence @@ #] & does? I am not familiar with it. $\endgroup$
    – Ozera
    Mar 21, 2016 at 15:31
0
$\begingroup$
mat[r_, s_, n_, i_] :=
 With[{mx = {{r, s}, {1, 0}} - {{1/100, 1/100}, {0, 0}}},
  MatrixPower[mx, n].i]

e.g.

With[{n = Range[0, 4]}, 
 TableForm[Expand@mat[r, s, #, {1, 1}] & /@ n, 
  TableHeadings -> {n, {"P", "Q"}}, TableAlignments -> Center]]

enter image description here

or

DiscretePlot[Evaluate@mat[1, 1, x, {1, 1}], {x, 0, 5}, 
 PlotLegends -> {"P", "Q"}]

enter image description here

Apologies for any errors or misunderstanding.

$\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.