Re: keeping fractions from being simplified?
- To: mathgroup at smc.vnet.net
- Subject: [mg22351] Re: [mg22310] keeping fractions from being simplified?
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Fri, 25 Feb 2000 21:13:52 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
on 2/24/00 9:01 AM, Gerhard Killesreiter at killesreiter at physik.uni-freiburg.de wrote: > > Hi there! > > I am using mathematica 3.0. I would like to keep fractions _not_ > simplified, e.g. 12/9 should stay 12/9 and not become 4/3. Can I set > this behaviour globally, that is without stating Hold[12/9]? > Any help is appreciated! > Gerhard > > I don't think there is any "direct" way of doing this. It seems to me that the only way to achieve something like what you want do is to define your own way to input fractions and a function which, when needed, will convert them to Mathematica's fractions. You might, for example, do something like this: In:= ReduceFractions[expr_] := expr /. fr[a_, b_] :> a/b In:= Format[fr[a_, b_]] := MakeBoxes[Rational[a, b], TraditionalForm] // DisplayForm Now by writing fractions as fr[a,b] you can obtain results like: In:= fr[3, 6] + fr[4, 8] Out= 3 4 - + - 6 8 In:= ReduceFractions[%] Out= 1 Or perhaps you might prefer a different approach: In:= Clear[fr] In:= fr[a_, b_] + fr[c_, d_] ^= fr[a*d + b*c, b*d]; In:= fr[a_, b_]*fr[c_, d_] ^= fr[a*c, b*d]; In:= ReduceFractions[expr_] := expr /. fr[a_, b_] :> a/b In:= Format[fr[a_, b_]] := MakeBoxes[Rational[a, b], TraditionalForm] // DisplayForm In:= fr[3, 6] + fr[4, 12] Out= 60 -- 72 In:= ReduceFractions[%] Out= 5 - 6 -- Andrzej Kozlowski Toyama International University JAPAN http://sigma.tuins.ac.jp