Cobb-Webbing Mathematica: Solving rNt+1

  • Mathematica
  • Thread starter Dustinsfl
  • Start date
  • Tags
    Mathematica
In summary, the conversation is about using Mathematica to construct a cobb webb for the equation $N_{t+1} = \frac{(1+r)N_t}{1+rN_t}$ and the code provided for the task. The person is asking about the use of # symbol and how to incorporate their function into the code. They also mention getting an error related to the coordinates when trying to use the code with different values for the variables.
  • #1
Dustinsfl
2,281
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
  • #2
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:
[COLOR=#333333][FONT=Courier][B]ClearAll[CobwebPlot][/B][/FONT][/COLOR]
[COLOR=#333333][FONT=Courier][B]SetAttributes[CobwebPlot, HoldAll][/B][/FONT][/COLOR]
[COLOR=#333333][FONT=Courier][B]CobwebPlot[f_, start_?NumericQ, n_, {xrange:{xmin_, xmax_}, yrange:{_, _}}]:=Module[{[/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]cob[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B], [/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]x[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B], [/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]g1[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B], [/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]coor[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B]},[/B][/FONT][/COLOR]
[COLOR=#333333][FONT=Courier][B]    [/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]cob[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B] = NestList[[/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B][I]f[/I][/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B], [/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B][I]start[/I][/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B], [/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B][I]n[/I][/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B]];[/B][/FONT][/COLOR]
[COLOR=#333333][FONT=Courier][B]    [/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]coor[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B] = Partition[Riffle[[/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]cob[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B], [/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]cob[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B]], 2, 1];[/B][/FONT][/COLOR]
[COLOR=#333333][FONT=Courier][B]    [/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]coor[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B][[1, 2]] = 0;[/B][/FONT][/COLOR]
[COLOR=#333333][FONT=Courier][B]    [/B][/FONT][/COLOR]
[COLOR=#333333][FONT=Courier][B]    [/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]g1[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B] = Graphics[{Red, Line[[/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]coor[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B]]}];[/B][/FONT][/COLOR]
[COLOR=#333333][FONT=Courier][B]    Show[{Plot[{[/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]x[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B],[/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B][I]f[/I][/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B][[/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]x[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B]]},{[/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]x[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B],xmin,xmax}, PlotStyle->{{Thick,Black}, Black}, PlotRange->{xrange,yrange}],[/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B]g1[/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B]}]
[/B][/FONT][/COLOR]
[COLOR=#333333][FONT=Courier][B]CobwebPlot[-4(-1 + [/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B][I]#[/I][/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B]) [/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B][I]#[/I][/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B] -3([/B][/FONT][/COLOR][COLOR=#428957][FONT=Courier][B][I]#[/I][/B][/FONT][/COLOR][COLOR=#333333][FONT=Courier][B] -0.6)^3&, -0.318,10, {{-2, 2}, {-1,2}}][/B][/FONT][/COLOR]
[COLOR=#333333][FONT=Courier][B]][/B][/FONT][/COLOR]

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

Thanks.
 
  • #3
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:

FAQ: Cobb-Webbing Mathematica: Solving rNt+1

What is Cobb-Webbing Mathematica?

Cobb-Webbing Mathematica is a mathematical model used to study the dynamics of economic systems. It was developed by American economist Alfred Marshall Cobb and mathematician Paul H. Douglas in the 1920s.

What does "rNt+1" represent in Cobb-Webbing Mathematica?

"rNt+1" represents the population size in a given time period (t+1) in the model. It is a variable that is used to measure the growth or decline of populations in an economic system.

How does Cobb-Webbing Mathematica solve for rNt+1?

Cobb-Webbing Mathematica uses a system of difference equations to predict the changes in population size over time. It takes into account factors such as birth rates, death rates, and resource availability to calculate the value of rNt+1.

What are the applications of Cobb-Webbing Mathematica?

Cobb-Webbing Mathematica can be used to analyze and predict the behavior of economic systems, such as markets, industries, and populations. It has also been used to study the effects of government policies and external factors on economic systems.

Are there any limitations to using Cobb-Webbing Mathematica?

While Cobb-Webbing Mathematica is a useful tool for studying economic systems, it has its limitations. It assumes that all individuals and firms act rationally and that there is perfect information in the market, which may not always be the case in reality. It also does not take into account external factors such as natural disasters or political events, which can greatly impact economic systems.

Similar threads

Replies
2
Views
581
Replies
1
Views
831
Replies
9
Views
862
Replies
19
Views
1K
Replies
1
Views
550
Replies
1
Views
2K
Back
Top