N0 = 1000; N1 = 0.1 N0; s = 0.1; T1 = N0/1000; NtStep[t_, T_] := Piecewise[{{N0, t < T1}, {N1, T1 <= t <= (T1 + T)}, {N0, t > T}}] Tvalues = Range[0, N0/5, N0/1000]; Pfix[t0_, T_] := 1. - Exp[-4/ NIntegrate[ E^(-s (t - t0)) (2 NtStep[t0, T])/NtStep[t, T], {t, t0, N0}]] pfmine = Table[1/(N0 - Log[N0 s 0.5]/(0.5 s)) NIntegrate[ Pfix[t0, T], {t0, 0, N0 (*- (Log[N0 s 0.5]/(0.5 s))*)}], {T, 0, N0/5, N0/1000}] Pfixotto[t0_, T_] := 2/( NtStep[t0, T] NIntegrate[ E^(- s (t - t0)) 1/NtStep[t, T], {t, t0, N0}]) pfotto = Table[1/(N0 - Log[N0 s 0.5]/(0.5 s)) NIntegrate[ Pfixotto[t0, T], {t0, 0, N0 (*- (Log[N0 s 0.5]/(0.5 s))*)}], {T, 0, N0/5, N0/1000}] customTicksX = {{1/N0 2 \[Pi], Row[{"\!\(\*FractionBox[\(2 \[Pi]\), SubscriptBox[\(N\), \(0\)]]\ \) "}]}, {1/N0 100 \[Pi], Row[{"\!\(\*FractionBox[\(100 \[Pi]\), SubscriptBox[\(N\), \ \(0\)]]\)"}]}, {1/N0 25 \[Pi], Row[{"\!\(\*FractionBox[\(25 \[Pi]\), SubscriptBox[\(N\), \ \(0\)]]\)"}]}, {1/N0 400 \[Pi], Row[{"\!\(\*FractionBox[\(400\\\ \[Pi]\), SubscriptBox[\(N\), \(0\ \)]]\)"}]}}; a = ListPlot[Transpose@{Tvalues, pfmine}, PlotStyle -> Red, PlotRange -> All , FrameLabel -> {"growth rate", "Pfix"}, Frame -> True, LabelStyle -> Directive[Black, Bold, Medium], Frame -> Thickness[0.003]]; b = ListPlot[Transpose@{Tvalues, pfotto}, PlotStyle -> Blue, PlotRange -> All, FrameLabel -> {"growth rate", "Pfix"}, Frame -> True, LabelStyle -> Directive[Black, Bold, Medium], Frame -> Thickness[0.003]]; Show[a, b] 1 Answer
Your main problem consists in the behavior if NIntegrate. Consider:
Clear[f]; f[x_] := NIntegrate[t, {t, x, 10}] NIntegrate[f[z], {z, 0, 1 }] This gives error messages:
NIntegrate::nlim: t = z is not a valid limit of integration.
NIntgrate tries to simplify its argument f[z], that is symbolic, and obviously fails. To prevent this you need to ensure that f[z] is only evaluated if z is numeric. You can due this e.g. by:
Clear[f]; f[x_?NumericQ] := (NIntegrate[t, {t, 1, 10}]) NIntegrate[f[z], {z, 0, 1 }] Now there are no more error messages.
Applied to your code,you have this problem with: Pfix[t0_, T_]. Therefore define:
Pfix[t0_?NumericQ, T_] := 1. - Exp[-4/ NIntegrate[ E^(-s (t - t0)) (2 NtStep[t0, T])/NtStep[t, T], {t, t0, N0}]] Further, you have convergence problems in the integral in "pfmine" that may or may not give an inaccurate result. But I will not investigate this now.
- $\begingroup$ perfect! thank you $\endgroup$Sachin Kaushik– Sachin Kaushik2024-02-01 20:29:28 +00:00Commented Feb 1, 2024 at 20:29


pfmine = Table[1/(N0 - Log[N0 s 0.5]/(0.5 s)) NIntegrate[ Pfix[t0, T], {t0, 0, N0 (*- (Log[N0 s 0.5]/(0.5 s))*)}], {T, 0, N0/5, N0/1000}], I obtain an error "NIntegrate::nlim: t = t0 is not a valid limit of integration.". $\endgroup$