1
$\begingroup$

My question is fairly basic, namely can I do the substitution below? $$ \frac{\mathrm{d}\theta(t)}{\mathrm{d}t} = -\frac{1}{\sin(\theta(t))}\frac{\mathrm{d}\cos(\theta(t))}{\mathrm{d}t} $$ If not, what corrections should I take into account? Since I am dealing with trigonometric functions there might be a sign-rule somwhere the I am missing.

Background information to the question: In reality I want to calculate the gradient of the angle $\theta$ between two vectors $\vec{a}$ and $\vec{b}$, with respect to the coordinates to one of the vectors. I use the chain rule because then I can use the relationship:$$\cos(\theta) = \frac{\vec{a}\cdot\vec{b}}{\|\vec{a}\|\|\vec{b}\|}$$ which allows me to easily calculate this derivative analytically. However, when I compare my result to a fully numerical calculation the results are not generally the same.

More details

In full I am looking for the gradient of a function $f(d,r,\theta)$, where the values of $d$, $r$ and $\theta$ are determined based on three vectors $\vec{x}$, $\vec{y}$ and $\vec{z}$. The values are given by: $d=|\vec{x}-\vec{y}|$, $r = |\vec{z}-\vec{y}|$ and $\theta$ by the angle between the vectors $\vec{a} = \vec{x}-\vec{y}$ and $\vec{b}=\vec{z}-\vec{y}$. The gradient I am looking at is with respect to the $\vec{y}$ vector, resulting in: $$ \nabla_{\vec{y}}f = -\frac{\partial f}{\partial d}\frac{\vec{x}-\vec{y}}{|\vec{x}-\vec{y}|} -\frac{\partial f}{\partial r}\frac{\vec{z}-\vec{y}}{|\vec{z}-\vec{y}|} + \frac{\partial f}{\partial \theta}\nabla_{\vec{y}}\theta, $$ where $\theta$ is given by the formula above.

If I calculate the gradient using the direct derivative (original question) or fully numerical I seem to have different results.

$\endgroup$
2
  • $\begingroup$ I think you might have to give more detail of what you are doing to get a useful answer. $\endgroup$ Oct 19, 2018 at 9:38
  • 1
    $\begingroup$ @Mark Bennet, better? $\endgroup$
    – Nick
    Oct 19, 2018 at 12:31

1 Answer 1

1
$\begingroup$

Yes, $\frac{d cos(\theta(t))}{dt}= -sin(\theta)\frac{d\theta}{dt}$ so, as long as $sin(\theta(t))\ne 0$, $\frac{d\theta}{dt}= -\frac{1}{sin(\theta(t))}\frac{d cos(\theta(t))}{dt}$

$\endgroup$
1
  • $\begingroup$ Thanks, That was exactly what I was thinking as well. For the special cases of $\theta$ equal to 0 and $\pi$ i have exception rules, so that should not be an issue. $\endgroup$
    – Nick
    Oct 19, 2018 at 12:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .