MathGroup Archive 1997

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

Search the Archive

Use a nicer Format for differences

  • To: mathgroup at
  • Subject: [mg6427] Use a nicer Format for differences
  • From: Ersek_Ted%PAX1A at
  • Date: Thu, 20 Mar 1997 00:52:24 -0500 (EST)
  • Sender: owner-wri-mathgroup at

If you have a difference of two terms Mma presents them so they are in 
standard order.  Consider the following:

In[1]:=  y-d

Out[1]= -d+y

It puts "-d" before "y", and most would find this unapealing.
You can get the nicer result by using TraditionalForm.

In[2]:= y-d//TraditionalForm


You can also get the nicer result by writing your own Format.
Dave Withoff at WRI helped me get this working.
However, he hasn't seen my latest version.


             Format[(n_Real | n_Integer | n_Rational)*a_.+b_/;


After entering In[3] any of the following are displayed as a difference in 
   y-3 d
   y-2/3 d
   y-1.25 d
   y-a b

Also this format is used when the difference is inside another function.
As in:    1/Log[y-3 d]

However, this format is not used when more that two terms are added / 
This is the way I wanted it.

Eventually I will have the above Format used automatically as soon as Mma is 
opened.  However, I have yet to figure out that part.

               Ted Ersek

  • Prev by Date: 3D Plots
  • Next by Date: fonts
  • Previous by thread: Re: Solving Underdamped Equation of motion
  • Next by thread: Re: Use a nicer Format for differences