In the end, what I would like to have is this in Latex Code

\frac{\partial \Theta(U(x),x)}{\partial U(x)} \frac{U(x))}{\partial x} + 
\frac{\partial \Theta(U(x),x)}{\partial x}

and I want to obtain that just from the expression

# Declaration
x = symbols('x')
U, Theta = symbols('U Theta', cls=Function)

# Function to derive
obj_function = Theta(U(x),x)

and derive that w.r.t. "x" which is what mathematically makes sense to me.

On Friday, May 1, 2015 at 1:19:19 PM UTC-5, Isuru Fernando wrote:
>
> Hi,
>
> I'm not sure how to do the substitution, but why do you expect 
>  obj_function.diff(x) to be 
> Derivative(Theta(U(x), x), x) + Derivative(U(x), x)* Derivative(Theta(U(x), 
> x), U(x)) ?
>
> I think the answer you are getting from sympy is not correct.
> obj_function.diff(x) should be the same as Derivative(Theta(U(x), x), x), 
> but that is not what sympy is giving. 
> See, https://github.com/sympy/sympy/issues/8510
>
> CSymPy is giving, 
> Derivative(U(x), x)*Subs(Derivative(Theta(_x, x), _x), (_x), (U(x))) + 
> Subs(Derivative(Theta(U(x), _x), _x), (_x), (x)) 
> which I think should be the correct answer. 
>
> Here what  Subs(Derivative(Theta(U(x), _x), _x), (_x), (x)) means is 
> partial differentiate Theta with respect to the second variable and replace 
> the first variable with U(x) and the second with x. 
> (D[2](Theta)(U(x), x) is the equivalent in Maple syntax or Derivative[0, 
> 1][Theta][U[x], x] in Mathematica syntax)
>
> Isuru Fernando
>
>
> On Fri, May 1, 2015 at 8:16 PM, Miguel Angel Salazar de Troya <
> [email protected] <javascript:>> wrote:
>
>> Hello
>>
>> I have this derivative of a function that has an argument which is also a 
>> function
>>
>> # Declaration
>> x = symbols('x')
>> U, Theta = symbols('U Theta', cls=Function)
>>
>> # Function to derive
>> obj_function = Theta(U(x),x)
>>
>> # Derivative
>> gradient_obj_function = obj_function.diff(x)
>>
>> And this is the output I obtain
>>
>> Derivative(Theta(U(x), x), x) + Derivative(U(x), 
>> x)*Subs(Derivative(Theta(_xi_1, x), _xi_1), (_xi_1,), (U(x),))
>>
>> How can I replace Subs(Derivative(Theta(_xi_1, x), _xi_1), (_xi_1,), 
>> (U(x),)) with Derivative(Theta(U(x), x), U(x)) ?
>> I found this post, 
>> https://groups.google.com/forum/#!searchin/sympy/"chain$20rule"/sympy/OfF5PklJtmY/t1FPWt3n8xIJ,
>>  
>> but it was not clear to me how this has to be done. 
>>
>> Thanks
>> Miguel
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] <javascript:>
>> .
>> Visit this group at http://groups.google.com/group/sympy.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sympy/5d9dfd23-be1a-4a08-9289-43562d0062f5%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sympy/5d9dfd23-be1a-4a08-9289-43562d0062f5%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/166ab624-e5ac-4b1c-9ef0-dcdb244e7f7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to