I am trying to write a loop that will take the first n derivatives (lets say n =3), which outputs a list that will include 1(or more) roots for each derivative.
I haven’t actually set up the loop because I’m not quite sure which I want to use. (Do, For, While, maybe even Table)
Here is what I have so far and I know I will need to use each of these somewhere in my loop.
Clear[x,roots,x,n];
f[x_] = x^8 - 3 x^5 + x - 1; (*function I am using *)
NSolve[f'[x] == 0, x, Reals]; (* this would be for the first derivative *)
Table[D[f[x], {x, n}], {n, 1, 3}] (* I know this is helpful for showing the first n derivatives, here n = 3 *)
I’m just not sure how I should start honestly.. I’ve been having difficulties with loops in Mathematica. Even a simple suggestion as to which loop I should use would be great (I know you could solve this using any of the loops but I’m not that familiar with them yet).. I think N[%] would help me get those roots also.
Thanks for the response. My only concern was, how will I know which roots correspond to which derivatives? This is where I thought using the “AppendTo” command would be useful. This is certainly a step in the right direction and exactly the output I was trying to produce. So thanks again!
Thanks again for your help because I was able to combine what you gave me along with some ideas I was messing around with. Great teamwork and much appreciated!