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}]
  • 1
    $\begingroup$ ParametricNDSolve. $\endgroup$
    – march
    Dec 9, 2015 at 2:06

1 Answer 1


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

  • $\begingroup$ Thank you very much for your response. $\endgroup$
    – Mksjd
    Feb 1, 2016 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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