Re: newbie: explicit function works, "function object" doesn't

*To*: mathgroup at smc.vnet.net*Subject*: [mg96251] Re: newbie: explicit function works, "function object" doesn't*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>*Date*: Tue, 10 Feb 2009 05:51:25 -0500 (EST)*Organization*: The Open University, Milton Keynes, UK*References*: <gmp0st$c30$1@smc.vnet.net>

In article <gmp0st$c30$1 at smc.vnet.net>, Tom Roche <tlroche at gmail.com> wrote: > summary: I've got a function that I can Manipulate, but I can't > Manipulate the things to which the function is assigned. I'm assuming > this is due to a syntax error. All the parameters used by Manipulate[] must appear *explicitly* at the first level of the expression to be manipulated. [snip] > From what I've read, it seems Manipulate wants an expression like the > RHS of 'soln', which I'll refer to here as a "function." (Please > correct my usage as needed.) I got a "function object" with ReplaceAll > > happysoln[t_] = theta[t] /. soln[[1]] Therefore, you should define happysoln as follows: happysoln[omega_, theta0_, v0_, t_] = theta[t] /. soln[[1]] So we now have the following working code: linearPendulum = theta''[t] == -omega^2 theta[t]; soln = DSolve[{linearPendulum, theta'[0] == v0, theta[0] == theta0}, theta, t]; happysoln[omega_, theta0_, v0_, t_] = theta[t] /. soln[[1]]; Manipulate[ Plot[happysoln[omega, theta0, v0, t], {t, -2 Pi, 2 Pi}], {{omega, 1}, 0, 5}, {{theta0, 1}, 0, 5}, {{v0, 1}, 0, 5}] which works as expected. [snip] Regards, --Jean-Marc