Introducing new populations in mathematica graphs

Click For Summary

Discussion Overview

The discussion revolves around how to introduce different populations at various times in Mathematica graphs, specifically when using differential equations and NDSolve. Participants explore methods for plotting these populations with specific initial conditions and values at designated times.

Discussion Character

  • Technical explanation, Conceptual clarification, Debate/contested

Main Points Raised

  • One participant seeks a method to introduce populations with specific initial values at different times, expressing concern over precision when using very small initial values for a new population.
  • Another participant suggests using ListPlot with specified x and y coordinates, although this may not directly apply to the differential equations context.
  • A participant clarifies that they are using Plot with NDSolve for a set of differential equations and wants to visualize populations that start at zero but later take on a value of one.
  • Another participant proposes a method using InterpolatingFunction objects from NDSolve, suggesting a truncation function to plot populations based on time constraints.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the best method to achieve the desired plotting of populations at different times, with various approaches being discussed and no clear resolution presented.

Contextual Notes

There are limitations regarding the applicability of ListPlot for the participant's needs, as well as potential issues with the precision of initial values when introducing new populations.

pemb09
Messages
2
Reaction score
0
hi i was wondering if anyone knew how to introduce different populations at diffrent times on the same plot on mathematica?
Say i wanted population 1 have n = 10 at t=0, population 2 to have n=4 at t=0 and then introduce a new population at t=25 so that population 3 would have n= 0 initally but then n= 1 at t = 25.
Any ideas? the only way I've been gettting around it is to give population 3 really small values initially (e.g. 0.000000000001) but its not very precise.
 
Physics news on Phys.org
What kind of plot are you using? If you are using list plot then you can specify both x and y coordinates in your list. e.g.

a = Transpose[{Range[10], 2 Range[10]}];
b = Table[{x, 13}, {x, 3, 10}];
ListPlot[{a, b}]
 
I'm using Plot [ndsolve] of a set of differential equations. Listplot won't seem to make a list of solutions. I want one populations to have initial conditions of 0 but then at a further time stage to have a vlaue of 1 and see how that changes.
 
If popa and popb are the InterpolatingFunction objects that return from NDSolve then you can do the following:


truncate[f_InterpolatingFunction, t_] := If[f[[1, 1, 1]] <= t <= f[[1, 1, 2]], f[t]];
Plot[{truncate[popa, t], truncate[popb, t]}, {t, -1, 6}]
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 12 ·
Replies
12
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K