What is the difference between variable "t" and variable "y" ?

I am trying to define a function of variables “x” and “t” and take partial derivatives with respect to each. The function is as follows:

f[x_,t_]=Cos[x-t]

When defining the function using variable “t” the output becomes:

Cos[t-x]

Then taking the partial derivative w.r.t “t” using D[f,t] returns 0 (zero).

Substituting variable “y” for “t” returns a different (correct in my eyes) result.

So my question is; What is the difference in the eyes of mathematica, to the variables “t” and “y” (or really any other variable that I could define)?

I’ve posted screenshots to show exactly what my inputs were. Thank you so much in helping me better understand this.

Look at your two examples carefully. In the first case you computed

D[f,t]

rather than

D[f[x,t],t]

By the way, you should define your functions using delayed evaluation (:=) rather than immediate evaluation (=)

Thank you,
I thought I had tried that before moving on to using variable “y”. I guess I didn’t though as D[f[x,t],t] works just fine. My mistake.

Why is using delayed evaluation advantageous over immediate evaluation?

You can read up on some of the differences between = and := here: