# Hold outermost layer of expression

In pursuit of a function to force unsimplified fractions

forceden[x_,d_]:=Hold[Evaluate[Numerator[x]d/Denominator@x]/d];


There are many related functions (Holdxxx,Evaluate,Unevaluated,Inactivated...), I can't seem to get any combination of them to work. "HoldFirst" doesn't work for cyring out loud. Of course,

DisplayForm@FractionBox[Numerator[x]d/Denominator@x,d]


works just fine for seeing the thing, but I lose the ability to use this object in calculations. Is there an elegant way to tell Mathematica to "chill out" for the fraction part while still doing the numerator multiplication? (without having to resort to throwing away all the symbolic goodness and "evaluability" of the fraction).

• "...HoldFirst doesn't work for crying out loud..." - because it's a function attribute, and not a function itself. Do you have an explicit example that you want to see in a held form? Commented Jan 18, 2021 at 2:05
• My bad, intended use of HoldFirst would be as an attribute of Quotient. Still no dice; I think Hold is the wrong word. I want 'Numerator[x]d/Denominator@x' to be fully evaluated and simplified as if it were an isolated expression, and no other simplification to occur. forceden[2/3,9] should yield 6/9
Commented Jan 18, 2021 at 7:11
• Would forceden[r_Rational, d_Integer?Positive] := With[{f = Quotient[d, Denominator[r]]}, InternalRationalNoReduce[f Numerator[r], d]] suit your needs, then? Commented Jan 18, 2021 at 7:46
• Yes! Thank you; going to browse more Internal functions now
Commented Jan 18, 2021 at 7:55
• Also, we do not do things like add "[SOLVED]" in titles here. If you don't mind waiting, I will write a more elaborate response later. Commented Jan 18, 2021 at 8:00

OK, just to put it on record: there is an undocumented function, InternalRationalNoReduce[] (see also Chip's answer here) that effectively allows you to represent a fraction not reduced to lowest terms, but can still act as a number:

InternalRationalNoReduce[3, 6]
3/6

N[%]
0.5


Thus, what the OP wants can be done like so:

forceden[r_Rational, d_Integer?Positive] := With[{f = Quotient[d, Denominator[r]]},
InternalRationalNoReduce[f Numerator[r], d]]


For instance,

forceden[2/3, 9]
6/9


" forceden[2/3,9] should yield 6/9 "

forceden[x_, d_] :=
Numerator[x] d/Denominator[x]/HoldForm[d]

ff = forceden[2/3, 9]
(*   6/9   *)

ff // ReleaseHold
(*   2/3   *)
`