Cobb-Webbing Mathematica: Solving rNt+1

  • Context: Mathematica 
  • Thread starter Thread starter Dustinsfl
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary
SUMMARY

The discussion focuses on using Mathematica to create a cobweb plot for the function \( N_{t+1} = \frac{(1+r)N_t}{1+rN_t} \). Users shared Mathematica code for the CobwebPlot function but encountered errors related to coordinate pairs and function parameters. Specifically, the error "Coordinate {-1.2, {-0.5467269281236332}} should be a pair of numbers" indicates issues with input values. The discussion emphasizes the importance of ensuring that parameters \( a \), \( b \), and \( r \) are positive and correctly formatted in the function calls.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of cobweb plots in economic modeling
  • Knowledge of function syntax and parameter passing in Mathematica
  • Basic concepts of recursive functions and their graphical representation
NEXT STEPS
  • Explore advanced Mathematica graphics functions for better visualization techniques
  • Learn about recursive function definitions in Mathematica
  • Research the mathematical theory behind cobweb models in economics
  • Investigate error handling and debugging techniques in Mathematica
USEFUL FOR

Mathematica users, economists modeling dynamic systems, and programmers interested in graphical representations of recursive functions.

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 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
8
Views
4K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K