Ask Your Question
0

Defining a function of vector variables

asked 2014-08-13 19:06:57 +0100

ajd gravatar image

I would like to define a Sage function that takes a vector variable and computes the result of some vector function on it, something like

f(v) = v.dot_product(vector((1,1)))

However, when I try to run this in Sage, I get

AttributeError: 'sage.symbolic.expression.Expression' object has no
attribute 'dot_product'

Is there a way to achieve this effect in Sage?

edit retag flag offensive close merge delete

Comments

1

To elaborate, `f(v)` creates a symbolic variable `v`, which is not (necessarily) a vector. Sage doesn't currently have symbolic vector types per se.

kcrisman gravatar imagekcrisman ( 2014-08-14 06:12:22 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-08-13 19:54:56 +0100

zmwangx gravatar image

You can always use a Python def:

sage: def f(v):
    return v.dot_product(vector((1,1)))

sage: f(vector((2,1)))
3
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: 2014-08-13 19:06:57 +0100

Seen: 1,803 times

Last updated: Aug 13 '14