|
[Date Index]
[Thread Index]
[Author Index]
Re: Rule-based programming: declare variables to be a number
- To: mathgroup at smc.vnet.net
- Subject: [mg80792] Re: Rule-based programming: declare variables to be a number
- From: dh <dh at metrohm.ch>
- Date: Sat, 1 Sep 2007 00:39:28 -0400 (EDT)
- References: <fb83lf$82d$1@smc.twtelecom.net>
Hi Hendrick,
simpliy replace g by 1. before calling NumberQ.
Further, I think it is a bad thing to change definitions of built in
function. Better create your own. Then:
myNumberQ[expr_] := NumberQ[expr /. g -> 1.]
By the way, I noted ,that NumberQ returns True for Exp[1.] but False for
Exp[1]
hope this helps, Daniel
Hendrik van Hees wrote:
> I still work with Mathematica 4.0. I hope, somebody can answer my
> question despite this.
>
> I have written a simple rule-based program to evaluate traces of
> SU(2)-Lie algebra (Pauli matrices) to help me to obtain the Lagrangian
> of a chiral model, but that's not so important for my question.
>
> My problem is the following: To get the usual rules with algebraic
> expressions containing numbers and Lie-algebra variables, one needs to
> define what happens when a Lie-algebra variable is multiplied by a
> number. This works fine as long as I use really constant numbers like
> 1, 2, 1/2, etc.
>
> However, of course, one needs this feature also for variable numbers,
> say a coupling constant g. So I wrote Unprotect[NumberQ] and then said
>
> NumberQ[g]:=True,
>
> but then NumberQ[g^2] evaluates to False. So I have written a whole
> bunch of rules to make powers of g also numbers. It works already quite
> well, but is there a possibility to just declare a variable (like g) to
> be a number, and then make Mathematica know, that expressions like g^2,
> Sqrt[g], 1+g, etc. are also numbers?
>
Prev by Date:
Re: [Mathematica 6] Bug in Labeled, Center align option not accepted.
Next by Date:
Re: Animation of a rotating object. (Mathematica 6)
Previous by thread:
Re: [Mathematica 6] Bug in Labeled, Center align option not accepted.
Next by thread:
Re: Rule-based programming: declare variables to be a number
|