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?

  • 1
    $\begingroup$ pretty bad; I filed this as a bug. $\endgroup$
    – user21
    Commented Sep 11, 2013 at 7:39

1 Answer 1


This was confirmed to be a bug.


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.