Re: display factored form
- To: mathgroup at smc.vnet.net
- Subject: [mg29342] Re: display factored form
- From: Tom Burton <tburton at cts.com>
- Date: Thu, 14 Jun 2001 02:27:21 -0400 (EDT)
- Organization: Brahea Consulting
- References: <9g7470$cfh$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I am unsure about "uppercase exponents". I mean, if we are factoring integers, won't the exponents also be integers? What's an "uppercase integer"? Anyway, perhaps the following will do most of what you want. I am using InputForm and OutputForm for Input and Output cells (like the old days!) so I can paste into this message without distortion. Of course, most cells would look better in StandardForm. First, the following function will factor and display an integer in the form close to what you want: fi[k_Integer] := Times @@ Replace[FactorInteger[k], {i_, j_} :> HoldForm[i^j], {1}] HoldForm is needed to prevent Mathematica from simplifying the expression. For example In[39]:= fi[6] Out[39]= 1 1 2 3 Then the following rule will display fractions as you want: factorRule = Rational[i_, j_] :> fi[i]/fi[j] For example, In[41]:= 9/10 /. factorRule Out[41]= 2 3 ----- 1 1 2 5 Now consider a small matrix m: In[48]:= m=Table[Random[Integer,{1,100}]/Random[Integer,100],{2},{3}] Out[48]= 43 19 1 11 62 25 {{--, --, --}, {--, --, --}} 13 94 96 13 35 57 Applying the rule, we get In[50]:= m/.factorRule Out[50]= 1 1 1 1 1 2 43 19 1 11 2 31 5 {{---, ------, -----}, {---, ------, ------}} 1 1 1 5 1 1 1 1 1 1 13 2 47 2 3 13 5 7 3 19 Here is one way to apply this rule automatically for purposes of display only: $PrePrint = ReplaceAll[#, factorRule]& After this assignment, In[54]:= m Out[54]= 1 1 1 1 1 2 43 19 1 11 2 31 5 {{---, ------, -----}, {---, ------, ------}} 1 1 1 5 1 1 1 1 1 1 13 2 47 2 3 13 5 7 3 19 On Wed, 13 Jun 2001 07:20:00 +0000 (UTC), in comp.soft-sys.math.mathematica you wrote: >I would like to get Mathematica to display fractions (in a matrix) as >quotients of integers with uppercase exponents. Anybody know how? > >thanks, Joel Zeitlin, CSUN > Tom