Re: Use of Mathematica with Rule-based Equation Derivations
- To: mathgroup at smc.vnet.net
- Subject: [mg61944] Re: [mg61914] Use of Mathematica with Rule-based Equation Derivations
- From: "David Park" <djmp at earthlink.net>
- Date: Sat, 5 Nov 2005 01:52:45 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Mark, Clearly, I think you have to specify either a list of variables or a list of constants. It will probably be easier to specify the variables. So for the cases you have presented (using EV instead of E for the expectation value operator)... vars = {x}; expectationBreakout[vars_][expr_] := expr //. {EV[a_?(FreeQ[#, Alternatives @@ vars] &)b_] -> a EV[b], EV[a_?(FreeQ[#, Alternatives @@ vars] &) + b_] -> a + EV[b], EV[EV[x_]] -> EV[x]} {EV[a x], EV[b + f[x]], EV[a + EV[b x]]}; % // expectationBreakout[vars] {a EV[x], b + EV[f[x]], a + b EV[x]} I suppose there would be additional sets of rules for evaluating various functions of the variables. It certainly is possible to do step by step derivations and calculations with Mathematica. It's the best way to learn material! You can do many steps within one cell and intersperse them with Print statements to annotate the derivation. But one will usually have to write rules, as above, to implement the various 'axioms'. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: mmorriss at gcn.ou.edu [mailto:mmorriss at gcn.ou.edu] To: mathgroup at smc.vnet.net Hi All - I'm a many-year user of mathematica, but have always had one particular problem with it that I may have just simply missed reading about. Mathematica Version: 5.2 Problem: I would like to develop a set of re-rewite rules to apply to the Expected Value operator. For example: E[a x] = a E[x] a -> constant, x -> variable E[b + f[x]] = b + E[f[x]] , etc. The issue is how does one using Mathematica distinguish a 'constant variable (i.e. a and b)' from a variable 'variable' (i.e. 'x')? The head of a, b and x is 'Symbol' and neither a, b nor x contain a number so I can't use a_?NumberQ to identify it as a constant. This actually goes to the wider question of how does one use Mathematica for symbolic derviations where numbers are not actually substituted in the derviation? E.g. E[a + E[b x]] /. Rule2 out= a + b E[x] etc. Thanks all - Mark Morrissey University of Oklahoma