Ask Your Question
0

Defining a function of vector variables

asked 10 years ago

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?

Preview: (hide)

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 ( 10 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 10 years ago

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
Preview: (hide)
link

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: 10 years ago

Seen: 1,908 times

Last updated: Aug 13 '14