Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It seems like there is a problem with differentiating a ParametricNDSolve object when the underlying system contains an matrix differential equation.

Create a simple ParametricNDSolveValue object which returns x[2], depending on parameter k.

pfun1 = ParametricNDSolveValue[{x'[t] == -k*x[t], x[0] == 10}, x[2], {t, 0, 10}, k]
ParametricFunction[SequenceForm["<", ">"]]

Now we have the same system but we add a matrix differential equation independent of the state x[t]. Here P[t] should be zero for all t due to the inital condition.

pfun2 = ParametricNDSolveValue[{x'[t] == -k*x[t], x[0] == 10, 
P'[t] == P[t], P[0] == {{0, 0}, {0, 0}}}, x[2], {t, 0, 10}, k]
ParametricFunction[SequenceForm["<", ">"]]

We can take out the values for k=0.4.


Now we differentiate the systems and take out the value for k=0.4.

Thread::tdlen: Objects of unequal length in {{0.},{0.},{0.},{0.},{0.}}+{{0.},{-10.}} cannot be combined. >>*
Experimental`NumericalFunction::nlnum1: The function value {{{0.},{-10.}}+{{0.},{0.},{0.},{0.},{0.}}} is not a list of numbers with dimensions {5} when the arguments are {0.,{0.,0.,0.,0.,10.},{0.4},{{0.},{0.},{0.},{0.},{0.}}}.

The derivative of the ParametricNDSolveValue object seems to fail when there is a matrix differential equation in the system.

Is this a bug?

share|improve this question
pretty bad; I filed this as a bug. – user21 Sep 11 '13 at 7:39

This was confirmed to be a bug.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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