防止导数输出中的重新排序?
关于Wolfram Blog 提供了以下功能,以更传统的方式格式化导数。
pdConv[f_] :=
TraditionalForm[
f /. Derivative[inds__][g_][vars__] :>
Apply[Defer[D[g[vars], ##]] &,
Transpose[{{vars}, {inds}}] /. {{var_, 0} :>
Sequence[], {var_, 1} :> {var}}]
]
示例使用 Dt[d[x, a]] // pdConv
给出:
在不破坏 pdConv 的一般功能的情况下,有人可以改变它来维持给定的变量顺序,产生如下所示的输出吗 (当然,这纯粹是出于审美原因,使推导更容易让人理解)
我怀疑这一点实现起来并不简单——除非有人知道可以在Block
内临时覆盖的神奇Global
选项。
无论如何,这些问题可能是相关的:
A recent post on the Wolfram Blog offered the following function to format derivatives in a more traditional way.
pdConv[f_] :=
TraditionalForm[
f /. Derivative[inds__][g_][vars__] :>
Apply[Defer[D[g[vars], ##]] &,
Transpose[{{vars}, {inds}}] /. {{var_, 0} :>
Sequence[], {var_, 1} :> {var}}]
]
An example use, Dt[d[x, a]] // pdConv
gives:
Without breaking the general capabilities of pdConv
, can someone alter it to maintain the given order of variables, producing the output shown below? (of course this is purely for asthetic reasons, making derivations easier for a human to follow)
I suspect this will be nontrivial to implement---unless someone knows of a magical Global
option that can be temporarily overridden within a Block
.
For what it's worth, these SO questions may be related:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可能有一种更简洁的方法来执行 s,但如果纯粹出于演示目的,您可以执行类似的操作,
此处,额外参数
vv
是f
中的变量列表> 按照您希望偏导数出现的顺序。要使用此功能,您可以执行类似的操作 基本上,此解决方案的作用是暂时替换列表变量
vv
包含按正确字典顺序排列的虚拟变量列表,应用转换,然后用原始变量替换虚拟变量,同时通过将转换后的表达式包装在中来保留所需的顺序HoldForm
。There is probably a cleaner way to do s, but if it's purely for presentation purposes, you could do something like
Here, the extra parameter
vv
is a list of the variables inf
in the order you want the partial derivatives to appear. To use this function, you would do something likeBasically what this solution does is to temporarily replace the list of variables
vv
with a list of dummy variables which are in the right lexicographical order, apply the transformation, and then replace the dummy variables with the original variables while preserving the desired order by wrapping the transformed expression inHoldForm
.在看到 Heike 更先进的方法后进行了修改。希望不要打破它。
用途:
窄箱自动订购:
用途:
Revised after seeing Heike's far superior method. Hopefully without breaking it.
Use:
Automatic ordering for a narrow case:
Use:
我意识到 Dt[d[x, a, c, b]] 已经给出了有序输出,只是相反。我可能误解了这种情况,但对于某些情况,这似乎就足够了:
I realized that
Dt[d[x, a, c, b]]
already gives ordered output, just in reverse. I am probably misunderstanding the situation, but for some cases this appears to be sufficient: