MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Basic Question about Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83402] Re: Basic Question about Mathematica
  • From: "David Park" <djmpark at comcast.net>
  • Date: Mon, 19 Nov 2007 06:20:44 -0500 (EST)
  • References: <fhp2la$1qh$1@smc.vnet.net>

You can use:

Clear["Global`*"]

to clear the values of everything. However, when things are messed up I 
usually just use Menu, Evaluation, Quit Kernel, Local.

You can change an Input cell and reevaluate without deleting the existing 
Output cell.

You can build up a calculation in a single cell and keep editing it and 
reevaluating until you have what you want. For example the following can all 
be put in one cell.

a=1;
b=2;
c=3;
a^2+b c
% -b^2

Then you could change any of the expressions and reevaluate. Don't worry 
about the In and Out numbers getting higher. (If you Quit the kernel they 
will restart at 1.)

It is probably poor practice to assign (Set) values to commonly used symbols 
like a,b,c,x,y etc. That is because you can't then use them as symbolic 
values, say in solving equations. The most common mistake in Mathematica is 
to forgot that you have assigned a value to a symbol. You can minimize these 
problems by using constructions that localize the values. For example:

f[a_, b_, c_] := a^2 + b c - b^2
f[1, 2, 3]

Or

With[
 {a = 1, b = 2, c = 3},
 a^2 + b c - b^2]



-- 
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/


<dmartin19 at gmail.com> wrote in message news:fhp2la$1qh$1 at smc.vnet.net...
>I only started using Mathematica yesterday, so please excuse this very
> newbie question.
>
> I was working in a notebook, using help files to try to learn
> Mathematica. I noticed that Mathematica uses cells for entry, and each
> of my entries in a cell are tagged by numbers, such as "In[n]" and
> "Out[n]" where "n" is some number.
>
> Being new, I keep making a lot of mistakes while experimenting, and
> each time when I realize the mistake, I delete the cell and start over
> again. When I do this, Mathematica does not continue to number the
> "In[n]" and "Out[n]" lines sequentially based on what is actually on
> the notebook, but instead remembers the numbers from the deleted cells
> even after I have deleted them.
>
> Consequently, with only 10 or so cells on my notebook, I have numbers
> like "In[102]" because Mathematica is remembering all the deletions,
> and all the times I asked it to recalculate.
>
> What is worse is that it seems to remember errors and variables from
> the deleted cells. If I previously made a mistake with some variable
> or expression and deleted it, then tried to define it again, it gives
> me the same error I got before I deleted it.
>
> Clearing the history does not help.
>
> Is there any way to get Mathematica to totally forget stuff that I
> have deleted and only evaluate whatever is in the notebook at a given
> time?
>
> It would also be great if it could renumber the "In[n]" and "Out[n]"
> statements so they bear some semblance to the actual number of cells
> in my notebook.
>
> Any help is appreciated!
> 



  • Prev by Date: Re: Symbolic vector handling
  • Next by Date: Re: data structures in Mathematica
  • Previous by thread: Re: Basic Question about Mathematica
  • Next by thread: Re: Basic Question about Mathematica