This isn't particularly complicated. Varying the span generates graphs that are smooth or have an obvious bug. Not sure why.

This also happens if you vary the C_I_CentLim or the C_Inventory. I created this example so it is clearly happening.

The graph gets a sharp jag down, then returns to normal.

Something weird with density of points? I played with it for hours and can't get it to go away.

=============================================

restart;

L := 0;

C_Inventory := 1500;

C_I_CentLim := 0.001;

C_I_StartLim := C_Inventory*C_I_CentLim;

C_InV := Matrix(1000, 3); # This is so you can see values created only bobble slightly where the graph has a giant deviation.

iCounter := 0;

P_ScLdt := proc(t) local x, k; global L, C_Inventory, iCounter, C_InV; x := 0; k := 0.08; iCounter := iCounter + 1; L := C_Inventory*C_I_CentLim; x := 4.8 + L/(1 + exp(-k*(t - 2060))) + 0.050; C_InV[iCounter, 1] := L; C_InV[iCounter, 2] := C_Inventory; C_InV[iCounter, 3] := x; if 0 < x then C_Inventory := C_Inventory - x; return x; else return 0; end if; end proc;

# Show results 1800-2100 Problem.

pP_ScLdt := plot('P_ScLdt'(x), x = 1800 .. 2100, linestyle = dash, color = red, thickness = 3, axis = [gridlines = [colour = black, majorlines = 2]], legend = "Pg");

# Re-initialize.

L := 0;

C_Inventory := 1500;

C_I_CentLim := 0.001;

C_I_StartLim := C_Inventory*C_I_CentLim;

C_InV := Matrix(1000, 3);

iCounter := 0;

# Show that problem happens with a little shorter span

pP_ScLdt := plot('P_ScLdt'(x), x = 1850 .. 2100, linestyle = solid, color = black, thickness = 1, axis = [gridlines = [colour = black, majorlines = 2]], legend = "Pg");

# Re-initialize

L := 0;

C_Inventory := 1500;

C_I_CentLim := 0.001;

C_I_StartLim := C_Inventory*C_I_CentLim;

C_InV := Matrix(1000, 3);

iCounter := 0;

# Show problem goes away with a different interval 1900-2200

pP_ScLdt := plot('P_ScLdt'(x), x = 1900 .. 2200, linestyle = dash, color = blue, thickness = 3, axis = [gridlines = [colour = black, majorlines = 2]], legend = "Pg");

# Re-initialize

L := 0;

C_Inventory := 1500;

C_I_CentLim := 0.001;

C_I_StartLim := C_Inventory*C_I_CentLim;

C_InV := Matrix(1000, 3);

iCounter := 0;

# Enlarge the working interval of 1900-2200 to 1900-2300 and the problem returns, in a different place.

pP_ScLdt := plot('P_ScLdt'(x), x = 1900 .. 2300, linestyle = dash, color = blue, thickness = 3, axis = [gridlines = [colour = black, majorlines = 2]], legend = "Pg");

# Re-initialize

L := 0;

C_Inventory := 2000;

C_I_CentLim := 0.001;

C_I_StartLim := C_Inventory*C_I_CentLim;

C_InV := Matrix(1000, 3);

iCounter := 0;

# Enlarge the interval and it causes a larger set of jaggie deviations.

pP_ScLdt := plot('P_ScLdt'(x), x = 1800 .. 2800, linestyle = solid, color = blue, thickness = 1, axis = [gridlines = [colour = black, majorlines = 2]], legend = "Pg");