# Getting different plot results from wolfram alpha and mathematica [closed]

I'm trying to draw this function: $$f(x) = x(\theta(x-1)-\theta(x-2))$$ Where $$\theta(x)$$ denotes the Heaviside theta function, in mathematica I wrote the function this way:

f[x_] = xHeavisideTheta[x - 1] - xHeavisideTheta[x - 2]
Plot[f[x], {x, 0, 10}]


But then this is the plot that I get in Mathematica:

Whereas in wolfram alpha I get this following plot:

What am I doing wrong in mathematica?

• just add space after the x like this !Mathematica graphics i.e. change xHeavisideTheta[x - 1] to x *HeavisideTheta[x - 1] Dec 26, 2022 at 17:09
• @Nasser Thank you I just had to add the * without the space to get it to work, I thought it would automatically multiply without the * like when I multiply a variable by a constant Dec 26, 2022 at 17:14
• Without either a space or an asterisk, xHeavisideTheta is a single symbol. Mathematica will not try to guess what you mean. Dec 26, 2022 at 17:27

f[x_] := x HeavisideTheta[x - 1] - x HeavisideTheta[x - 2]