# How to put the result of NDSolve in a function?

I have solved an ODE with NDSolve, and put the result in S:

S = NDSolve[{y'[x]==(y[x]^4+y[x]+1)^(1/2),y[0]==0}, y, {x, 0, 100}]


But i don't want to plot y[x] directly. I want to define a new function of y[x] and plot that function. So i tried this:

func1[x_] := (Evaluate[y[x]/.S])^-3;
Plot[func1[x], {x, 0, 100}]


But that doesn't work! I understand why this should be wrong but i don't know what's the correct way to do this.

• What do you mean by "that doesn't work"? It produces a plot for me. I do get an error about your differential equations, but the basic syntax you have is fine – Jason B. Nov 24 '15 at 9:36
• @JasonB Actually i have simplified my ODE here a little. And you're right, i tested it now and i got a result too. But i still can't get the result from my original ODE. i get an error like this on defining the new function: SetDelayed::write: "Tag Times in (2.27621*10^-27/(y^3))[m_] is Protected. Now at least i know the problem is not with the syntax. thanks. – Mostafa Nov 24 '15 at 9:55
• You forgot to clear previous definitions if you're hitting that error. Look up Clear[]. – J. M.'s ennui Nov 24 '15 at 10:04
• @JasonB Oh, thanks a lot. That solved the problem. – Mostafa Nov 24 '15 at 10:28

 S=NDSolve[{y'[x]==(y[x]^2+y[x]+1)^(1/2),y[0]==0},y,{x,1,8}];

func1[x_?NumericQ] := ...