Message Boards Message Boards

0
|
5402 Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

DSolve - Why is example code giving me incorrect results when run?

Posted 5 years ago

I am new to Mathematica and am particularly struggling with its differential equation solving capacity. Most recently, I have encountered a completely baffling issue where even the example code straight from the included documentation does not behave the same way when I evaluate it in a notebook. At right in the reference documentation for DSolve; at left is what happens when I paste exactly those same equations into a fresh notebook. Notably, one of them even throws an error! I am completely at a loss for what is going on here. Has anyone else encountered this issue?

A screenshot of the notebook in question, with the docs on the right and the output on the left

POSTED BY: Maxwell Greason
5 Replies

If you do something like:

x=1

That means "whenever you see x, replace it with 1". You thus cannot subsequently use x as a free variable in your session.

POSTED BY: John Doty

Could you post a notebook where your problem occurrs?

POSTED BY: Hans Dolhaine

Hans,

I am new to DSolve, and I had a similar problem too. Clear[x,y] followed by the DSolve worked. I cannot explain why I had to give Clear[x,y] command. May be someone will explain.

Vijay

POSTED BY: Vijay Vemuri

You could try to quit the kernel : Evaluation -> Quit Kernel.

That leaves your notebook intact, but seems to forget everything that had happended before ( the definitions you might have to use as well).

POSTED BY: Hans Dolhaine

Update: When I saved the notebook, completely closed Mathematica, and reopened it, the code gave the correct output once re-evaluated, but I have no idea what went wrong initially, or how to prevent it happening again. So, presumably it was some lasting remnant of a previous action - but if it was, I have no idea how I could have fixed it or even found out what the difference was. (As you can see, I tried clearing everything I could, but the incorrect behavior persisted until I started a completely new session.)

I seem to have issues of this nature quite frequently, where some invisible bit of state will end up mucking up my work and leading to unexpected behavior, and I have no idea what the actual problem is, let alone how to undo it. I can't imagine Mathematica is supposed to feel like you're constantly walking through an invisible minefield where at any moment some forgotten bit of code from a deleted cell in a closed notebook could break stuff without warning ...

Is there some window or panel I've missed where I can view what symbols are active in a session, like how Matlab lets you see all the variables currently defined in your workspace? MATLAB has a similar tradeoff between having a global workspace where variables stay defined and can potentially cause old code from one program to interfere with another, but having a view like that makes it much easier to deal with; I'm almost sure such a thing exists, and it would be extremely helpful, but I can't find it. I know there must be some way to find out what I've added to a session.

Also, how can I get a fresh session again without having to close and reopen Mathematica, given that even Clear["Global`*"] and ClearAll don't seem to be able to get rid of everything?

POSTED BY: Maxwell Greason
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract