I have a Calculus problem that I am not entirely happy with how I solved it.
Given the following information:
$$y = x^{k} + x^{k-2}$$
$$(k \in \mathbb{N}) \wedge (k \mod{2} \neq 0) \wedge (k > 1) \wedge (x=-1 \rightarrow \frac{dy}{dx}=8)$$
First, I computed the first derivative of y in respect to x using the Power Rule. $$\frac{dy}{dx}=kx^{k-1}+(k-2)x^{k-3}$$
Second, I substituted $x=-1$ and $\frac{dy}{dx}=8$. This is as far as I got before I started looking for answers by just searching/guessing. $$8=k(-1)^{k-1}+(k-2)(-1)^{k-3}$$
Third, I used a Python lambda function and a list comprehension to search for a value of k that satisfied the available equations and premises. Searching from $3$ to $100$ was just a guess.
>>> f = lambda k: k*(-1)**(k-1) + (k-2)*(-1)**(k-3)
>>> [i for i in range(3,100) if (i % 2 != 0) and (f(i) == 8)]
[5]
Thus, $$k=5$$
Is there a more analytic way of finding the value of $k$?
$k \mod 2 \ne 0$ means that $(k-1) \mod 2 = 0$ and $(k-3) \mod 2 = 0$. So $(-1)^{k-1}=(-1)^{k-3}=1$. Then your equation becomes $8=k+k-2$, with the solution $k=5$