Directly going from the line element to a coordinate invariant function? Background and Question
I came up with an algorithm which enables me to go from $ds^2 \to K$ where $K$ is a coordinate invariant quantity. Is the below conjectured algorithm always right? If so, why does it work? What is $K$ geometrically
Algorithm with Example
Consider the following line element:
$$ ds^2 = dx^2 + dy^2 $$
We want the metric to scale by $\lambda$ so we apply the following transformations:
$$x \to \sqrt{\lambda} x $$
$$y \to \sqrt{\lambda} y $$
Thus we have,
$$ ds^2 \to \lambda ds^2 $$
Replace all the differentials of transformed variables with $dx \to x $ and $dy \to y $ if a variable does not take part in the transformation then replace it with $0$. Thus,
$$K = x^2+ y^2 $$
Where $s$ is the displacement vector. Now let us try another line element:
$$ ds^2 = u^2(1+\frac{1}{u^4})dt^2 + t^2(1+\frac{1}{u^4})du^2 + 2ut(1-\frac{1}{u^4}) du dt$$
To achieve $ds^2 \to \lambda ds^2$ we use $t \to \sqrt{\lambda} t $ since $du$ does not take part in the transformation we put $0$ and since $t$ does we replace $dt \to t$ and get:
$$ K = u^2(1+\frac{1}{u^4})t^2 = u^2 t^2 + \frac{t^2}{u^4}$$
Note: Since $x=tu$ and $y=t/u$ this suggests our output is coordinate invariant as $K$ should be. Hence,
$$K  = u^2 t^2 + \frac{t^2}{u^4} = x^2 + y^2$$
 A: That's just because the line element is nothing but the metric tensor, so the inner product of two vectors $a=\sum_i a^ie_i,b=\sum_i b^ie_i$ with respect to the metric tensor $ds^2=\sum_{ij}g_{ij}dx^idx^j$ is just
$$ds^2(a,b) = \sum_{ij}g_{ij}a^ib^i.$$
Hence what you are doing using the line element to calculate the (squared) length of a tangent vector $ds^2(v,v)$.
The "rescaling" you are doing is actually assigning to every point $(x,y)$ the tangent vector $v=(\sqrt\lambda x,\sqrt\lambda y)$.
(You can see this as the "infinitesimal flow" of the rescaling, but this is not very precise and you shouldn't take it so seriously).
Then
$$\begin{aligned}
ds^2(v,v)
&=(dx^2+dy^2)(\sqrt\lambda x,\sqrt\lambda y) \\
&=(\sqrt\lambda x)^2+(\sqrt\lambda y)^2 \\
&= \lambda (x^2+y^2)
\end{aligned}$$
Now, if you change coordinates to $x=tu$, $y=t/u$, then the same vector $v=(\sqrt\lambda x,\sqrt\lambda y)$ has coordinate representation $v=(\sqrt\lambda t,0)$, so that applying the line element yields
$$\begin{aligned}
ds^2(v,v)
&=\left(
u^2(1+u^{-4})dt^2 + t^2(1+u^{-4})du^2 + 2ut(1-u^{-4}) du dt
\right)(\sqrt\lambda t,0) \\
&= u^2(1+u^{-4})(\sqrt\lambda t)^2 + t^2(1+u^{-4})(0)^2 + 2ut(1-u^{-4}) (0)(0) \\
&= u^2(1+u^{-4})(\sqrt\lambda t)^2 \\
&= \lambda(t^2u^2+t^2u^{-2}).
\end{aligned}$$
Obviously this is invariant, since the length of a vector does not depend on the coordinate system.
