Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

D.

share|improve this question
2  
Remove[y] will do the trick. –  rasher Jan 13 at 6:25
    
That worked! Thanks. –  David Jan 13 at 6:43
    
Related: (373) –  Mr.Wizard Jan 13 at 8:09
    
@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 Jan 13 at 8:34
    
@Mr.Wizard: Good point. Probably gave too quick-n-dirty, emphasis on dirty, solution. –  rasher Jan 13 at 8:38

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer

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

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]}} *)
share|improve this answer
1  
If 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 Jan 13 at 8:37
    
@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 Jan 13 at 17:07
    
I added a note to my answer directing readers to yours, because they are complementary. –  Mr.Wizard Jan 13 at 17:16

Your Answer

 
discard

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.