Message Boards Message Boards

0
|
259 Views
|
6 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Using symbolic calculation result to evaluate real expression

I define a vector with 4 components, indicating their dependencies:

A = {At[t, x, y, z], Ax[t, x, y, z], Ay[t, x, y, z], Az[t, x, y, z]}

Then I tell it to take the partial derivative of the first element with respect to t:

\!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\(A[[\(1\)\(]\)]\)\)

It gives the correct answer as a superscript:

\!\(\*SuperscriptBox[\(At\), 
TagBox[
RowBox[{"(", 
RowBox[{"1", ",", "0", ",", "0", ",", "0"}], ")"}],
Derivative],
MultilineFunction->None]\)[t, x, y, z]

But when I ask it to evaluate that derivative for a concrete case, it gives nonsense:

\!\(\*SuperscriptBox[\((
\*SuperscriptBox[\(t\), \(2\)] + 
\*SuperscriptBox[\(x\), \(3\)] + 
\*SuperscriptBox[\(y\), \(4\)] + 
\*SuperscriptBox[\(z\), \(5\)])\), 
TagBox[
RowBox[{"(", 
RowBox[{"1", ",", "0", ",", "0", ",", "0"}], ")"}],
Derivative],
MultilineFunction->None]\)[t, x, y, z]

See attached screenshot as the symbolism doesn't show well what I am doing.

Attachment

Attachments:
POSTED BY: Thomas Fowler
6 Replies

Try At -> Function[{t, x, y, z}, t^2 + x^3 + y^4 + z^5]. The symbol At appears as a function, not a formula.

For posting the code, try Edit > Copy As > Input Text or converting to InputForm. The boxes are rather hard to read. It also should be formatted as code in MarkDown, or it won't copy reliably.

POSTED BY: Michael Rogers

Thanks! That works! The superscript method of indicating derivatives does not seem to be well-documented. It's great that you understand how the symbols in these formulas behave.

POSTED BY: Thomas Fowler

You're welcome! BTW, indicating partial derivatives with a vector of nonnegative integers (sometimes called a "multi-index") is a standard notation in higher mathematical analysis, often first encountered in grad school. So it's standard but not commonly known. Your implicit suggestion that it be mentioned in the documentation seems a good one, perhaps on the pages for D and for Derivative. The "Details" section often mention how certain symbols are formatted. Another tip: You can use FullForm to see that the partial derivative is in fact Derivative[1, 0, 0, 0][At][t, x, y, z], but the Front End displays in the standard, if arcane, notation.

POSTED BY: Michael Rogers

Yes thanks again Mr. Rogers. I have a doctorate in EE, but I never encountered that superscript notation before. However, I wasn't using partial derivatives much because I was working in control and chaos theory. Anyway it would be good if Mathematica gave the option of standard partial derivative notation instead of the superscript notation.

POSTED BY: Thomas Fowler

I know you weren't asking for the following, but it writes the derivatives of At in the way you'd like, I think:

MakeBoxes[Derivative[i_, j_, k_, l_][At][tt_, xx_, yy_, zz_], 
  TraditionalForm] := Block[{t, x, y, z},
  MakeBoxes[D[At[tt, xx, yy, zz], ##], TraditionalForm] & @@ 
   DeleteCases[{{t, i}, {x, j}, {y, k}, {x, l}} /. {v_, 1} :> v, {_, 0}]
  ];

D[At[t, x, y, z], t, t, x] // TraditionalForm
(* shows the traditional Leibniz form of the partial derivative *)

Of course it works only for At. There are issues implementing it in general. Like determining the symbol names for the arguments of every function that might be differentiated at some time by some user.

POSTED BY: Michael Rogers

Thanks again! I'll try this to see if it will scale. Otherwise I'll just get used to the existing method!

POSTED BY: Thomas Fowler
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract