Ask Your Question

# Revision history [back]

Do you mean you are considering the function f(x, y, z) = 0.3*x + 0.7*y + 0.2*z and you have a list ver of 3-tuples and you want the list of f(x, y, z) for each (x, y, z) in the list ver?

Define f and ver:

sage: f = lambda x, y, z: 0.3*x + 0.7*y + 0.2*z
sage: ver = [ (0.00, 0.50, 0.75), (0.00, −0.50, 0.75), (0.50, 0.75, 0.00), (0.50, −0.75, 0.00)]


Several ways to compute the image:

sage: w = [f(x, y, z) for x, y, z in ver]
sage: w = [f(*v) for v in ver]


Or using vectors instead of tuples, and seeing f(x, y, z) as a scalar product:

sage: a = vector((0.3, 0.7, 0.2))
sage: w = [a * vector(v) for v in ver]