Thanks Aaron,

To my needs,

import sympy
import math
diff(sympy.sin(x)*diff(u(x),x),x)

is a good choice because math functions are used in other places.
I will try this.

czbebe

On 1月6日, 午後12:11, "Aaron S. Meurer" <[email protected]> wrote:
> On Jan 5, 2010, at 7:32 PM, czbebe wrote:
>
> > Dear members,
>
> > import sympy
> > import math
>
> I believe the problem lies here.   You are importing math, which imports the 
> math sin, which doesn't work with SymPy symbolic operations.  You have some 
> options:
>
> - Don't import math.  If you need to evaluate a floating point expression, 
> use N() or .evalf(), as in sin(1.2).evalf().  If you need other things from 
> math, do explicit imports instead of import *.  Actually, it's best to use 
> explicit imports anyway, especially if you are writing a script.  
> - If you really want math behavior, use lambdify(sin(x), x, "math").
> - Do from math import sin as msin or some similar.  That is, use the as 
> keyword.  
> - Don't import from.  That is, just do import sympy and import math and then 
> use sympy.sin and so on.  Doing import sympy as S can make this easier.
>
> One of these should fit your needs.  If not, I am sure someone else on this 
> list can come up with yet another solution.
>
> Aaron Meurer
>
>
>
> > u = Function('u')
> > x = Symbol('x')
> > diff(diff(u(x),x),x) = D(u(x), x, x)  ii is all right.
> > diff(x*diff(u(x),x),x) = x*D(u(x), x, x)+D(u(x), x)  it is all right.
>
> > diff(sin(x)*diff(u(x),x),x) gives an error.
>
> > Can anyone show me the correct way to get a correct result ?
>
> > czbebe
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "sympy" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > For more options, visit this group 
> > athttp://groups.google.com/group/sympy?hl=en.- 引用テキストを表示しない -
>
> - 引用テキストを表示 -
-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
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