[Date Index]
[Thread Index]
[Author Index]
Re: Non standard evaluation troubles.
*To*: mathgroup at smc.vnet.net
*Subject*: [mg20497] Re: [mg20448] Non standard evaluation troubles.
*From*: Jean-Marie Thomas <jmt at agat.net>
*Date*: Wed, 27 Oct 1999 02:04:57 -0400
*Organization*: TeA
*References*: <199910260433.AAA06018@smc.vnet.net.>
*Sender*: owner-wri-mathgroup at wolfram.com
Unless f has been defined somewhere, the two following expressions return the
same output :
Table[f[ksi],{ksi,1,2,0.01}]
Table[Evaluate[f[ksi]],{ksi,1,2,0.01}]
and in this case, there are no reasons why to use Evaluate.
In this kind of situation, do not hesitate to use Trace !
Using Evaluate can be useful in a Plot expression, because Mathematica takes
the iterator {variable, one end, other end} and transforms it in a set of
values, the number of which depends on PlotPoints options.
If f is a complicated expression, not specifying Evaluate leads to evaluate f
at each point of the set.
The same reason apply to Table, for instance :
Table[Table[LegendreP[n, x], {n, 4}], {x, 0, 1, 0.1}] // Timing
versus
Table[Evaluate at Table[LegendreP[n, x], {n, 4}], {x, 0, 1, 0.1}] // Timing
If you analyse the last command, you should realize that Evaluate computes the
list of polynomials, and Table computes the values of this list for each value
of x.
No using Evaluate makes Mathematica to rebuild the list of polynomials for each
value of x.
jmt
On Tue, 26 Oct 1999, I. Ioannou wrote:
> Hi all,
>
> I've got a problem with Plot and Table "non-standard" evaluation.
>
> When I specify list1=Table[Evaluate[function[ksi]],{ksi,1,2,0.01}]
>
> I get 100 numbers that are not the values at ksi 1, 1.01, 1.02,...
>
> The same happens with Plot of the function.
>
> When I type function[1] I get the proper value though. Must be that ksi is
> held unevaluated and ends up mangled in my function. (which is a module
> that I wrote)
>
> How can I avoid this kind of behavior? I don't quite understand at this
> point the various evaluation schemes of Mathematica very well. Any
> didactic pointers wellcome.
>
> Thanks, John
> --
> Ioannis I Ioannou phone: (206)-543-1372
> g-2 group, Atomic Physics fax: (206)-685-0635
> Department of Physics
> University of Washington e-mail: iioannou at u.washington.edu
Prev by Date:
**Re: Iterators, again**
Next by Date:
**Re: bug in Legendre polinomials**
Previous by thread:
**Non standard evaluation troubles.**
Next by thread:
**Re: Non standard evaluation troubles.**
| |