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

Controlled evaluation of functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56763] Controlled evaluation of functions
  • From: "Brett Patterson" <muckle.moose at gmail.com>
  • Date: Thu, 5 May 2005 06:02:34 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Consider the following behaviour:

  In[1]:= f[i_, x_] := Sin[i x]

  In[2]:= g[x_] = Table[f[i, x], {i, 3}]

  Out[2]= {Sin[x], Sin[2 x], Sin[3 x]}

  In[3]:= {3, 0, 1} . g[y]

  Out[3]= 3 Sin[y] + Sin[3 y]

This is what I want to do, but using my own function instead of Sin.
However, this is the result:

  In[4]:= k[x_] := x^2           (* This is my alternative to Sin *)

  In[5]:= f[i_, x_] := k[i x]

  In[6]:= g[x_] = Table[f[i, x], {i, 3}]

  Out[6]= {x^2, 4 x^2, 9 x^2}    (* I want {k[x], k[2 x], k[3 x]} *)

  In[7]:= {3, 0, 1} . g[y]

  Out[7]= 12 y^2                 (* I want 3 k[y] + k[3 y] *)

How can I get the function k to behave like Sin, so that it is not
evaluated?

Note that in my real application, k is a lot more complex and has
conditions on its arguments, etc.

Thanks!

Brett Patterson


  • Prev by Date: Re: Cases and Nonatomic expression
  • Next by Date: InitializationCell -> Toggle shortcut key
  • Previous by thread: Re: Bug in Integrate in Version 5.1?
  • Next by thread: Re: Controlled evaluation of functions