我希望Mathematica返回符号偏导数而不是实际导数。
Prelude> let f x = [not a | a<-[x,not x], a]
Prelude> f True
[False]
Prelude> f False
[False]
上面的代码返回零,但我希望它返回符号相对于rho的[[2,3]]的部分衍生物。
我该怎么做?
答案 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}]
可选地
symbolic2 = StringJoin["D[",
StringTake[ToString[StressMatrix[[2, 3]]], {6, -2}], ",",
ToString@varList[[1, 1]], "]"];
Row[{expr, " = ", symbolic2, " = ", ToExpression[symbolic2]}]
最后
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}]