Ask Your Question

__jacques__'s profile - activity

2016-05-11 16:23:41 +0200 received badge  Famous Question (source)
2016-05-11 16:23:41 +0200 received badge  Notable Question (source)
2013-03-16 20:03:38 +0200 received badge  Popular Question (source)
2011-09-24 06:34:32 +0200 commented answer simplify_full() and symbolic vectors

Awesome, thanks for the pointer. For some reason this didn't come up in my original search.

2011-09-21 04:56:36 +0200 commented answer simplify_full() and symbolic vectors

That indeed works. Awesome, thanks a lot! Judging from what you're saying, this could be worth a feature request. I'll dig around for where I can file one.

2011-09-21 04:56:15 +0200 commented answer simplify_full() and symbolic vectors

Thanks; makes sense!

2011-09-21 04:55:38 +0200 received badge  Scholar (source)
2011-09-21 04:55:38 +0200 marked best answer simplify_full() and symbolic vectors

Here is a workaround:

vector(list((1-t)*P0+t*P1)).simplify_full()

It seems that the Vector_symbolic_dense class is quite new (judging by the content of vector_symbolic_dense.py). Even basic operations are not yet implemented:

sage: type(P0)
<class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
sage: type(P0+P0)
<type 'sage.modules.free_module_element.FreeModuleElement_generic_dense'>
sage: type(2*P0)
<type 'sage.modules.free_module_element.FreeModuleElement_generic_dense'>

(I think addition and scalar multiplication are desirable for a class implementing vectors). For some reason vector needs a list as input (or a tuple, but not a symbolic vector) in order to produce a symbolic vector:

sage: type(vector(P0+P0))
<type 'sage.modules.free_module_element.FreeModuleElement_generic_dense'>
sage: type(vector(list(P0+P0)))
<class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
2011-09-21 04:55:30 +0200 received badge  Supporter (source)
2011-09-20 19:39:55 +0200 received badge  Nice Question (source)
2011-09-20 18:14:34 +0200 received badge  Student (source)
2011-09-20 17:38:22 +0200 received badge  Editor (source)
2011-09-20 17:37:30 +0200 asked a question simplify_full() and symbolic vectors

First, the question:

Suppose I've constructed some vectors with symbolic entries, call them P0 and P1. Calling simplify_full on them will -- apparently by changes introduced in the latest version (#11335 and #11381)! -- do an elementwise simplification. Great!

Suppose I construct a new symbolic vector by, say, interpolating between P0 and P1:

Pt = (1-t)*P0 + t*P1

Now

Pt.simplify_full()

produces

Traceback (click to the left of this block for traceback)
...
AttributeError:
'sage.modules.free_module_element.FreeModuleElement_generic_dense'
object has no attribute 'simplify_full'

whereas

P0.simplify_full()

and

P1.simplify_full()

work just fine. Somehow the symbolic vector-ness is forgotten in the construction of Pt.

Am I doing something wrong?

Then, the disclaimer:

A friend pointed me to Sage today, and this is the first thing I'm trying to do with it -- I do have background in some other symbolic tools, but this may just be a Stupid User Error despite giving this my best shot and looking at documentation.

Anyway, I'm very impressed with what I'm seeing when I look at Sage.

(For completeness' sake, here's a full example:

var('x,w,C0,C1,t')
P0=vector([0, C1*w/(C1*w+C0) - w/(w+C0/C1)])
P1=vector([cos(x)/sin(x)*tan(x)-1, 0])

Now both

P0.simplify_full()
P1.simplify_full()

return (0,0) as they should. But

Pt=(1-t)*P0+t*P1
Pt.simplify_full()

returns the above error.)