bre*_*onk 4 wolfram-mathematica
我在Mathematica中有一些用其他表达式定义的表达式.我想采用较大表达式的一些函数,然后根据子表达式得到结果.例:
In[78]:= e1 = x + y;
e2 = 2^e1;
In[80]:= D[e2, x]
Out[80]= 2^(x + y) Log[2]
Run Code Online (Sandbox Code Playgroud)
我希望输出代替2^e1 Log[2]
.我目前正在使用ReplaceAll
如下,但这在我的实际应用程序中使用大约20个子表达式是很麻烦的.
In[81]:= D[e2, x] /. e1 -> E1
Out[81]= 2^E1 Log[2]
Run Code Online (Sandbox Code Playgroud)
如果将e1设置为x + y,则很难获得并保留该形式.因此,如果您真的不需要,可以使用替换规则.
rul = {e1->x+y, e2->2^e1};
revrul = {x+y->e1};
InputForm[D[e2//.rul, x] /. revrul]
Out[5]//InputForm= 2^e1*Log[2]
Run Code Online (Sandbox Code Playgroud)
Daniel Lichtblau Wolfram Research
归档时间: |
|
查看次数: |
490 次 |
最近记录: |