I have two functions $\vec Q_p$ and $\vec C$, $p \in \mathbb R^3 $,
$$\vec C = \langle \theta, \alpha\rangle$$
$$\vec Q_p = \langle \sqrt{p_x^2 + p_z^2}, -p_y\rangle $$
$\theta$ and $\alpha$ are constants, you can think of $\vec C$ as the terminal side on a circle constrained to quadrant 1. And $p_x, p_y, p_z$ are the relative components of the input point p. The dot of these 2 vectors gives the distance from $\vec Q_p$ to the nearest point on the cone with the angle created by $\vec C$.
When I take the gradient of the dot of these two vector functions using the product rule, I get:
$$\nabla f_p = \langle \frac {x\theta}{\sqrt{x^2 + z^2}}\vec C, -\alpha\vec C, \frac {z\theta}{\sqrt{x^2 + z^2}}\vec C\rangle $$
How is this possible? How can $\vec C$ be part of $\hat i$ and $\hat k$ in the gradient? How can I find the actual gradient?
The fact that this results doesn’t make sense tells you that you made a mistake in your calculation.
Taking the dot product of the constant vector $\vec{C} = ⟨θ, α⟩$ with the vector-valued function $\vec{Q}(x, y, z) = ⟨\sqrt{x^2 + z^2}, -y⟩$ gives us the scalar function $$ f(x, y, z) = \vec{C} ⋅ \vec{Q}(x, y, z) = θ \sqrt{x^2 + z^2} - α y \,. $$ The partial derivatives with respect to $x$, $y$ and $z$ are \begin{align*} \frac{∂ f}{∂ x}(x, y, z) &= \frac{θ}{2 \sqrt{x^2 + z^2}} ⋅ 2x = \frac{θ x}{\sqrt{x^2 + z^2}} \,, \\[0.5em] \frac{∂ f}{∂ y}(x, y, z) &= -α \,, \\[0.5em] \frac{∂ f}{∂ z}(x, y, z) &= \frac{θ}{2 \sqrt{x^2 + z^2}} ⋅ 2z = \frac{θ z}{\sqrt{x^2 + z^2}} \,. \end{align*} The gradient of $f$ is therefore given by $$ (∇f)(x, y, z) = \biggl\langle \frac{θ x}{\sqrt{x^2 + z^2}}, \enspace -α, \enspace \frac{θ z}{\sqrt{x^2 + z^2}} \biggr\rangle = \frac{\langle θ x, \: -α \sqrt{x^2 + z^2}, \ θ z \rangle}{\sqrt{x^2 + z^2}} \,. $$