Ondrej Certik wrote:
> On Tue, Oct 7, 2008 at 12:07 AM, Alan Bromborsky <[EMAIL PROTECTED]> wrote:
>   
>> Ondrej Certik wrote:
>>     
>>> On Mon, Oct 6, 2008 at 11:28 PM, Alan Bromborsky <[EMAIL PROTECTED]> wrote:
>>>
>>>       
>>>> Suppose I have two symbols A and B that I wish to declare implicit
>>>> functions of say the symbols x1, x2, and x3.  Then I wish to calculate
>>>> the derivative of A*B with respect to x1 and x2 and x3.  Can I do this
>>>> and if so how?
>>>>
>>>>         
>>> Yes, for example this way:
>>>
>>> In [2]: A = Function("A")
>>>
>>> In [3]: B = Function("B")
>>>
>>> In [4]: var("x1 x2 x3")
>>> Out[4]: (x₁, x₂, x₃)
>>>
>>> In [5]: f = A(x1, x2, x3)*B(x1, x2, x3)
>>>
>>> In [6]: f
>>> Out[6]: A(x₁, x₂, x₃)⋅B(x₁, x₂, x₃)
>>>
>>> In [7]: diff(f, x1)
>>> Out[7]:
>>>                d                                  d
>>> A(x₁, x₂, x₃)⋅───(B(x₁, x₂, x₃)) + B(x₁, x₂, x₃)⋅───(A(x₁, x₂, x₃))
>>>               dx₁                                dx₁
>>>
>>>
>>>
>>>
>>> Ondrej
>>>
>>>       
>> Is there anyway of suppressing the arguments so you could write f = A*B
>> and then d(A*B)/dx1 = dA/dx1*B+A*dB/dx1.  I guess what I am saying is
>> that writing A(x1,x2,x3)  could get very long especially if the A's and
>> B's are components of vectors or matrices and you are differentiating
>> all of them.  It would be very useful to declare the independent
>> variables when you declare A as a function so you do not have to write
>> out A(x1,x2,x3) every time you use A in an expression or differentiate it.
>>     
>
> Like below?
>
> In [1]: var("x1 x2 x3")
> Out[1]: (x₁, x₂, x₃)
>
> In [2]: A = Function("A")(x1, x2, x3)
>
> In [3]: B = Function("B")(x1, x2, x3)
>
> In [4]: f = A*B
>
> In [5]: diff(f, x1)
> Out[5]:
>                d                                  d
> A(x₁, x₂, x₃)⋅───(B(x₁, x₂, x₃)) + B(x₁, x₂, x₃)⋅───(A(x₁, x₂, x₃))
>               dx₁                                dx₁
>
>
>
> Ondrej
>
> >
>   
Yes almost, but can you suppress the (x1,x2,x3) in the output so that 
the output would be

A*dB/dx1+B*dA/dx1 ?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to