# built in method norm of Vector_symbolic_dense object

So, I want to write a program that plots equipotential contours for z=0 for electric potential of 3 charges(ch) at specified coordinates(matrix m). I need rv to be a vector with general coordinates so I can later plot the equipotential contours.

var(' x y ')
m=matrix(QQ,[[1,1],[-1,-1],[-1,1]])
ch=([-1,1,1])
rv=vector([x,y])
k=m.nrows();
u=[(rv-m[i]).norm() for i in range(k)];

However, after the last line I get this:

[<built in method norm of Vector_symbolic_dense object at 0xbb752fc>, <built in method norm of Vector_symbolic_dense object at 0xbb7532c>, <built in method norm of Vector_symbolic_dense object at 0xbb750bc>]

How do I fix this to get the norm of rv-m[i]?

,

edit retag close merge delete

1

Which version of Sage are you running ? I got the following:

sage: u
[sqrt(abs(x - 1)^2 + abs(y - 1)^2),
sqrt(abs(x + 1)^2 + abs(y + 1)^2),
sqrt(abs(x + 1)^2 + abs(y - 1)^2)]
( 2015-02-15 16:36:20 -0500 )edit

Are your shure this is the code in your worksheet? It seems like you left out the parenthesis in .norm()

( 2015-02-16 04:09:47 -0500 )edit

It's a mistake I made here, there is the parenthesis in .norm() in my worksheet

( 2015-02-16 06:16:13 -0500 )edit

And I'm using sage 5.13 because newer versions don't work on my virtualbox machine.

( 2015-02-16 06:17:00 -0500 )edit

That seems odd about the virtual box. Can you give more specific details in another question (or, better, on sage-support@googlegroups.com)?

( 2015-02-16 11:51:41 -0500 )edit

Sort by ยป oldest newest most voted

sage: var('x y')
(x, y)
sage: m = matrix(QQ,[[1,1],[-1,-1],[-1,1]])
sage: ch = ([-1,1,1])
sage: rv = vector([x,y])
sage: k = m.nrows()
sage: u = [(rv-m[i]).norm() for i in range(k)]

yields no output, unless we ask for u:

sage: u
[sqrt(abs(x - 1)^2 + abs(y - 1)^2),
sqrt(abs(x + 1)^2 + abs(y + 1)^2),
sqrt(abs(x + 1)^2 + abs(y - 1)^2)]

Of course, if the definition for u has .norm instead of .norm(),

sage: u = [(rv-m[i]).norm for i in range(k)]

then we would get:

sage: u
[<built-in method norm of Vector_symbolic_dense object at 0x10f76fb48>,
<built-in method norm of Vector_symbolic_dense object at 0x10f76fbb0>,
<built-in method norm of Vector_symbolic_dense object at 0x10f76fc18>]

If you are working in the notebook, maybe you evaluated

u = [(rv-m[i]).norm for i in range(k)]

and then changed it to

u = [(rv-m[i]).norm() for i in range(k)]

but forgot to reevaluate?

more