Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.2K Views
|
2 Replies
|
1 Total Like
View groups...
Share
Share this post:

[?] Add a result of expression's differentiation result to string variable?

Posted 7 years ago
POSTED BY: Dmitriy K
2 Replies
Posted 7 years ago

This question was also asked on StackOverflow. See answer.

May not be exactly what you are looking for, but should be easy to modify.

derivativeGrid[f_Function, xmax_Integer, ymax_Integer] := 
 Module[{derivatives, rowHeader, columnHeader, grid},
  derivatives = 
   Table[D[f[x, y], {x, i}, {y, j}], {i, 0, xmax}, {j, 0, ymax}];
  columnHeader = Table["dx"^x, {x, 0, xmax}];
  rowHeader = Join[{""}, Table["dy"^y, {y, 0, ymax}]];
  grid = MapThread[Prepend, {Prepend[derivatives, columnHeader], rowHeader}];
  Grid[grid, ItemStyle -> {{1 -> Bold}, {1 -> Bold}}, 
   Background -> {{LightYellow, None}, {LightYellow, None}}, 
   Frame -> All]]

Since it computes derivatives of a function of two arguments f[x, y], it needs to be passed a function of two arguments.

derivativeGrid[Sin[#1*#2] &, 3, 3]

enter image description here

POSTED BY: Rohit Namjoshi
Posted 7 years ago
POSTED BY: Dmitriy K
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard