View Single Post
jackmell
jackmell is offline
#3
Feb29-12, 11:38 AM
P: 1,666
Quote Quote by phyzguy View Post
The output of NDSolve (mysol) is a list. You need to take the first element of it in your myy function definition, as follows:

In[25]:= mysol = NDSolve[{y'[x] == x, y[0] == 1}, y, {x, 0, 1}]

In[26]:= myy[x_] := Evaluate[y[x] /. mysol][[1]];

In[27]:= myf[x_] := Piecewise[{{myy[x], 0 < x <= 1}, {x^2, x > 1}}];

In[28]:= NIntegrate[myf[x], {x, 0, 2}]

Out[28]= 3.5
Ok. Thanks a bunch. It's working now. :)