Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

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[1]:=
ReduceFractions[expr_] := expr /. fr[a_, b_] :> a/b
In[2]:=
Format[fr[a_, b_]] :=
  MakeBoxes[Rational[a, b], TraditionalForm] // DisplayForm

Now by writing fractions as fr[a,b] you can obtain results like:

In[3]:=
fr[3, 6] + fr[4, 8]
Out[3]=
3   4
- + -
6   8


In[4]:=
ReduceFractions[%]
Out[4]=
1

Or perhaps you might prefer a different approach:

In[5]:=
Clear[fr]
In[6]:=
fr[a_, b_] + fr[c_, d_] ^= fr[a*d + b*c, b*d];
In[7]:=
fr[a_, b_]*fr[c_, d_] ^= fr[a*c, b*d];
In[8]:=
ReduceFractions[expr_] := expr /. fr[a_, b_] :> a/b
In[9]:=
Format[fr[a_, b_]] :=
  MakeBoxes[Rational[a, b], TraditionalForm] // DisplayForm
In[10]:=
fr[3, 6] + fr[4, 12]
Out[10]=
60
--
72
In[11]:=
ReduceFractions[%]
Out[11]=
5
-
6



-- 
Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp




  • Prev by Date: Re: Superposition of 3D plots?
  • Next by Date: Re: Building lists
  • Previous by thread: RE: keeping fractions from being simplified?
  • Next by thread: a Graphic in a Graphic