|
[Date Index]
[Thread Index]
[Author Index]
re: Specifying rules
- To: mathgroup at yoda.physics.unc.edu
- Subject: re: Specifying rules
- From: Marnix Van Daele <Marnix.VanDaele at rug.ac.be>
- Date: Wed, 15 Jun 1994 17:58:15 +0200 (MET DST)
On Mon, 13 Jun 1994 Paul=Rubin%Management%Business at banyan.cl.msu.edu wrote:
> Ron I. Herman <m1rih00 at frb.gov> wrote:
>
> >Is there any way to specify rules for symbols?
> >For example, is there a way to tell Mathematica
> >that a > 0 and b < 0 such that Positive[a b] will
> >yield false?
>
> Yes, using upvalues, but I'm not confident that it works across the board.
> For your specific example:
>
> In[]:= Clear[a, b];
> In[]:= a /: Sign[ a ] = 1;
> In[]:= b /: Sign[ b ] = -1;
>
> The two preceding lines tell Mma to evaluate the Sign function differently
> when applied to a and b. The "a /:" part associates that definition with a
> rather than Sign (which is protected). If you clear a, the upvalue goes with
> it.
>
> In[]:= Positive[ a b ]
> Out[]= False
> In[]:= Positive[ a ]
> Out[]= True
> In[]:= Negative[ b ]
2> Out[]= True
>
> It worked this time. It seems to me, though, that I've seen other examples
> where it doesn't work so well. (I tried up-setting NumberQ[a] to True, so
>2 that Mma would think a was a number, and caused a recursion fault with a
> later reference to a.) Off-hand, I can't remember the failure stories I've
> read. So caveat emptor.
>
> 2**************************************************************************
> * Paul A. Rubin Phone: (517) 336-3509 *
> * Department of Management Fax: (517) 336-1111 *
> * Eli Broad Graduate School of Management Net: RUBIN at MSU.EDU *
> * Michigan State University *
> * East Lansing, MI 48824-1122 (USA) *
> **************************************************************************
> Mathematicians are like Frenchmen: whenever you say something to them,
> they translate it into their own language, and at once it is something
> entirely different. J. W. v. GOETHE
>
>
>
Hello, I have a problem with complex numbers !
I want to tell Mma that a is real, such that
Im[a+I] will give 1,
but I do not get this result.
I have tried
a /: Im[a]=0
Can anyone help me ?
==============================================================================
Marnix Van Daele
Universiteit Gent
Vakgroep Toegepaste Wiskunde en Informatica
Krijgslaan 281 - Gebouw S9
B9000 Gent (Belgium)
tel. 32-(0)9-264.48.09
fax. 32-(0)9-264.49.95
==============================================================================
Prev by Date:
re: WnMath22 vs. memory
Next by Date:
Coloring 2DPlot with different colors
Previous by thread:
re: Specifying rules
Next by thread:
re: Specifying rules
|