I have a problem with plotting the integral of an NDSolve solution.
I have attached the code for a simple 2nd order linear ODE to be solved by NDSolve and then to be integrated by NIntegrate.
I would you appreciate if you could give me a help to overcome the problem.
My best regards.
Hadi
f := NDSolve[{x''[t] + 2 x'[t] + x[t] == 0, x[0] == 1, x'[0] == -4},
x, {t, 0, 2}]
g[t_] := NIntegrate[Exp[y*Evaluate[x[t] /. f]], {y, 1, 10}]
Plot[g[t], {t, 0, 2}]
And hear are the errors
NDSolve::dsvar: 0.00004085714285714285` cannot be used as a variable. >>
ReplaceAll::reps: {NDSolve[{x[0.0000408571]+2 (x^[Prime])[0.0000408571]+(x^[Prime][Prime])[0.0000408571]==0,x[0]==1,(x^[Prime])[0]==-4},x,{0.0000408571,0,2}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
NIntegrate::inumr: The integrand E^(y (x[0.0000408571]/. NDSolve[{x[<<1>>]+Times[<<2>>]+(<<1>>^(<<1>>))[<<1>>]==0,x[0]==1,(x^[Prime])[0]==-4},x,{0.0000408571,0,2}])) has evaluated to non-numerical values for all sampling points in the region with boundaries {{1,10}}. >>
NDSolve::dsvar: 0.00004085714285714285` cannot be used as a variable. >>
ReplaceAll::reps: {NDSolve[{x[0.0000408571]+2 (x^[Prime])[0.0000408571]+(x^[Prime][Prime])[0.0000408571]==0,x[0]==1,(x^[Prime])[0]==-4},x,{0.0000408571,0,2}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
NIntegrate::inumr: The integrand E^(y (x[0.0000408571]/. NDSolve[{x[<<1>>]+Times[<<2>>]+(<<1>>^(<<1>>))[<<1>>]==0,x[0]==1,(x^[Prime])[0]==-4},x,{0.0000408571,0,2}])) has evaluated to non-numerical values for all sampling points in the region with boundaries {{1.,10.}}. >>
NDSolve::dsvar: 0.04085718367346938` cannot be used as a variable. >>
General::stop: Further output of NDSolve::dsvar will be suppressed during this calculation. >>
ReplaceAll::reps: {NDSolve[{x[0.0408572]+2 (x^[Prime])[0.0408572]+(x^[Prime][Prime])[0.0408572]==0,x[0]==1,(x^[Prime])[0]==-4},x,{0.0408572,0,2}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
General::stop: Further output of ReplaceAll::reps will be suppressed during this calculation. >>
NIntegrate::inumr: The integrand E^(y (x[0.0408572]/. NDSolve[{x[<<1>>]+Times[<<2>>]+(<<1>>^(<<1>>))[<<1>>]==0,x[0]==1,(x^[Prime])[0]==-4},x,{0.0408572,0,2}])) has evaluated to non-numerical values for all sampling points in the region with boundaries {{1,10}}. >>
General::stop: Further output of NIntegrate::inumr will be suppressed during this calculation. >>