I am not perfectly sure that the following code evaluate the implicit differentiation of the function UU
. In all case what I expect is to fint $\partial w_2/ \partial w_1$ and then $\partial w_2^2/ \partial^2 w_1$
U=function('U')(x)
w2=function('w2')(w1)
U=U(x)
UU=p*U(w1)+(1-p)*U(w2)
diff(UU, w1)
then I would like to substitute $U(x) = log(x)$ or $U(x) = x^a$ or $U(x) = -\exp(-ax)$. And as an implied question, I would like to know how to select part of an expression like for instance $\exp(ax + b)+ f(x) -> a, \text{ or } a*x \text{ or } f(x)$. As every expression in Mathematica is a three, is not difficult to saw a branch. But in Sagemath I wonder how to do.