I have a small toy script in Mathematica that I am trying to use to evaluate the pdf of $Y$ where $Y=X^2$, and $X$ is uniformly distributed in $[0,a]$.
The script is,
assum = {a > 0};
Subscript[P, X][x_] := If[Inequality[0, Less, x, LessEqual, a], 1/a, 0];
Y[x_] := x^2
Subscript[F, Y][y_] := Integrate[If[Y[x] <= y, 1, 0]*Subscript[P, X][x],
{x, -Infinity, Infinity}]
Subscript[P, Y][y_] := D[Subscript[F, Y][y], y]
It shows the correct form of the pdf:
In[192]:=
Simplify[Subscript[P, Y][y], assum]
Out[192]=
Piecewise[{{1/(2*a*Sqrt[y]), y > 0 && a^2 >= y}}, 0]
However, it doesn't evaluate the expression correctly:
In[194]:=
Simplify[Subscript[P, Y][a*(a/2)], assum]
During evaluation of In[194]:= General::ivar:a^2/2 is not a valid variable. >>
Out[194]=
D[1/Sqrt[2], a^2/2]
The session, in pretty printing looks like this:

:=wasn't the right way to define functions. – highBandWidth Mar 20 '12 at 05:54=and:=are right way to define functions. There is a big difference between them however, and you should learn the difference. See for example http://mathematica.stackexchange.com/questions/2639/what-is-x-x-trickery andSetDelayed: http://reference.wolfram.com/mathematica/ref/SetDelayed.html – tkott Mar 20 '12 at 10:53=and:=define pattern-based replacement rules, which may look like functions in many cases, but are handled differently internally. Defining actual functions is done usingFunction. Related: http://mathematica.stackexchange.com/questions/704/functions-vs-patterns – David Mar 20 '12 at 17:54