Message Boards Message Boards

How do I NIntegrate solutions to Differential Equations?

Posted 2 years ago

How do I use NIntegrate solutions to Differential Equations?

IntegratedDifferenceFunction[I_, O_] := 
 NIntegrate[I[U] - O[U], {U, 0, 2*Pi}]

m = DSolve[y''[x] + y[x] == 0, y[x], x]
n = DSolve[y''[x] + y'[x] == 0, y[x], x]

IntegratedDifferenceFunction[m, n]

I want to compute the difference between two Ordinary Differential Equation Solutions from 0 to 2*Pi, It can be any ODE's. Is there also a way to apply the function for Numerical Solutions that were solved using NDSolve?

    m = NDSolve[y''[x] + y[x] == 0, y[x], {x,0,2*Pi}]
    n = NDSolve[y''[x] + y'[x] == 0, y[x], {x,0,2*Pi}]
2 Replies

Do you perhaps mean something like this?

IntegratedDifferenceFunction[fi_, fo_] :=  NIntegrate[fi - fo, {x, 0, 2*Pi}]

g1 = DSolve[{y''[x] + y[x] == 0, y[0] == .8, y'[0] == -.2}, y, x]
g2 = DSolve[{y''[x] + y'[x] == 0, y[0] == .8, y'[0] == -.2}, y, x]
fgi = y[x] /. g1[[1, 1]]
fgo = y[x] /. g2[[1, 1]]
IntegratedDifferenceFunction[fgi, fgo]
POSTED BY: Hans Dolhaine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract