Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica being very strange

Tags:
  1. Jun 19, 2014 #1
    So when i use the following command, I get the following error
    DSolve[y'[x] - y[x] == 3, y[x], x]
    DSolve::deqn: Equation or list of equations expected instead of False in the first argument False. >>

    But when i change the variable y[x] and y'[x] to s[x] and s'[x], It works
    why is this?
    In[185]:= DSolve[s'[x] - s[x] == 3, s[x], x]

    Out[185]= {{s[x] -> -3 + E^x C[1]}}
     
  2. jcsd
  3. Jun 19, 2014 #2

    lurflurf

    User Avatar
    Homework Helper

    Most likely y[x] has been given some value earlier.
     
  4. Jun 19, 2014 #3
    I tried clearing it with clear all and clear [f,y,x] but it still doesn't work. I think it's strange, maybe y didn clear properly?
     
  5. Jun 19, 2014 #4

    phyzguy

    User Avatar
    Science Advisor

    Clear[y] won't clear y[x]. Try Clear[y[x]].
     
  6. Jun 19, 2014 #5
    Clear[y] does remove function definitions and Clear[y[x]] fails.

    Code (Text):
    In[1]:= y[x_] := 3 x

    In[2]:= ?y

    Out[2]= Global`y
    Out[2]= y[x_]:=3 x

    In[3]:= Clear[y]

    In[4]:= ?y

    Out[4]= Global`y

    In[5]:= y[x] := 3 x

    In[6]:= Clear[y[x]]

    Clear::ssym: y[x] is not a symbol or a string. >>
    As the IT Guy says, "Have you tried turning it off and turning it back on again" (possibly trying a ?y before anything else and then just entering that DSolve line and nothing else)?
     
  7. Jun 19, 2014 #6

    phyzguy

    User Avatar
    Science Advisor

    You're right, I'm wrong. Apologies for the mis-information.
     
  8. Jun 19, 2014 #7

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

     
  9. Jun 19, 2014 #8
    Code (Text):
    In[1]:= y[x_] := E^x

    In[2]:= DSolve[y'[x] == y[x], y[x], x]

    Out[2]= During evaluation of In[2]:= DSolve::dsfun: E^x cannot be used as a function. >>
    Out[2]= DSolve[True, E^x, x]

    In[3]:= Clear[y]

    In[4]:= DSolve[y'[x] == y[x], y[x], x]

    Out[4]= {{y[x] -> E^x C[1]}}
     
  10. Jun 20, 2014 #9
    I've always wanted to see a great example where Clear wasn't enough and Remove was necessary, not just some weird trick, but really interesting use that could be learned from and applied in useful ways in the future.
     
  11. Jun 20, 2014 #10
    Ah, I didn't know there was a remove function! Hopefully that works, I'll try it momentarily. And yes, I restarted Mathematica several times and it persisted.

    I tried it in the document where it wasn't working, and it didn't work. However i downlaoded another copy of the assignment and it worked with y[x]! Strange.
     
    Last edited: Jun 20, 2014
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook