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: [mg63950] Re: how to define a constant like Pi in Mathematica
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Tue, 24 Jan 2006 01:30:39 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 1/23/06 at 4:11 AM, doesnotexist at dread13.news.tele.dk (John
Smith) 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...]

You should be able to assign a value to c and have c displayed rather than the value using Hold or one of the variants of Hold. But this really won't achieve what you want since you still need to have Integrate determine c is a real > 0.

Rather than trying to get c to behave this way I believe it is far simpler and easier to use Assuming, i.e.,

In[14]:=
Assuming[c > 0, Integrate[Exp[(-c)*x^2], {x, -Infinity, Infinity}]]

Out[14]=
Sqrt[Pi]/Sqrt[c]

And if I needed to convert this to a number, then

Assuming[c > 0, Integrate[Exp[(-c)*x^2], {x, -Infinity, Infinity}]]/.c->1.2345

suffices. Or probably even better would be to use NIntegrate instead of Integrate where a number is desired rather than a symbolic solution.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: When reopen notebook, strange indentation and output is Null (ver5.2)
  • Next by Date: Re: correlated random vector
  • Previous by thread: Re: how to define a constant like Pi in Mathematica
  • Next by thread: Re: Re: how to define a constant like Pi in Mathematica