0
$\begingroup$

I'm a new user and I have no idea how to solve the equation with a parameter by using NDSolve. For example consider following differential equation (DE):

sol = y'[x] + (y[x] + k) == 0;

where k is a parameter. I want to solve this DE and plot with k range.

Plot[y[x]./x->3, {k, 0, 10}]
$\endgroup$
  • 1
    $\begingroup$ ParametricNDSolve. $\endgroup$ – march Dec 9 '15 at 2:06
1
$\begingroup$

Since you have not specified an initial condition, I have decided to use it as one of the parameters. Modify as you see fit.

eq = y'[x] + (y[x] + k) == 0;
sol = ParametricNDSolveValue[{eq, y[0] == y0}, y, {x, 0, 3.5}, {k, y0}];
Plot[sol[k, 0][3], {k, 0, 10}]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you very much for your response. $\endgroup$ – H.Matsu Feb 1 '16 at 8:38

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.