Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Use of Mathematica with Rule-based Equation Derivations

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

Using rules:

Clear[\[DoubleStruckCapitalE],rules];

rules[x_Symbol:x]:={
      \[DoubleStruckCapitalE][expr_?(FreeQ[#,x]&)]:>expr,
      \[DoubleStruckCapitalE][a_?(FreeQ[#,x]&) expr_?(!FreeQ[#,x]&)]:>
        a*\[DoubleStruckCapitalE][expr],
      \[DoubleStruckCapitalE][a_ + b_]:>\[DoubleStruckCapitalE][a] + \
\[DoubleStruckCapitalE][b],
      \[DoubleStruckCapitalE][\[DoubleStruckCapitalE][expr_]]:>\
\[DoubleStruckCapitalE][expr]
      };

{\[DoubleStruckCapitalE][a*x],\[DoubleStruckCapitalE][
        b+f[x]],\[DoubleStruckCapitalE][a+\[DoubleStruckCapitalE][
        b x]]}//.rules[]

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

{\[DoubleStruckCapitalE][a*y],\[DoubleStruckCapitalE][
        b+f[y]],\[DoubleStruckCapitalE][a+\[DoubleStruckCapitalE][
        b y]]}//.rules[y]

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


Using definitions:

Clear[\[DoubleStruckCapitalE]];

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

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

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

{\[DoubleStruckCapitalE][a*y,y],\[DoubleStruckCapitalE][b+
    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 gcn.ou.edu
To: mathgroup at smc.vnet.net
> 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?