2
$\begingroup$

Using the TableForm command, I want to find the derivatives up to the fourth order of the function $f(x)=\cos{x^2}/x$ and give the results in Matrix form.

$\endgroup$
2
  • $\begingroup$ Exactly what Mathematica code did you use? Was it this? TableForm[Table[D[Cos[x]^2/x,{x,n}],{n,1,4}]] Why do you need this in any "Form" Often using "Form" causes more trouble, not less, but I realize that many feel they MUST desktop publish their result. Exactly what did you do and Exactly what is wrong with it and Exactly what do you really have to have? $\endgroup$
    – Bill
    Nov 27, 2022 at 20:13
  • $\begingroup$ My friend alwyas check Wolfram Doc to learn how to use functions reference.wolfram.com/language/ref/Table.html Also the best way ever to learn coding is to try and practice it!!!! $\endgroup$
    – Alrubaie
    Nov 27, 2022 at 20:16

3 Answers 3

3
$\begingroup$

Many ways to do this. One is

f[x_] := Cos[x^2]/x
data = {TraditionalForm[HoldForm@D[f[x], {x, #}]], 
     TraditionalForm[D[f[x], {x, #}]]} & /@ Range[4];
PrependTo[data, {Row[{TraditionalForm[HoldForm@f[x]], "=", 
    TraditionalForm[f[x]]}], "output"}]
Grid[data, Frame -> All]

Mathematica graphics

You did not say if this is for display only or not. If you want to use the data, then you can remove the Grid part. If it is for display only, you can also use TeXForm and MaTeX to make nice Latex table with caption title and figure numbers to include in your latex document so you can reference the table from other places in the document.

$\endgroup$
3
$\begingroup$
Clear["Global`*"]

f[x_] := Cos[x^2]/x

Using MatrixForm (note that the "forms" are not included in the scope of the definition of mat)

(mat = NestList[{#[[1]] + 1, Simplify[D[#[[2]], x]]} &, {0, f[x]}, 
     4]) // TraditionalForm // MatrixForm

enter image description here

Using TableForm

TableForm[mat, 
  TableHeadings -> {None, {n, 
     Superscript[f, "(n)"][x]}}] // TraditionalForm

enter image description here

$\endgroup$
1
$\begingroup$

Using FoldList while calculating derivs in addition to mostly borrowed formatting techniques:

f[x_] := Cos[x^2]/x
n = 5;
derivs = FoldList[D[#, x] &, f[x], Range[n]];
ops = TraditionalForm@HoldForm[Derivative[#][f][x]] & /@ Range[0, n];
data = Transpose@{TraditionalForm /@ Range[0, n], ops, 
    TraditionalForm /@ derivs};

Grid[#, Frame -> All
   , Alignment -> {Center, Center}
   , Spacings -> {1, 2}
   , ItemSize -> {{Scaled[.1], Scaled[.1], Scaled[0.8]}}
   ] &@
 PrependTo[data
  , TraditionalForm /@ {"n", Superscript[f, "(n)"][x], "Output"}
  ]

enter image description here

$\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.