6
$\begingroup$

I was trying to obtain the same result of a differential equation with to different methods the first one is based on DSolve and the second one is based on NDSolve

a = Around[1, 0.1];
b := DSolve[{y'[x] + y[x] == a, y[0] == a}, y[x], {x, 0, 1090}]
f[x_] = y[x] /. b[[1]];
f[2]

And with this code I get that $f[2]=1\pm 0.1018$.

Now I want to get the same result but using NDSolve:

soli = NDSolve[{p'[x] + p[x] == a, p[0] == a}, p[x], {x, 0, 1090}]
solie[x_] = p[x] /. soli[[1]];
solie[2]

But the Mathematica V.12 gives as result

NDSolve::ndinnt: Initial condition 1.00±0.10 is not a number or a rectangular array of numbers.

The problem is that I need to use NDSolve because I have a complicated differential equation (not the equation that appears in the example)

$\endgroup$
4
  • 3
    $\begingroup$ I think you might have to integrate each end-point value separately (ParametricNDSolve[] could help with this). Of course, you're not guaranteed to capture the full range of the trajectories, but I don't think NDSolve is programmed to do it either. $\endgroup$ – Michael E2 Feb 8 '20 at 22:45
  • $\begingroup$ @Michael E2: The following soli = ParametricNDSolve[{p'[x] + p[x] == a, p[0] == a}, p, {x, 0, 1090}, {a}];p1 = p[Around[1, 0.1]] /. soli; p1[10] /. soli does not work for me in version 12.0 on Windows 10 32bit. $\endgroup$ – user64494 Feb 9 '20 at 17:38
  • $\begingroup$ @user64494 Why would you think it would work? I said "end-point" (i.e. a number), not Around[..]. $\endgroup$ – Michael E2 Feb 9 '20 at 18:28
  • $\begingroup$ @Michael E2: I tried that, no more and no less. $\endgroup$ – user64494 Feb 9 '20 at 18:38
1
$\begingroup$

You can use ParametricNDSolve to analyse how sensitive the solution is to parameters or initial conditions. There are multiple examples on the reference page under "Scope".

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.