如何在mathematica中获得偏导数符号

时间:2017-06-01 23:06:26

标签: wolfram-mathematica mathematica-8

我希望Mathematica返回符号偏导数而不是实际导数。

Prelude> let f x = [not a | a<-[x,not x], a]
Prelude> f True
[False]
Prelude> f False
[False]

上面的代码返回零,但我希望它返回符号相对于rho的[[2,3]]的部分衍生物。

我该怎么做?

2 个答案:

答案 0 :(得分:0)

您可以使用Inactivate

Inactivate[D[StressMatrix[[2, 3]], varList[[1, 1]]]]

Hold

Hold[D[StressMatrix[[2, 3]], varList[[1, 1]]]]

答案 1 :(得分:0)

各种方法,包括指定值(需要在保持后设置)。

Clear[σ23]

StressMatrix = Map[Hold,
   {{σ11, σ12, σ13}, {σ21, σ22, σ23}, {σ31, σ32, σ33}}, {2}];
varList = {{ρ, θ, z}};

σ23 = 4 ρ^2;

expr = StandardForm[
   "∂" <> StringTake[ToString[StressMatrix[[2, 3]]], {6, -2}]/
    "∂" <> ToString[varList[[1, 1]]]];

symbolic = Inactive[D][ReleaseHold@StressMatrix[[2, 3]], varList[[1, 1]]];

result = D[ReleaseHold@StressMatrix[[2, 3]], varList[[1, 1]]];

Row[{expr, " = ", symbolic, " = ", result}]

enter image description here

可选地

symbolic2 = StringJoin["D[",
  StringTake[ToString[StressMatrix[[2, 3]]], {6, -2}], ",", 
  ToString@varList[[1, 1]], "]"];

Row[{expr, " = ", symbolic2, " = ", ToExpression[symbolic2]}]

enter image description here

最后

Clear[σ23]

StressMatrix = 
  Map[HoldForm, {{σ11, σ12, σ13}, {σ21, σ22, σ23}, {σ31, σ32, σ33}}, {2}];
varList = {{ρ, θ, z}};

σ23 = 4 ρ^2;

expr = StandardForm[
   "∂" <> ToString[StressMatrix[[2, 3]]]/
    "∂" <> ToString[varList[[1, 1]]]];

symbolic = Inactive[D][ToString@StressMatrix[[2, 3]], varList[[1, 1]]];

result = D[ReleaseHold@StressMatrix[[2, 3]], varList[[1, 1]]];

Row[{expr, " = ", symbolic, " = ", result}]

enter image description here