Ask Your Question
1

built in method norm of Vector_symbolic_dense object

asked 2015-02-15 22:22:21 +0200

idonea gravatar image

updated 2015-02-15 22:53:39 +0200

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 flag offensive close merge delete

Comments

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)]
tmonteil gravatar imagetmonteil ( 2015-02-15 23:36:20 +0200 )edit

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

Thorsten gravatar imageThorsten ( 2015-02-16 11:09:47 +0200 )edit

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

idonea gravatar imageidonea ( 2015-02-16 13:16:13 +0200 )edit

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

idonea gravatar imageidonea ( 2015-02-16 13:17:00 +0200 )edit

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

kcrisman gravatar imagekcrisman ( 2015-02-16 18:51:41 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-02-16 13:48:54 +0200

slelievre gravatar image

Repeating your input:

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?

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-02-15 22:22:21 +0200

Seen: 370 times

Last updated: Feb 16 '15