|
[Date Index]
[Thread Index]
[Author Index]
RE: Getting rid of annoying zeroes in algebraic expressions
- To: mathgroup at smc.vnet.net
- Subject: [mg15237] RE: [mg15228] Getting rid of annoying zeroes in algebraic expressions
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Sun, 27 Dec 1998 03:58:30 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Sean Ross wrote,
_________________
>
>Let xx be the result of some algebraic manipulations
>which, for some reason, mathematica thinks the real
>zeroes ought to be kept and I think
>they ought to be dropped.
>
>xx=0. + (a*f)/(0. + f) + (b*f)/(0. + f) + (c*f)/(0. + f)
>
>xx/.Plus[0.,q_]->q
>
>returns
>
>0. + (a*f)/(0. + f) + (b*f)/(0. + f) + (c*f)/(0. + f)
>
.....
I don't understand your question, and I don't know if I could answer it
if I did understand it, but consider the following.
In[1]:=
xx=0. + (a*f)/(0. + f) + (b*f)/(0. + f) + (c*f)/(0. + f) Out[1]= 0. +
(a*f)/(0. + f) + (b*f)/(0. + f) + (c*f)/(0. + f)
In[2]:=
q=5;
In[3]:=
xx/.Plus[0.,q_]->q
Out[3]=
5
You don't get what you wanted for Out[3]. You do get what you want if
you use (->) instead of (:>) as below.
In[4]:=
xx/.Plus[0.,q_]:>q
Out[4]=
(a*f)/(0. + f) + (b*f)/(0. + f) + (c*f)/(0. + f)
I always say never use (lhs->rhs) when (lhs) has a named pattern that is
needed for (rhs). Instead use (lhs:>rhs).
Examples:
This first example is OK because (x) isn't used on the right side of
(->). (x_?Positive) -> 0
_____________
These can give you trouble:
(a_Rational) -> Floor[a]
foo[args__] -> Max[args]
(x_?Positive) -> Round[x]
Instead use:
(a_Rational) :> Floor[a]
foo[args__] :> Max[args]
(x?Positive) :> Round[x]
_____________
In a similar manner when (lhs) has a named pattern use (lhs:=rhs)
instead of (lhs=rhs)
use (lhs:^=rhs) instead of (lhs^=rhs) use (f/:lhs:=rhs) instead of
(f/:lrs=rhs) _____________
Cheers,
Ted Ersek
Prev by Date:
Re: Algebra on complex expressions: Collect
Next by Date:
Reading Mathematica 3.0 notebooks in Mathematica 2.2
Previous by thread:
Re: Getting rid of annoying zeroes in algebraic expressions
Next by thread:
Re: Getting rid of annoying zeroes in algebraic expressions
|