MathGroup Archive 2006

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

Search the Archive

Re: Not accepting function as parameter

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71716] Re: Not accepting function as parameter
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Mon, 27 Nov 2006 04:04:40 -0500 (EST)
  • References: <ekbmj4$f87$1@smc.vnet.net>

Head Function???

As far as I know there is not such a head.

Maybe something like the following is more appropriate:

Quit

First here is a list of the Built-in symbols in Mathematica that have
the the Attribute
NumericFunction

lst = ToExpression[Select[Names["System`*"],
    MemberQ[Attributes[#1], NumericFunction] & ]]

{Abs, AiryAi, AiryAiPrime, AiryBi, AiryBiPrime, ArcCos, ArcCosh,
ArcCot,
  ArcCoth, ArcCsc, ArcCsch, ArcSec, ArcSech, ArcSin, ArcSinh, ArcTan,
  ArcTanh, Arg, ArithmeticGeometricMean, BesselI, BesselJ, BesselK,
BesselY,
  Beta, BetaRegularized, Binomial, Ceiling, ChebyshevT, ChebyshevU,
Clip,
  Conjugate, Cos, Cosh, Cot, Coth, Csc, Csch, Divide, EllipticE,
EllipticF,
  EllipticK, EllipticPi, Erf, Erfc, Erfi, Exp, ExpIntegralE,
ExpIntegralEi,
  Factorial, Factorial2, Fibonacci, Floor, FractionalPart, Gamma,
  GammaRegularized, GegenbauerC, HermiteH, Hypergeometric0F1,
  Hypergeometric0F1Regularized, Hypergeometric1F1,
  Hypergeometric1F1Regularized, Hypergeometric2F1,
  Hypergeometric2F1Regularized, HypergeometricU, Im, IntegerPart,
JacobiP,
  JacobiZeta, LaguerreL, LerchPhi, Log, LogGamma, LogIntegral,
MathieuC,
  MathieuCharacteristicA, MathieuCharacteristicB,
  MathieuCharacteristicExponent, MathieuCPrime, MathieuS,
MathieuSPrime, Max,
  Min, Minus, Mod, Multinomial, Plus, Pochhammer, PolyLog, Power,
Quotient,
  Re, Rescale, RiemannSiegelTheta, RiemannSiegelZ, Round, Sec, Sech,
Sign,
  Sin, Sinh, SphericalHarmonicY, Sqrt, Subtract, Tan, Tanh, Times,
UnitStep,
  Zeta}

(Head & ) /@ lst

{Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
Symbol,
  Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
Symbol,
  Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
Symbol,
  Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
Symbol,
  Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
Symbol,
  Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
Symbol,
  Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
Symbol,
  Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
Symbol,
  Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
Symbol,
  Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
Symbol,
  Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
Symbol,
  Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
Symbol}

Here is an example of function which if the given symbol is an element
of the list lst.

g[f_] := f[3] /; MemberQ[lst, f]

g[Sin]
Sin[3]

g[a]
g[a]

g[Re]
3

g[{Sin}]
g[{Sin}]

So for your function I would suggest the following definition

happy[f_, a_Integer, b_Integer] := Module[{width = (b - a)/1000},
f[width] /; MemberQ[lst, f]]

happy[Sin, 1, 21]
N[%]
happy[Tan, 10, 30]
N[%]

Sin[1/50]
0.01999866669333308
Tan[1/50]
0.020002667093402423

Best Regards
Dimitris

wooks wrote:
> This is a piece of experimental code. The function happy does not
> evaluate whenever I pass f as a parameter as in the example below.
>
> Clear[happy]
> happy[ f_Function, a_Integer, b_Integer] := Module[{width = (b -
> a)/1000},
>        f[width]];
> 
> happy[ Sin, 1, 21]
> 
> I'd be grateful for help.


  • Prev by Date: Re: Bookmarks in Mathematica????
  • Next by Date: Re: Bookmarks in Mathematica????
  • Previous by thread: Re: Not accepting function as parameter
  • Next by thread: Re: Re: Not accepting function as parameter