Re: Changing the argument

*To*: mathgroup at smc.vnet.net*Subject*: [mg125029] Re: Changing the argument*From*: Andrés <jarosham at gmail.com>*Date*: Sat, 18 Feb 2012 06:27:23 -0500 (EST)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*References*: <jhldc2$oq5$1@smc.vnet.net>

Hi Niles. z must be a function of t from the beginning so that t can also be one. I would rewrite: primaryFunc[i_,t_] := { secondaryFunc[t_] := 1/z[t]; func = 0; For[j = 1, j < i + 1, j++, func = func + secondaryFunc[t]; ]; func}; test[t_] := primaryFunc[20,t] NDSolve[{z''[t] == test[t], z[0] == 0, z'[0] == 20}, z, {t, 0, 5}]; Hope it helps, Andr=E9s On Feb 17, 6:23 am, Niles <niels.martin... at gmail.com> wrote: > Hi! > > I have the following piece of code (I am using this as an example): > > primaryFunc[i_] := { > secondaryFunc[z_] := 1/z; > func = 0; > For[j = 1, j < i + 1, j++, > func = func + secondaryFunc[z]; > ]; > func}; > > test = primaryFunc[20]; > > Say that I need to use the function "test" in NDSolve, e.g.: > NDSolve[{z''[t] == test, z[0] == 0, z'[0] == 20}, z, {t, 0, 5}]; > > The problem is that the variable "z" in "test" needs to become "z[t]". > How can this be done most efficiently? Thanks for the help in advance. > > Best, > Niles.