MathGroup Archive 2000

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

Search the Archive

RE: Newbie-?: How to edit an input and recalculate dependent formula's

  • To: mathgroup at
  • Subject: [mg25662] RE: [mg25629] Newbie-?: How to edit an input and recalculate dependent formula's
  • From: "David Park" <djmp at>
  • Date: Wed, 18 Oct 2000 02:52:31 -0400 (EDT)
  • Sender: owner-wri-mathgroup at


Mathematica is not like an Excel spreadsheet where everything is
automatically recalculated when you make a change. And we wouldn't want it
to be that way. We would seldom want the whole notebook, or even everything
after the changed statement to be recalculated. Suppose you were working a
series of exercises and wanted to go back and change an earlier exercise.
Would you want all the subsequent exercises to be automatically

But there are many ways to organize your notebook and your calculations for

If you use the Section, Subsection and Subsubsection grouping, you can
change a statement and then reevaluate an entire (sub)section by selecting
it and using Shift-Enter.

Defining functions with arguments provides an easy way to recalculate them
with changed arguments.

You can put multiple statements in one cell and then make a change and
reevaluate the cell. Here is an example (all in one cell):

x = a + 1
y = x^2 + 3*x
Expand[y^2 + 1]

1 + a
3*(1 + a) + (1 + a)^2
17 + 40*a + 33*a^2 + 10*a^3 + a^4

You can then change x and reevaluate the cell.

You can group a calculation within a With or Module statement where some of
the initial variables are set. So, the above calculation could be done:

{x = b - 2, y, w},
 y = x^2 + 3*x;
 w = Expand[y^2 + 1];
 {x, y, w}]

{-2 + b, 3*(-2 + b) + (-2 + b)^2, 5 + 4*b - 3*b^2 -
   2*b^3 + b^4}

You can then change anything in the Module statement and reevaluate.

You could always select the entire notebook and reevaluate. The statement
numbers will then be in the same order as the statements, and if you started
a fresh session they will start with 1. I certainly don't recommend this as
standard operating procedure.

If you have just started with Mathematica, it really pays to read Steven
Wolfram's "Suggestions about Learning Mathematica" in the front of the Book,
and it really pays to work through, by typing in the statements, as much of
Part I as seems relevant to you.

David Park
djmp at

> -----Original Message-----
> From: Adriaan_S [mailto:adriaansachtler at]
To: mathgroup at
> I started to use Mathematica 4.02 today (on Windows NT 4.0), and
> quickly ran
> into a problem: how do I edit an input??
> It is easy enough to change an existing input line, but I noticed that two
> unexpected things happen:
> (a) the input line number is changed to (the last one +1)
> (b) none of the subsequent equations (in the original number scheme) are
> recalculated
> I would like to believe that I am not the first of over 1 million
> Mathematica users to ever make a mistake? I searched help, but with no
> success.
> >>How do I correct or modify an input line in such a way that all of the
> following equations ARE recalculated??
> On a related note, since the calcs don't execute in the order they are
> displayed on the page, is there a way to re-display the page to match the
> actual calcs?
> Many thanks, Adriaan Sachtler

  • Prev by Date: Re: A function to evaluate only parts matching a pattern
  • Next by Date: Re: Graphics Directives Lost In Certain Cases
  • Previous by thread: Re: Newbie-?: How to edit an input and recalculate dependent formula's
  • Next by thread: Simple equation checking..