Re: Confusing behaviour with caching of evaluated expressions ?
- To: mathgroup at smc.vnet.net
- Subject: [mg63747] Re: [mg63727] Confusing behaviour with caching of evaluated expressions ?
- From: "David Park" <djmp at earthlink.net>
- Date: Fri, 13 Jan 2006 04:48:27 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Chris, Check the Update function. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Chris Rodgers [mailto:rodgers at physchem.NOSPAMox.aREMOVEc.uk] To: mathgroup at smc.vnet.net Hi, Can anyone shed any light upon the following unexpected output from Mathematica? I have come across some rather strange behaviour in the way Mathematica handles expressions which depend on a "flag" variable e.g.: F[x_] := G /; flag==1 It appears that Mathematica forgets that flag is a variable that might change in the future. Thus, if one defines another expression e.g.: flag=0 expr1= F[z1] expr2:=F[z2] expr1 and expr2 will both currently evaluate to F[z1] and F[z2] as expected. BUT, if we now change the flag and try to prod them into evaluating to give G, things become tricky: flag=1 expr1 expr2 Evaluate[expr1] Evaluate[expr2] FullSimplify[expr1] FullSimplify[expr2] Even doing something like F[z1] expr1 doesn't work. (The F[z1] returns G correctly, but expr1 doesn't realise that it should change to give G.) The only way to make it work again seems to be to "change" z1 or z2. For example, z1=z1+0 expr1 RandomFunctionIMadeUp[z2]^:=33 expr2 These two assignments are enough to make Mathematica update its cache(?). Can anyone explain to me why this might be "by design"? Can anyone tell me a way to make Mathematica fully evaluate an expression e.g. expr1 without getting stuck in this way? Is there a SuperFullActuallyEvaluate[expr1] commmand?? :-) Many thanks in advance, Chris.