MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Use of Mathematica with Rule-based Equation Derivations

  • To: mathgroup at
  • Subject: [mg61933] Re: [mg61914] Use of Mathematica with Rule-based Equation Derivations
  • From: Bob Hanlon <hanlonr at>
  • Date: Sat, 5 Nov 2005 01:52:16 -0500 (EST)
  • Reply-to: hanlonr at
  • Sender: owner-wri-mathgroup at

Using rules:


      \[DoubleStruckCapitalE][a_?(FreeQ[#,x]&) expr_?(!FreeQ[#,x]&)]:>
      \[DoubleStruckCapitalE][a_ + b_]:>\[DoubleStruckCapitalE][a] + \

        b x]]}//.rules[]

{a \[DoubleStruckCapitalE](x),b+\[DoubleStruckCapitalE](f(x)),a+
    b \[DoubleStruckCapitalE](x)}

        b y]]}//.rules[y]

{a \[DoubleStruckCapitalE](y),b+\[DoubleStruckCapitalE](f(y)),a+
    b \[DoubleStruckCapitalE](y)}

Using definitions:


\[DoubleStruckCapitalE][expr_, x_Symbol:x]:=expr/;FreeQ[expr,x];
\[DoubleStruckCapitalE][a_ expr_, x_Symbol:x]:= 
      FreeQ[a, x]&&!FreeQ[expr,x];
\[DoubleStruckCapitalE][a_ + b_, x_Symbol:x]:=\[DoubleStruckCapitalE][a,x]+

      b+f[x]],\[DoubleStruckCapitalE][a+\[DoubleStruckCapitalE][b x]]}

{a \[DoubleStruckCapitalE](x,x),b+\[DoubleStruckCapitalE](f(x),x),a+
    b \[DoubleStruckCapitalE](x,x)}

    f[y],y],\[DoubleStruckCapitalE][a+\[DoubleStruckCapitalE][b y,y],y]}

{a \[DoubleStruckCapitalE](y,y),b+\[DoubleStruckCapitalE](f(y),y),a+
    b \[DoubleStruckCapitalE](y,y)}

Bob Hanlon

> From: mmorriss at
To: mathgroup at
> Date: 2005/11/04 Fri AM 05:11:39 EST
> Subject: [mg61933] [mg61914] Use of Mathematica with Rule-based Equation Derivations
> 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

  • Prev by Date: MathML->SymbolicXML->MathML
  • Next by Date: En:Re:String filtering problem
  • Previous by thread: Re: Use of Mathematica with Rule-based Equation Derivations
  • Next by thread: "gray" lines in grids?