Ask Your Question

Defining a function of vector variables

asked 2014-08-13 12:06:57 -0500

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-13 23:12:22 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-08-13 12:54:56 -0500

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 12:06:57 -0500

Seen: 417 times

Last updated: Aug 13 '14