# How big of an integer does k have to be so that the slope of f(x) at Sqrt[k] is greater than 20?

Here is my function:

f[x_] := x^2 + k*x


I can plot this function to see its behavior but I certainly cannot obtain an answer by this visualization

Plot3D[f[x], {x, 0, 10}, {k, 0, 10}]


I will eventually create a loop for the question at hand, but I want to know what that k value would be in advance before I begin creating my loop that'll find k for me. I guess you could say I'm trying to work backwards.

I tried creating a table (by hand) starting at x = 0, then finding what that equation for f(x) is, then using arbitrary k values to try and come up with something. I'm not sure how I would go about finding a slope from that though.

UPDATE

slope[m_] := (
f[x_] := x^2 + k*x;
g[x_] = D[f[x], x] /. x -> Sqrt[k];
k = 1;
While[g[x] < m, k; k++];
k)
slope[20]

• Well, you can find the slope with f'[Sqrt[k]] and solve for where they're equal with Solve[]. Oct 16, 2016 at 23:38
• That's a good point. Thanks @MichaelE2 Oct 16, 2016 at 23:42

Why not solve it analytically, using the fact that the slope is the derivative?

   f[x_] = x^2 + k*x;
g[k_] = D[f[x], x] /. x -> Sqrt[k];
Solve[g[k] == 20, k]


Then round k to the nearest integer value.

• That's quite handy. Thank you Lauren! Oct 16, 2016 at 23:42
• That was kind of silly on my part not to realize that. Oct 16, 2016 at 23:44
f[x_] := x^2 + k*x
k = 0;
While[(D[f[x], x] /. x -> Sqrt[k]) < 20, k++];
k


13

• very nice, I posted the code I came up with. Thanks! Oct 18, 2016 at 20:05