# How to Integrate a function of an InterpolatingFunction?

Let u consider the case (given in Mathematica documentation as an example)

ysol = NDSolveValue[{y'[x] == y[x] Cos[x + y[x]], y == 1},y, {x, 0, 30}]


So, you can define a function of ysol like

y2 = FunctionInterpolation[soly[x]^2, {x, 0, x0}]


I'd like to integrate y2 and later define and Plot where y^2(x)=y2. As I said, I'd like to Plot z[x]. I dont know how to Integrate y2 symbolically in such a way we can Plot a function defined as above.

I'd like to refer question1 and question2 where this case were asked.

• e.g. NIntegrate[ysol[x]^2, {x, 0, 30}]. – AccidentalFourierTransform May 8 '18 at 19:39
• You could do yzsol = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y == 1, z'[x] == y[x]^2, z == 0},{y, z}, {x, 0, 30}], but that's not defining it "later." – Michael E2 May 8 '18 at 19:43
• You could use this answer to multiply ysol by itself. Then Integrate (not NIntegrate) can be used to compute the antiderivative of the result. – Michael E2 May 8 '18 at 19:46