Message Boards Message Boards

0
|
6739 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Hold a fraction in unreduced terms?

This is trivial but for the life of me I cannot find a reference in the docs and it has perplexed me forever. Either I have forgotten, not unlikely & more common as I grow longer of tooth, or I never knew. I unsuccessfully searched the forum for unreduced _ and fraction_

How can I hold a fraction in unreduced terms Mathematica. For instance how can I get the example to display as: {4/18, 6/18, 8/18}

    r = {2, 3, 4};
    r/Total[r]
    HoldForm[r/Total[r]]

    {2/9, 1/3, 4/9}

r={2,3,4};
r/Total[r]
HoldForm[r/Total[r]]
{2/9,1/3,4/9}
r/Total[r]

HoldForm[] clearly is not the answer.

Attachments:
POSTED BY: Roger M Kolaks
4 Replies

Thank you, Udo, I'll give that a shot.

POSTED BY: Roger M Kolaks

Try that

In[70]:= Clear[r]
         r = {2, 3, 4};
         (r /. x_Integer -> If[Divisible[Total[r], x], Hold[x], x])/Total[r]
Out[72]= {2/9, Hold[3]/9, 4/9}
POSTED BY: Udo Krause

Thanks. This is a solution I hadn't considered since it turns the denominator into a string & which could be a bit of time bomb with my erratic work style . It may be the only way to see what I want.

POSTED BY: Roger M Kolaks

Try this:

r = {2, 3, 4}; r/ToString[Total[r]]

POSTED BY: S M Blinder
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract