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? $\endgroup$HoldFirst
would be as an attribute ofQuotient
. Still no dice; I thinkHold
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 yield6/9
$\endgroup$forceden[r_Rational, d_Integer?Positive] := With[{f = Quotient[d, Denominator[r]]}, Internal`RationalNoReduce[f Numerator[r], d]]
suit your needs, then? $\endgroup$