Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Partial evaulation of function terms

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53230] Partial evaulation of function terms
  • From: Erich Neuwirth <erich.neuwirth at univie.ac.at>
  • Date: Sun, 2 Jan 2005 04:12:39 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

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