Ask Your Question

Defining a function of vector variables

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

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



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 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

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

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)))
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


Asked: 2014-08-13 19:06:57 +0200

Seen: 1,747 times

Last updated: Aug 13 '14