Your answer seems concrete due to the simple form of your e1 and e2 . One possibility is to define e2 as a function in terms of e1 without indicating that e1 :
In[8]:= Clear[e1, e2]; e2[x_] := 2^e1[x]
Then
In[10]:= D[e2[x], x] Out[10]= 2^e1[x] Log[2] Derivative[1][e1][x]
which is generally the right answer. As soon as you want to calculate it, you can specify a specific definition for e1 . You can also do this inside Block , so as not to introduce global definitions:
In[11]:= Block[{e1}, e1[x_] := x + y; D[e2[x], x]] Out[11]= 2^(x + y) Log[2]
I guess this approach can scale to more subexpressions.
NTN
source share