Re: Can Mathematica evaluate step by step???

• To: mathgroup at smc.vnet.net
• Subject: [mg29493] Re: Can Mathematica evaluate step by step???
• From: "Neri Kafkafi" <NKafkafi at intra.nida.nih.gov>
• Date: Fri, 22 Jun 2001 02:20:22 -0400 (EDT)
• References: <9gf03m\$7m0\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Thanks David, I got several answers for this question, and  the solution
using DownValues worked best for me. I generaly appriciate very much the
knowlage and resopnsiveness in this group. Since you were interested in my
objective, it is simple: We use some complex algorithms for analysing a
large database. Since most of these algorithms take some time to evaluate
over the whole database, I wrote a function that store the results in files,
and recall them whenever the same question is asked again. Since we
sometimes improve our algorithms, I wanted to include in each file the
symbolic definition of the algorithm that was used for generating it, and
here I got into the problem...

Thanks, Neri

David Park <djmp at earthlink.net> wrote in message
news:9gf03m\$7m0\$1 at smc.vnet.net...
> Neri,
>
> It would be interesting to know what your larger objective is. A different
> Mathematica approach is probably the answer to your problem.
>
> Once you set a value for a, you have to use rather round about methods to
> keep it from being evaluated. So my first suggestion would be: don't set a
> to a value if you intend to later use it as a variable. You could do
> something like this (although I doubt that this is the answer you are
> looking for)
>
> a = 4;
> myfunction[a_] := 2a
>
> HoldForm @@ {myfunction[b]}
> % /. b :> a
> 2 b
> 2 a
>
> But what use would that result be for you, since it is in a HoldForm? So I
> think that you must avoid setting values for anything you want to use as a
> symbolic variable. It is often better to use rules, a -> 4, to substitute
> values for variables, or myfunction[4] to evaluate at a specific value. In
> my work I follow my own rule of never setting a single character symbol
> (a,b,x,y, etc.) to a value. The chances of getting tripped up by it are
just
> too high.
>
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
>
> > From: Neri Kafkafi [mailto:NKafkafi at intra.nida.nih.gov]
To: mathgroup at smc.vnet.net
> >
> > Assume I define:
> > myfunction:=2a
> >
> > and at some later time:
> > a=4
> >
> > Now if I evaluate myfunction I get 8.
> > If I evaluate Hold[myfunction] I get myfunction.
> >
> > My question is, how do I get 2a ?
> >
> > In other words, I want to get the symbolic definition of
> > myfunction, whether
> > a is defined or not.
> >
> > In (yet) other words, I want to evaluate myfunction only one step
further,
> > up to 2a, but not all the way to 8.
> >
> > Is this possible in Mathematica?
> >
> > Thanks in advance,
> > Neri
> >
> >
> >
> >
> >
>
>

```

• Prev by Date: Originality
• Next by Date: Re: AMD vs. Intel Floating Point
• Previous by thread: RE: Can Mathematica evaluate step by step???
• Next by thread: Odd behavior of InterpolationFunction derivative