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;
NSolve[f'[x] == 0, x, Reals];
Table[D[f[x], {x, n}], {n, 1, 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).
Any help/advice is always appreciated!
Brandon
* I GOT IT!*
Clear[x, roots, x, n, d];
f[x_] = x^8 - 3 x^5 + x - 1;
n = 5;
der = D[f[x], {x, #}] & /@ Range[n];
roots = Table[NSolve[der[[#]] == 0, x, Reals] & /@ Range[n]];
Grid[{der, roots} // Transpose]
Thanks to all.
Derivative[]
? Also, did you look at how to extract the solutions returned byNSolve[]
? $\endgroup$