I am trying to define a function $\mathbb{E}_t$ such that $\mathbb{E}_{t}[f[x_{s}]] = f[x_{s}]$ if s<=t, and $\mathbb{E}_{t}[f[x_{s}]] = \mathbb{E}_{t}[f[x_{s}]]$ if s>t. $\mathbb{E}_{t}$ is linear such that $\mathbb{E}_{t}[x_{s}+y_{r}]=\mathbb{E}_{t}[x_{s}]+\mathbb{E}_{t}[y_{r}]$ and $\mathbb{E}_{t}[x_{s}*y_{r}]=\mathbb{E}_{t}[x_{s}]*\mathbb{E}_{t}[y_{r}]$

I tried (f:->x in this definition)

$\mathbb{E}_{t\_}[x_{s\_}] := If[Refine[t>s,Elment[\{t,s\},Reals]],x_{s},HoldForm[\mathbb{E}_{t}[x_{s}] ]]$ and $\mathbb{E}_{t\_}[x\_+y\_]:=\mathbb{E}_{t}[x]+\mathbb{E}_{t}[y]$ and $\mathbb{E}_{t}[x\_*y\_]:=\mathbb{E}_{t}[x]*\mathbb{E}_{t}[y]$

It works for the simple cases. However, it gives


instead of


I suspect the reason is because the head of x*y is not the same as x^2. Is there an easier way to define such a function? I hope $\mathbb{E}_{t}$ will work for a more general function f. I used HoldForm so that I do not get an infinite loop.

  • 1
    $\begingroup$ Could you please reformat your code in a form that is copy and pastable (e.g. using the { } tool). $\endgroup$ – GerardF123 Jan 4 at 16:27
  • $\begingroup$ Subscript[[DoubleStruckCapitalE], s_][Subscript[x_, t_]] := If[Refine[s < t, Element[{t, s}, Reals]], HoldForm[Subscript[[DoubleStruckCapitalE], s][Subscript[x, t]]], Subscript[x, t]]; Subscript[[DoubleStruckCapitalE], s_][x_ + y_] := Subscript[[DoubleStruckCapitalE], s][x] + Subscript[[DoubleStruckCapitalE], s][y]; Subscript[[DoubleStruckCapitalE], s_][x_y_] := Subscript[[DoubleStruckCapitalE], s][x] Subscript[[DoubleStruckCapitalE], s][y] $\endgroup$ – cheng liu Jan 4 at 16:46
  • $\begingroup$ Your rule is too ambiguous to work for any f, consider a definition with additional arguments, $\mathbb{E}_{t\_}[expr\_,x\_,s\_]$ for example. $\endgroup$ – swish Jan 5 at 1:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.