MathGroup Archive 2006

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

Search the Archive

Re: how to define a constant like Pi in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63947] Re: [mg63936] how to define a constant like Pi in Mathematica
  • From: Zhengji Li <zhengji.li at gmail.com>
  • Date: Tue, 24 Jan 2006 01:30:32 -0500 (EST)
  • References: <200601230911.EAA04902@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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.
-------------------------------------------------------------


  • Prev by Date: Re: correlated random vector
  • Next by Date: Re: Getting the value of the independent var from the dep.var using NDSolve
  • Previous by thread: how to define a constant like Pi in Mathematica
  • Next by thread: Re: how to define a constant like Pi in Mathematica