I had learnt that differentiating the function $y=f(x)$ and putting the value of a point $(x_1,y_1)$ would give the slope of the tangent to the function at $(x_1,y_1)$. In other words, to find the slope of the tangent to a function at a point, one has to first differentiate the dependent variable ($y$ here) with respect to the independent variable ($x$ in this case). $$$$However when I tried to derive the formula for the slope of the tangent to the parabola $y^2=4ax$, I came up with a mistake in finding the slope of the tangent. In my book, it was given that the slope of the tangent at $(x_1,y_1)$ is $\frac{dy}{dx}\large{|}_{y_1}$ However, according to me, the slope of the tangent should be found by differentiating the dependent variable (x according to me) with respect to the independent variable (y according to me). Thus, I get the slope of tangent as $$\dfrac{y_1}{2a}$$ instead of $\dfrac{2a}{y_1}$. $$$$I cannot identify where I have gone wrong despite trying for quite a while. I would be grateful for any help in clearing this confusion of mine. Many thanks in advance!
PS. I have a rudimentary knowledge of functions. All I know is that a function is such that corresponding to each independent variable, there is only 1 value of the dependent variable. The reason I thought $y$ was the independent variable in $y^2=4ax$ was because corresponding to any value of $y$, there is only one possible value of $x$. Kindly correct me if I am wrong. Thanks once again
Notice, in general, the slope of tangent to the curve $y=f(x)$ is $\frac{dy}{dx}$ & usually, $y$ is treated as a dependent variable & $x$ as independent variable in XY-plane.
For the slope of tangent to the curve: $y=f(x)$, one should find $\frac{dy}{dx}$ not $\frac{dx}{dy}$
Now, for the given equation of parabola $y^2=4ax$, $y$ is dependent variable while $x$ is independent variable, hence the slope of tangent to the parabola: $y^2=4ax$ is given by differentiating w.r.t. $x$ as follows $$\frac{d}{dx}(y^2)=\frac{d}{dx}(4ax)$$ $$2y\frac{dy}{dx}=4a$$ $$\frac{dy}{dx}=\frac{2a}{y}$$ for the point $(x_1. y_1)$, the slope of tangent is
$$\left[\frac{dy}{dx}\right]_{(x_1, y_1)}=\frac{2a}{y_1}$$