diff f(x)

3 views
Skip to first unread message

czbeb...@yahoo.co.jp

unread,
Dec 28, 2009, 2:04:18 AM12/28/09
to sympy, o...@bpe.es.osaka-u.ac.jp
Dear members,

When function f is a function of x, sympy diff output is diff(f,x) =
0.
I hope output should be dx(f). Is this output possible for current
sympy ?

czbebe

smichr

unread,
Dec 28, 2009, 9:11:08 AM12/28/09
to sympy
On Dec 28, 12:04 pm, "czbebe_...@yahoo.co.jp" <czbebe_...@yahoo.co.jp>
wrote:

I get the following:

>>> f = Function('f')
>>> x = Symbol('x')
>>> diff(f(x),x)
D(f(x), x)

Did you use f(x) or did you use f? Could you copy and paste the exact
input and output involved? That would me to understand what exactly
you are trying to do.

/smichr

czbebe

unread,
Jan 4, 2010, 4:36:44 AM1/4/10
to sympy
Thank you for your reply.
I suceeded to run the code.

>>> f = Function('f')
>>> x = Symbol('x')
>>> diff(f(x),x)
D(f(x), x)
How about second derivatives ?
I mean
diff(D(f(x), x),x)
Is there any way to get the answer ?

Thanks in advance,

czbebe

smichr

unread,
Jan 12, 2010, 10:55:12 PM1/12/10
to sympy
> I suceeded to run the code.
> >>> f = Function('f')
> >>> x = Symbol('x')
> >>> diff(f(x),x)
>
> D(f(x), x)
> How about second derivatives ?
> I mean
> diff(D(f(x), x),x)
> Is there any way to get the answer ?
>

If you replace the "D" with "diff" in your example it would work:

>>> D(f(x),x)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
NameError: name 'D' is not defined
>>> D=diff
>>> D(f(x),x)
D(f(x), x)


Either of these work, too:

>>> from sympy import *
>>> f=Function('f')
>>> x=Symbol('x')
>>> diff(f(x),x,2) # list the number of times that you want to differentiate wrt x after the x
D(f(x), x, x)
>>> diff(f(x),x,x) # or just list the x that many times
D(f(x), x, x)

/c

Aaron S. Meurer

unread,
Jan 12, 2010, 11:16:11 PM1/12/10
to sy...@googlegroups.com
Yes, it can be annoying that diff repr's to D. Sometimes, I do D =
diff to make expressions copy and paste correctly.

Aaron Meurer

Sent from my iPod touch.

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

Reply all
Reply to author
Forward
0 new messages