3
$\begingroup$

I am new to Mathematica, but not so new to programming. What I'd like to do in Mathematica (not using an API) is to display on each line, the nth derivative of a function, e.g. for n = 1..10. Is there a way to accomplish this in Mathematica? (without explicitly typing the command for each derivative of course. e.g. does Mathematica have iterative constructs to do this).

$\endgroup$
  • $\begingroup$ Column[D[Sin[x] Log[x], {x, #}] & /@ Range[10]] ? $\endgroup$ – b.gates.you.know.what Aug 18 '12 at 16:49
  • $\begingroup$ @b.gatessucks looks good; how about: Print@D[Sin[x] Log[x], {x, #}] & ~Array~ 10; ? $\endgroup$ – Mr.Wizard Aug 18 '12 at 16:51
  • $\begingroup$ ...or Scan[Print[D[Sin[x] Log[x], {x, #}]] &, Range[10]] or Do[Print[D[Sin[x] Log[x], {x, k}]], {k, 10}]. $\endgroup$ – J. M. will be back soon Aug 18 '12 at 16:56
  • $\begingroup$ @J.M. not enough infix. :^) $\endgroup$ – Mr.Wizard Aug 18 '12 at 16:57
  • $\begingroup$ @Mr.Wizard, but I am forced to think when reading infix... ;) $\endgroup$ – J. M. will be back soon Aug 18 '12 at 16:59
3
$\begingroup$

Avoiding cleverness as much as possible, you can just use a Do loop:

Do[Print[D[Exp[-a*x], {x, n}]], {n, 0, 10}]

Mathematica graphics

Or for example

Grid@(List@D[Exp[-a*x], {x, #}] & /@ Range[0, 10])

Mathematica graphics

etc

$\endgroup$
2
$\begingroup$

"Iteratively differentiate" cries out Nest[] to me,....

Print /@ NestList[D[#, x] &, Exp[-a*x], 10];

Mathematica graphics

Or substitute CellPrint@ExpressionCell[#, "Output"] & for Print for different styling.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.