I am trying to solve coupled differential equations, inside which I have a function which I am getting by doing NIntegrate. The code is shown below:
x[z_] := NIntegrate[(x - 1)/x Sqrt[x] BesselK[1, z Sqrt[x]], {x,1, \[Infinity]}];
y[z_] := N[z^2*BesselK[2, z]];
s = NDSolve[{m1'[z] == x[z] * (m1[z] - 1),m2'[z] == (m1[z]/y[z] - 1)*m2[z]* 1/2* x[z], {m1[0.01] == y[0.01],m2[0.01] == 10^-14}}{m1, m2}, {z, 0.01, 10}]
But when I run this code I am getting following error massages:
NIntegrate::inumr: The integrand ((-1+x) BesselK[1,Sqrt[x] z])/Sqrt[x] has evaluated to non-numerical values for all sampling points in the region with boundaries {{[Infinity],1.}}.
NIntegrate::inumr: The integrand ((-1+x) BesselK[1,Sqrt[x] z])/Sqrt[x] has evaluated to non-numerical values for all sampling points in the region with boundaries {{[Infinity],1.}}.
General::stop: Further output of NIntegrate::inumr will be suppressed during this calculation.
NDSolve::nbnum1: The function value 0.01 Im[Sqrt[x]]==0 is not True or False when the arguments are {0.01,1.99995,1.10^-14,3.9987610^6,-2.21987*10^-24}.
NDSolve::nbnum1: The function value 0.01 Im[Sqrt[x]]==0 is not True or False when the arguments are {0.01,1.99995,1.10^-14,3.9987610^6,-2.21987*10^-24}.
NDSolve::nbnum1: The function value 0.01 Re[Sqrt[x]]<=0 is not True or False when the arguments are {0.01,1.99995,1.10^-14,3.9987610^6,-2.21987*10^-24}.
General::stop: Further output of NDSolve::nbnum1 will be suppressed during this calculation.
NDSolve::ecboo: The value of event condition function at z = 0.01` was not True or False. The event will be considered inactive.
NDSolve::ecboo: The value of event condition function at z = 0.010000000062299782` was not True or False. The event will be considered inactive.
NDSolve::ecboo: The value of event condition function at z = 0.010000000124599564` was not True or False. The event will be considered inactive.
General::stop: Further output of NDSolve::ecboo will be suppressed during this calculation.e here
Is it a problem in NIntegrate? How should I bypass these errors?
x[z_?NumericQ]:=...andy[z_?NumericQ]:=.... You also need to fix your braces in the NDSolve. It should be:s = NDSolve[{m1'[z] == x[z]*(m1[z] - 1), m2'[z] == (m1[z]/y[z] - 1)*m2[z]*1/2*x[z], m1[0.01] == y[0.01], m2[0.01] == 10^-14}, {m1, m2}, {z, 0.01, 10}]. This takes a couple of minutes to run and gives m1,m2 interpolating functions and a warning about stiffness at z == 0.010002. – flinty Aug 02 '20 at 16:00Remove["Global`*"]first because the original functions are still defined. – flinty Aug 02 '20 at 16:36ClearAll[x,y]did not. – PaulCommentary Aug 02 '20 at 16:44?NumericQis a pattern test that checks the argument is numeric. This is supposed to prevent functions like NDSolve, NIntegrate, NMinimize/NMaximize etc. from doing symbolic manipulation/preprocessing by changing evaluation order. See here too: https://support.wolfram.com/12502 - yes you need it for the multivariate case too. You can also use it to test higher rank objects https://mathematica.stackexchange.com/a/19600/72682 – flinty Aug 02 '20 at 16:50NIntegrate– Bob Hanlon Aug 02 '20 at 18:39NDSolve"calling"NIntegratewith a symbolic parameter? – PaulCommentary Aug 02 '20 at 18:46