# Message Boards

0
|
1170 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
 I had code to display with subscripts from http://mathematica.stackexchange.com/questions/30884/ which is now breaking an innocuous pure function substitution as in http://mathematica.stackexchange.com/questions/51103 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 Mathematica 10 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 Mathematica 9, 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!