MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Partial evaulation of function terms


I have the following function definition

ParFun[amps_, freq_] := Function[t, Sum[amps[[i]]*Sin[2*Pi*freq*i*t], {
     i, Length[amps]}]]

Then, the following works:

ParFun[{1,1/2},220][t]//InputForm
Sin[440*Pi*t] + Sin[880*Pi*t]/2

but
ParFun[{1,1/2},220]//InputForm
	yields
Function[t$, Sum[{1, 1/2}[[i]]*Sin[2*Pi*220*i*t$], {i, Length[{1, 1/2}]}]]

Is there a way to force Mathematica to evaluate all
subterms which already can be evaluated?
This function will be called in Play very often, so it would make things 
much faster if you could assign the function with all possible
constants evaluated to a local variable and do the many calls to the 
function for producing numerical values with the "partially 
preevaluated" expression.


  • Prev by Date: Re: mathematica parser
  • Next by Date: Re: Slowdown
  • Previous by thread: Re: For to Map to Increase Speed
  • Next by thread: Re: Partial evaulation of function terms