我在Mathematica中有一些用其他表達式定義的表達式。我想要採用較大表達式的一些函數,然後根據子表達式得到結果。例如:在Mathematica中用它們的名稱替換表達式
In[78]:= e1 = x + y;
e2 = 2^e1;
In[80]:= D[e2, x]
Out[80]= 2^(x + y) Log[2]
我想輸出爲2^e1 Log[2]
。我目前使用ReplaceAll
如下,但這在我的實際應用中很麻煩,大約有20個子表達式。
In[81]:= D[e2, x] /. e1 -> E1
Out[81]= 2^E1 Log[2]