Error entering equation in DSolve

21

3

I entered a command incorrectly as follows:

    DSolve[{y'[x]=y[x]},y[x],x]

I am now experiencing:

    DSolve[{y'[x] == y[x]}, y[x], x]

During evaluation of In[26]:= DSolve::deqn: Equation or list of equations expected instead of True in the first argument {True}. >>

(* DSolve[{True},y(x),x] *)

How do I recover from this error. I've tried Clear[y'[x]]. That didn't work.

David

Posted 2014-01-13T06:11:06.923

Reputation: 14 143

3Remove[y] will do the trick. – ciao – 2014-01-13T06:25:49.847

That worked! Thanks. – David – 2014-01-13T06:43:56.493

Related: (373)

– Mr.Wizard – 2014-01-13T08:09:16.310

@rasher I caution against using Remove here! It will break any definitions that reference y, and it will alter even localized appearances of the Symbol, though the definitions may still work. Try e.g. fn[y_] := Sin[y]; Remove[y]; Definition[fn] – Mr.Wizard – 2014-01-13T08:34:50.870

@Mr.Wizard: Good point. Probably gave too quick-n-dirty, emphasis on dirty, solution. – ciao – 2014-01-13T08:38:08.137

Answers

20

It is for situations like this that Unset exists. :-)

After the mistaken Set operation:

y'[x] = "oh dear";

y'[x]
"oh dear"

Merely use:

y'[x] =. 

The definition is cleared:

y'[x]
y'[x]

Please see halirutan's answer for an explanation of why ClearAll[y] does not work here.

Mr.Wizard

Posted 2014-01-13T06:11:06.923

Reputation: 259 163

14

Very tricky mistake because hard to track down. The problem is that y'[x] parses as

Derivative[1][y][x]

Therefore, your assignment is not to the symbol y but to the symbol Derivative and since you have multiple call like f[][] it goes into its SubValues:

SubValues[Derivative]
(* {HoldPattern[Derivative[1][y][x]] :> y[x]} *)

Therefore, evaluate

SubValues[Derivative] = {};

and the sun shines again

DSolve[{y'[x] == y[x]}, y[x], x]
(* {{y[x] -> E^x C[1]}} *)

halirutan

Posted 2014-01-13T06:11:06.923

Reputation: 109 574

1If there are any other SubValues defined for Deritative this non-specific clearing will not be appropriate. In version 7 for example there are definitions for InverseLaplaceTransform by default. – Mr.Wizard – 2014-01-13T08:37:22.023

@Mr.Wizard Yes, you are of course right. My answer was rather an explanation what happens than the correct way to solve the problem. I upvoted your answer, since Unset is the way to go IMO – halirutan – 2014-01-13T17:07:00.717

I added a note to my answer directing readers to yours, because they are complementary. – Mr.Wizard – 2014-01-13T17:16:28.133

I just noticed that technically this answer was incorrect. Evaluation of y'[x] is not the issue as one can see with HoldPattern[y'[x]] = "bad"; rather y'[x] parses as Derivative[1][y][x], as seen with HoldForm @ FullForm[y'[x]]. I am editing this answer accordingly. – Mr.Wizard – 2016-05-01T17:39:54.917