Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Symbolic vectors

Let's say I have a vector space V, a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some point in V.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate M*v, then take diff(), and then I can plug in a tangent vector.

As part of this, I would then run

x, y = var('x, y')
v = vector([x,y])

if V happens to be two-dimensional. This works fine in a new session, but if in the same session I've already used a vector space somewhere it says

'sage.modules.free_module_element.FreeModuleElement_generic_sparse' object is not callable

Why is that? And is there a better way to do this?

Symbolic vectors

Let's say I have a vector space V, a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some point in V.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate M*v, ||M*v||, then take diff(), and then I can plug in a tangent vector.

As part of this, I would then run

x, y = var('x, y')
v = vector([x,y])

if V happens to be two-dimensional. This works fine in a new session, but if in the same session I've already used a vector space somewhere it says

'sage.modules.free_module_element.FreeModuleElement_generic_sparse' object is not callable

Why is that? And is there a better way to do this?

Symbolic vectors

Let's say I have a vector space V, a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some point in V.V, and evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

As part of this, I would then run

x, y = var('x, y')
v = vector([x,y])

if V happens to be two-dimensional. This works fine in a new session, but if in the same session I've already used a vector space somewhere it says

'sage.modules.free_module_element.FreeModuleElement_generic_sparse' object is not callable

Why is that? And is there a better way to do this?

Symbolic vectors

Let's say I have a vector space V, a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some point in V, and evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

As part of this, I would then run

x, y = var('x, y')
v = vector([x,y])

if say V happens to be two-dimensional. This works fine in a new session, but if in the same session I've already used a vector space somewhere it says

'sage.modules.free_module_element.FreeModuleElement_generic_sparse' object is not callable

Why is that? And is there a better way to do this?

Symbolic vectors

Edit: I've changed the question - upon editing the code the problem seems to lie elsewhere.

Let's say I have a vector space V, V of dimension n (which is variable) and a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some point vector v in V, and then evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

As part of this, So I would then runwrite something like

x, y = var('x, y')
v = vector([x,y])
list(var('v_%d' % i) for i in range(1,W.rank()+1))
def f(*v):
    L = []
    for var in v:
        L.append(var)
    return (M*vector(L)).norm()

if say V happens to be two-dimensional. This works fine in a new session, but if in the same session I've already used a vector space somewhere it saysthen diff(f) throws an error:

'sage.modules.free_module_element.FreeModuleElement_generic_sparse' object is not callable
unable to convert <function f at 0x7f2b046c5b90> to a symbolic expression

Why is that? And is there a better way to do this?

Symbolic vectors

Edit: I've changed the question - upon editing the code the problem seems to lie elsewhere.

Let's say I have a vector space V of dimension n (which is variable) and a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some vector v in V, and then evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

So I would write something like

v = list(var('v_%d' % i) for i in range(1,W.rank()+1))
def f(*v):
    L = []
    for var in v:
        L.append(var)
    return (M*vector(L)).norm()

but then diff(f) throws an error:

unable to convert <function f at 0x7f2b046c5b90> to a symbolic expression

Symbolic vectorsDifferentiating function with fluctuating number of variables

Edit: (Edit: I've changed the question somewhat - upon editing the code the problem seems to lie elsewhere.elsewhere.)

Let's say I have a vector space V of dimension n (which is variable) and a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some vector v in V, and then evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

So I would write something like

v = list(var('v_%d' % i) for i in range(1,W.rank()+1))
def f(*v):
    L = []
    for var in v:
        L.append(var)
    return (M*vector(L)).norm()

but then diff(f) throws an error:

unable to convert <function f at 0x7f2b046c5b90> to a symbolic expression

Differentiating function with fluctuating number of variables

(Edit: I've changed the question somewhat - upon editing the code the problem seems to lie elsewhere.)

Let's say I have a vector space V of dimension n (which is variable) and a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some vector v in V, and then evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

So I would write something like

v = list(var('v_%d' % i) for i in range(1,W.rank()+1))
range(1,n+1))
def f(*v):
    L = []
    for var in v:
        L.append(var)
    return (M*vector(L)).norm()

but then diff(f) throws an error:

unable to convert <function f at 0x7f2b046c5b90> to a symbolic expression

Differentiating function with fluctuating number of variables

(Edit: I've changed the question somewhat - upon editing the code the problem seems to lie elsewhere.)

Let's say I have a vector space V of dimension n (which is variable) and a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some vector v in V, and then evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

So I would write something like

v = list(var('v_%d' % i) for i in range(1,n+1))
def f(*v):
f(*arg):
    L = []
    for var in v:
arg:
        L.append(var)
    return (M*vector(L)).norm()

but then diff(f) throws an error:

unable to convert <function f at 0x7f2b046c5b90> to a symbolic expression

Differentiating function with fluctuating number of variables

(Edit: I've changed the question somewhat - upon editing the code the problem seems to lie elsewhere.)

Let's say I have a vector space V of dimension n (which is variable) and a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some vector v in V, and then evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

So I would write something like

v = list(var('v_%d' % i) for i in range(1,n+1))
def f(*arg):
    L = []
    for var in arg:
        L.append(var)
    return (M*vector(L)).norm()

(which is clearly bad) but then diff(f) throws an error:

unable to convert <function f at 0x7f2b046c5b90> to a symbolic expression

Differentiating function with fluctuating number of variables

(Edit: I've changed the question somewhat - upon editing the code the problem seems to lie elsewhere.)

Let's say I have a vector space V of dimension n (which is variable) and a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some vector v in V, and then evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

So I would write something like

v = list(var('v_%d' % i) for i in range(1,n+1))
def f(*arg):
    L = []
    for var in arg:
        L.append(var)
    return (M*vector(L)).norm()

(which is clearly bad) but then attempting something like this, diff(f) throws an error:

unable to convert <function f at 0x7f2b046c5b90> to a symbolic expression

Differentiating function with fluctuating number of variables

(Edit: I've changed the question somewhat - upon editing the code the problem seems to lie elsewhere.)

Let's say I have a vector space V of dimension n (which is variable) and a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some vector v in V, and then evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

So I would write something like

v = list(var('v_%d' % i) for i in range(1,n+1))
def f(*arg):
    L = []
    for var in arg:
        L.append(var)
    return (M*vector(L)).norm()

(which is clearly bad) bad and going nowhere) but attempting something like this, diff(f) throws an error:

unable to convert <function f at 0x7f2b046c5b90> to a symbolic expression

Differentiating function with fluctuating number of variables

(Edit: I've changed the question somewhat - upon editing the code the problem seems to lie elsewhere.)

Let's say I have a vector space V of dimension n (which is variable) and a matrix M, and I want to understand the derivative of the function v -> ||M*v|| at some vector v in V, and then evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

So I would write something like

v = list(var('v_%d' % i) for i in range(1,n+1))
def f(*arg):
    L = []
    for var in arg:
        L.append(var)
    return (M*vector(L)).norm()

(which is clearly bad and going nowhere) but attempting something like this, diff(f) throws an error:

unable to convert <function f at 0x7f2b046c5b90> to a symbolic expression

and

f(*v) = (M*vector(v)).norm()

doesn't work either.

Differentiating function with fluctuating number of variables

(Edit: I've changed the question somewhat - upon editing the code the problem seems to lie elsewhere.)

Let's say I have a vector space V of dimension n (which is variable) and a matrix M, M (also depending on n and other input), and I want to understand the derivative of the function v -> ||M*v|| at some vector v in V, and then evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

So I would write something like

v = list(var('v_%d' % i) for i in range(1,n+1))
def f(*arg):
    L = []
    for var in arg:
        L.append(var)
    return (M*vector(L)).norm()

(which is clearly bad and going nowhere) but attempting something like this, diff(f) throws an error:

unable to convert <function f at 0x7f2b046c5b90> to a symbolic expression

and

f(*v) = (M*vector(v)).norm()

doesn't work either.

Differentiating function with fluctuating number of variables

(Edit: I've changed the question somewhat - upon editing the code the problem seems to lie elsewhere.)

Let's say I have a vector space V of dimension n (which is variable) and a matrix M (also depending on n and other input), and I want to understand the derivative of the function v -> ||M*v|| at some vector v in V, and then evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

So I would write something like

v = list(var('v_%d' % i) for i in range(1,n+1))
def f(*arg):
    L = []
    for var in arg:
        L.append(var)
    return (M*vector(L)).norm()

(which is clearly bad and going nowhere) but attempting something like this, diff(f) throws an error:

unable to convert <function f at 0x7f2b046c5b90> to a symbolic expression

and Trying

f(*v) = (M*vector(v)).norm()

doesn't work either.

Differentiating function with fluctuating number of variables

(Edit: I've changed the question somewhat - upon editing the code the problem seems to lie elsewhere.)

Let's say I have a vector space V of dimension n (which is variable) and a matrix M (also depending on n and other input), and I want to understand the derivative of the function v -> ||M*v|| at some vector v in V, and then evaluate it at tangent vectors.

As far as I can tell, the easiest way to do this is to use a symbolic vector v, then calculate ||M*v||, then take diff(), and then I can plug in a tangent vector.

So I would write something like

v = list(var('v_%d' % i) for i in range(1,n+1))
def f(*arg):
    L = []
    for var in arg:
        L.append(var)
    return (M*vector(L)).norm()

(which is clearly bad and going nowhere) but attempting something like this, diff(f) throws an error:

unable to convert <function f at 0x7f2b046c5b90> to a symbolic expression

Trying

f(*v) = (M*vector(v)).norm()

doesn't work either.