Say I've got a function
f[x_] := a x^2 + b*x + c;
and later set for some other reason a=1;
how can I get the expression of f in an untouched form (with "a" and not "1")?
I don't want to use HoldForm or Unevaluated in definition of f nor parse Definition[f].
An example code that I'm trying to modify, so that it ignores evaluation of symbols in the first 2 StylePrints.
SetAttributes[DD, HoldFirst];
DD[f_, var_] := HoldForm[\!\(\*SubscriptBox[\(\[PartialD]\), \(var\)]f\)];
SetAttributes[CSE, HoldFirst];
CSE[e_] :=
ToExpression[
If[StringFreeQ[ToString[HoldForm@e], "Subscript["],
"\[CapitalDelta]" <> ToString[HoldForm@e] <> "",
StringReplace[ToString[HoldForm@e],
"Subscript[" -> "Subscript[\[CapitalDelta]"]], TraditionalForm,
HoldForm];
SetAttributes[TDE, HoldFirst];
TDE[fun2_, vars2__] :=
Sqrt[Sum[i, {i, ((CSE[#] DD[fun2, #])^2) & /@ vars2}]];
SetAttributes[TotalDiffrentialError, HoldFirst];
TotalDiffrentialError[fun_, vars__] := Module[{Expanded},
StylePrint[CSE[fun] == TDE[fun, vars], "EquationNumbered"];
StylePrint[CSE[fun] == FullSimplify[ReleaseHold[TDE[fun, vars]]],
"EquationNumbered"];
FullSimplify[ReleaseHold[TDE[fun, vars]]]];
So what I'm trying to do with that is to print elegant equations without numerical values, up to a certain point when (in current implementation) I release all the Holds. This design would in theory let me to define values somewhere before and not bother about passing them to the function.
DownValues[f], orBlock[{a}, ...]. – Oleksandr R. May 09 '14 at 19:221+1from turning into2. Without interfering with Mathematica's evaluation process or other trickery which makes that it only looks like you get what you want, this is not possible. Can you please give a practical reason what you try to achieve? – halirutan May 09 '14 at 19:46TotalDerivative[f,{a,b}]should print me 2-3 "theoretical" steps before putting the actual values. Often it happens thataandbalready have values as well as[\Delta]aand[\Delta]b– Ranza May 09 '14 at 19:47DownValues[f] /. RuleDelayed[a_, b_] :> HoldForm[b]is just one way of getting at this, but I must agree with other comments: what is the purpose and why are you trying to circumvent the basic semantics of the language? – ciao May 09 '14 at 19:48SetAttributes[TotalDerivative, HoldAll]; TotalDerivative[f_,vars:{__Symbol}] := Block[vars, {whatever}]... for what reason is that problematic? – Oleksandr R. May 09 '14 at 20:01