Bug introduced in 10.0.0 and fixed in 10.0.1
I had code to display with subscripts from Displaying index as subscript on output: e.g. C[i] -> C_i with Notation[...] or Interpretation[..]? which is now breaking an innocuous pure function substitution as in Looking for an elegant way to solve a (system of) ODEs/functional equations with undetermined coefficients The substitution itself has nothing to do with any actual display of subscripts.
I am having a little trouble creating a minimal example, but here goes. First, in Mma10 try the pre-side effect code:
ODE = F'[z] == g F[z]
Fguess = {F-> (Exp[a #]&)}
ODE /. Fguess //FullSimplify
=> e^(a z)(a - g)== 0, the proper output
Now, add in the following code, stripped down from that previous example. This isn't intended to actually have anything to do with the substitution, but is causing side effects.
NotScriptedVarQ[z_] := ! MemberQ[$scriptedfunctionsvars, z, Infinity];
makeDef[pat_, body_] := (MakeBoxes[a : pat, fmt_] :=
ToBoxes[Interpretation[body, a], fmt] /;
MemberQ[Union[$scriptedconstants, $scriptedfunctions],
Unevaluated@h];
)
makeDef[h_Symbol[argssub__?NotScriptedVarQ], h[argssub]];
$scriptedconstants = {};
$scriptedfunctions = {};
$scriptedfunctionsvars = {};
Now, try the substitution and a few permutations:
(*The ODE and guess are*)
ODE = F'[z] == g F[z]
Fguess = {F -> (Exp[a #] &)}
(*Substituting NOW DOESN'T work*)
ODE /. Fguess // FullSimplify
(*But if the guess is NOT displayed before the substitution(i.e., no ;) WORKS!*)
Fguess = {F -> (Exp[a #] &)};
ODE /. Fguess // FullSimplify
(*And if the guess is substituted directly, IT WORKS!*)
F'[z] == g F[z] /. {F -> (Exp[a #] &)} // FullSimplify
As this used to work fine in Mma9, I imagine this is a bug. If so, any idea of a workaround?
One last thing I learned: If you change the definition so that NotScriptedVarQ[z_] := True
, or change it to always be False, the bug is no longer there!
Print
expressions suppose to accomplish? Are they supposed to function as comments? Should that be the case, then use Mathematica's comment syntax, e.g.,(* a comment *)
. $\endgroup$