3
$\begingroup$

In Mathematica 8

NDSolve[{x[t] == 1, x[0] == 1}, x[t], {t, 0, 10}]

solves fine and returns

{{x[t]->InterpolatingFunction[{{0.,10.}},<>][t]}}

while Mathematica 9 raises

NDSolve::derivs: No derivatives of dependent variables were found in the equations. NDSolve is designed to solve differential or differential algebraic equations. Use NSolve or FindRoot to numerically solve algebraic equations. >>

I get the point, but is there maybe a way to restore the old behavior via NDSolve's options system?

$\endgroup$
3
  • 1
    $\begingroup$ Why would you want to restore the old behaviour? $\endgroup$
    – user21
    Apr 18, 2013 at 4:47
  • $\begingroup$ These type of equations systems come from model descriptions (not my own; why would anyone describe such a pointless system, right?) and I would like to be able to reliable solve them (without manual intervention). Anyways, I hacked my way around it (see my answer, which I will not accept ...). $\endgroup$ Apr 18, 2013 at 16:58
  • $\begingroup$ The old behavior allowed to solve equations of the form f[x,y[x]]==0, which cannot be solved by any other built-in methods. $\endgroup$
    – a user
    Dec 16, 2019 at 18:25

2 Answers 2

2
$\begingroup$

Based on an idea from my answer here:

Add a dummy derivative in a separate equation to trick Mathematica into not complaining:

NDSolve[{dummy'[t] == 0, x[t] == 1, x[0] == 1}, x[t], {t, 0, 10}]
(* {{x[t] -> InterpolatingFunction[{{0., 10.}}, <>][t]}} *)
$\endgroup$
1
$\begingroup$

This is not a real answer to my own question because I am not restoring NDSolve's old behavior. I am posting it in the (unlikely) case anyone has the same problem and is looking for a solution. The following function

catchMissingDeriv=Quiet[
    Check[
        ReleaseHold[#],
        NSolve[DeleteCases[#[[1,1]],_[0]==_],#[[1,2]]],
    {NDSolve::derivs}],
{NDSolve::derivs}]&;

catches NDSolve::derivs and switches to NSolve to calculate a solution. So,

catchMissingDeriv[Hold[NDSolve[{x[t] == 1, x[0] == 1}, x[t], {t, 0, 10}]]]

will return

{{x[t] -> 1.}}
$\endgroup$

Your Answer

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

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