Cobb-Webbing Mathematica: Solving rNt+1

  • Context: Mathematica 
  • Thread starter Thread starter Dustinsfl
  • Start date Start date
  • Tags Tags
    Mathematica
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
Dustinsfl
Messages
2,217
Reaction score
5
How can I get Mathematica to construct a cobb webb for

$$
N_{t+1} = \frac{(1+r)N_t}{1+rN_t}
$$
 
Physics news on Phys.org
dwsmith said:
How can I get Mathematica to construct a cobb webb for

$$
N_{t+1} = \frac{(1+r)N_t}{1+rN_t}
$$

I found some Mathematica code but I don't quite understand it

Code:
[FONT=Courier][B]ClearAll[CobwebPlot][/B]
[FONT=Courier][B]SetAttributes[CobwebPlot, HoldAll][/B]
[FONT=Courier][B]CobwebPlot[f_, start_?NumericQ, n_, {xrange:{xmin_, xmax_}, yrange:{_, _}}]:=Module[{[/B][FONT=Courier][B]cob[/B][FONT=Courier][B], [/B][FONT=Courier][B]x[/B][FONT=Courier][B], [/B][FONT=Courier][B]g1[/B][FONT=Courier][B], [/B][FONT=Courier][B]coor[/B][FONT=Courier][B]},[/B]
[FONT=Courier][B]    [/B][FONT=Courier][B]cob[/B][FONT=Courier][B] = NestList[[/B][FONT=Courier][B][I]f[/I][/B][FONT=Courier][B], [/B][FONT=Courier][B][I]start[/I][/B][FONT=Courier][B], [/B][FONT=Courier][B][I]n[/I][/B][FONT=Courier][B]];[/B]
[FONT=Courier][B]    [/B][FONT=Courier][B]coor[/B][FONT=Courier][B] = Partition[Riffle[[/B][FONT=Courier][B]cob[/B][FONT=Courier][B], [/B][FONT=Courier][B]cob[/B][FONT=Courier][B]], 2, 1];[/B]
[FONT=Courier][B]    [/B][FONT=Courier][B]coor[/B][FONT=Courier][B][[1, 2]] = 0;[/B]
[FONT=Courier][B]    [/B]
[FONT=Courier][B]    [/B][FONT=Courier][B]g1[/B][FONT=Courier][B] = Graphics[{Red, Line[[/B][FONT=Courier][B]coor[/B][FONT=Courier][B]]}];[/B]
[FONT=Courier][B]    Show[{Plot[{[/B][FONT=Courier][B]x[/B][FONT=Courier][B],[/B][FONT=Courier][B][I]f[/I][/B][FONT=Courier][B][[/B][FONT=Courier][B]x[/B][FONT=Courier][B]]},{[/B][FONT=Courier][B]x[/B][FONT=Courier][B],xmin,xmax}, PlotStyle->{{Thick,Black}, Black}, PlotRange->{xrange,yrange}],[/B][FONT=Courier][B]g1[/B][FONT=Courier][B]}]
[/B]
[FONT=Courier][B]CobwebPlot[-4(-1 + [/B][FONT=Courier][B][I]#[/I][/B][FONT=Courier][B]) [/B][FONT=Courier][B][I]#[/I][/B][FONT=Courier][B] -3([/B][FONT=Courier][B][I]#[/I][/B][FONT=Courier][B] -0.6)^3&, -0.318,10, {{-2, 2}, {-1,2}}][/B]
[FONT=Courier][B]][/B]

What are the #? How would I all my function above to use this code?

Thanks.
 
Can someone explain what is after the ampersand symbol, -0.318?

What does this error mean?
Coordinate {-1.2, {-0.5467269281236332}} should be a pair of numbers, or a Scaled or Offset form.

I get this for
Code:
CobwebPlot[.2 #/(1 + .3 #)^{3} &, -1.2, 50, {{-2, 2}, {-2, 2}}]

.2 = r, .3 = a, and 3 = b. The restriction is a,b,r> 0. I tried many different options for a, b, r and the error is the same.
 
Last edited: