Attributes and behaviors?
- To: mathgroup at smc.vnet.net
- Subject: [mg46545] Attributes and behaviors?
- From: "Fred Klingener" <flush at BitBucket.com>
- Date: Mon, 23 Feb 2004 02:15:37 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Please help me understand better the relationship between attributes and behaviors. Background: I'm a Mathematica (5.0.0) newbie who's trying to build a package for dual numbers. In the package, ultimately I want to overwrite the System numeric functions to handle dual numbers without affecting the handling of the native (atomic) types. Progress so far: I have some sample functions working pretty well. Functions I've named things like kDualNumberSin[] seem to work numerically and symbolically on dual numbers and to drop through (via an explicit call) to System`Sin[] on Real arguments. Now I'm ready to think about overwriting System`Sin[], for example, and I'm having trouble getting my head around atttributes. I've built a toy function: kSin[x_] :=Sin[x], and here are a few observations about it: - In:-> Attributes[Sin] Out:-> {Listable, NumericFunction,...} - In:-> Attributes[kSin] Out:-> {} - a few tests show that kSin[] has full listable behavior, that is, it produces the same output as Sin[] when fed a List as an input argument. - My 'serious' function kDualNumberSin[] relies on Series[] for its operation. - Series[] has no Listable attribute. - a few primitive tests show that Series[] in fact has Listable capability. - kDualNumberSin[] also seems to have listable capability. All of this is confusing. - What's the nature of the relationship between attributes and behavior? - Is the attribute used in some inscrutable inner workings of the kernal? - What are the costs and benefits of simply setting the Listability attribute in my function? - How certain do I have to be that my function really IS Listable before I set the attribute? - Does the absence of the Listability attribute of Series[] mean that its current listable behavior is an undocumented feature subject to future abandonment? TIA for any help, Fred Klingener Brock Engineering