Mathematica Cobb-Webbing Mathematica: Solving rNt+1

  • Thread starter Thread starter Dustinsfl
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
The discussion focuses on constructing a Cobb-Webb diagram in Mathematica for the equation N_{t+1} = (1+r)N_t / (1+rN_t). Users are seeking clarification on existing Mathematica code and how to adapt it for their specific functions. Questions arise regarding the meaning of parameters after the ampersand symbol and the significance of the error message related to coordinate pairs. The error occurs when inputting specific values for r, a, and b, indicating a potential issue with the function's output format. Understanding the code structure and ensuring proper input formats are essential for successful implementation.
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:

Similar threads

Replies
2
Views
1K
Replies
1
Views
2K
Replies
19
Views
2K
Replies
1
Views
1K
Replies
1
Views
3K
Back
Top