Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
0

vector derivative returns a scalar

asked 11 years ago

Tomas gravatar image

updated 11 years ago

Trying to obtain the derivative of u=[1,1] using the following code:

u = matrix(1,2,[-1, 1])

r = derivative(u,x); r

I get a scalar value 0.

Although according the following relation it should be a 2-dimensional zero vector.

dudx=ddx[1,1]=[ddx(1),ddx(1)]=[0,0]

Why does it happen? In the case it's a bug where could I report it?

Thanks

Preview: (hide)

Comments

Compared to: a(x) = function('a',x) b(x) = function('b',x) u = matrix(1,2,[a,b]) r = derivative(u,x);r Which gives a vector as expected: [x |--> D[0](a)(x) x |--> D[0](b)(x)]

Tomas gravatar imageTomas ( 11 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 11 years ago

ppurka gravatar image

Look at the help of derivative. It works on symbolic functions, polynomials, and symbolic expressions. Your variable u is not a function, so it is not really being considered a two dimensional symbolic expression or function. If you do

sage: u(x,y) = matrix(1,2,[-1,1])
sage: derivative(u, x)
(x, y) |--> 0

then you can see that it is considering it as a two dimensional function. In the second case, you have a function of one variable in the variable x.

The alternative fix is to work in the symbolic ring:

sage: u = matrix(SR, [-1,1])
sage: derivative(u,x)
[0 0]
Preview: (hide)
link

Comments

Thanks, the fix with a symbolic ring is helpful. In my problem the u really is a function, just happens to be a constant at this occasion.

Tomas gravatar imageTomas ( 11 years ago )

Anyway, I reckon that the first example is probably a bug. The derivative of n-dimensional vector should have n-dimensions again no matter to which ring it belongs to. Would you know how to report that, please?

Tomas gravatar imageTomas ( 11 years ago )

This is now ticket 15067

ppurka gravatar imageppurka ( 11 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 11 years ago

Seen: 1,694 times

Last updated: Aug 19 '13