I know loops aren't the best choice in Mathematica, there's a lot of great built in functions to use, but there are times when procedural programming is necessary or just to do for a challenge. I've posted several previous questions utilizing loops but I still struggle using them.
I am attempting to create a loop that will find the biggest value for k so that the slope of f(x) at Sqrt[k] is greater than some arbitrary value, we can call it 5 in this case..
So here is what I have so far..This is the function along with a visualization of the function, not like I can visually see where this k value would be located but I enjoy visuals.
Clear[f, x, k, g, integer]
f[x_] := x^2 + k*x
Plot3D[f[x], {x, 0, 10}, {k, 0, 10}, ColorFunction -> "Rainbow"]
In addition, I was able to work out this problem without using a loop, but I am very curious how I could use procedural programming in this case.
g[k_] = D[f[x], x] /. x -> Sqrt[k];
integer := N[Solve[g[k] == 5, k]]
integer
= 2.10102
I would of course round this value to 3 because 2 would not satisfy the condition.
I probably have most of the code already here, I at least it could be used in the loop somewhere.
Does anyone have any pointers? I know loops aren't everyone's first choice.