Re: Re: how to define a constant like Pi in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg63952] Re: [mg63947] Re: [mg63936] how to define a constant like Pi in Mathematica
- From: "Erickson Paul-CPTP18" <Paul.Erickson at Motorola.com>
- Date: Wed, 25 Jan 2006 04:11:22 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
- Thread-index: AcYgu5hZLpZtdwlNTSOoi5fQf+kvLAAcnwCg
Since "Attributes[ð] = {Constant, Protected, ReadProtected}", is there a reason you didn't add Protected to your setattributes list? I guess this is an application question, but if to be treated as if a physical (i.e., really is a) constant, then I'd guess it should be. -----Original Message----- From: Zhengji Li [mailto:zhengji.li at gmail.com] To: mathgroup at smc.vnet.net Subject: [mg63952] [mg63947] Re: [mg63936] how to define a constant like Pi in Mathematica This works: c; SetAttributes[c, {ReadProtected, Constant}]; (* ReadProtected does the magic*) N[c] = 1.2345; c /: Re[c] = 1.2345; c /: Im[c] = 0; Then, Integrate[Exp[-c x ^2], {x, -Infinity, Infinity}] --> Sqrt[Pi/c] Sqrt[Pi/c] // N --> 1.59525 On 1/23/06, John Smith <doesnotexist at dread13.news.tele.dk> wrote: > I would like to define a constant in mathematica for example c=1.2345 > in such a way that it behaves exactly like Pi or E. > That is when I type c then I get the output c and not 1.2345. > If I do integration[Exp[-c*x^2],{x,-oo,oo}] then I should get > sqrt[Pi/c] and not If[c<0...] > > > -- Li Zhengji ------------------------------------------------------------- If all you have is a hammer, everything is a nail. -------------------------------------------------------------