Subject: [mg111135] Re: Very very basic question about Mathematica expressions

From: dr DanW <dmaxwarren at gmail.com>

Date: Wed, 21 Jul 2010 07:14:35 -0400 (EDT)

References: <i23k1j$epv$1@smc.vnet.net>

I ran into this problem yesterday. I don't know exactly why it
happens, I think it has something to do with the way Manipulate
localizes variables. To solve it, I use a trick I found that lets me
take an expression built up of global symbols and localize the
symbols. Your trivial example:
s = x + h
Make a function out of it. The Evaluate[] is necessary to evaluate s,
which replaces it with x+h
sfnc = Function[{x, h}, Evaluate[s]]
Now the Manipulate[] works fine
Manipulate[Plot[sfnc[x, h], {x, 0, h}], {h, 0.1, 1}]
I find myself using this trick a lot.
Regards,
Daniel