using lists in multivariable functions
I wish to create a function that uses elements from a list and is used later on. For example, I have an array M=[m1,m2,...,mn]
, B=[b1,b2,...,bn]
and wish to have a function R(r,u,b)=r+b+u
(using the elements from the array B
), which I then pass to another function Y(r,u,b,m)=R*b*m
(using the result from the first function and the values from each array). In other words, if M=[m1,m2]
and B=[b1,b2]
, I want to be able to have a function R(r,u,b)=[r+b1+u,r+b2+u]
and then have that Y(r,u,b,m)=R*b*m=[(r+b1+u)*b1*m1,(r+b2+u)*b2*m2]
. Basically, I wish to do what is mentioned in this post: http://ask.sagemath.org/question/8545..., but with more than one array.
I tried the following
sage: m1,m2,b1,b2,u=var('m1','m2','b1','b2','u')
sage: M=[m1,m2], B=[b1,b2]
sage: R(r,b,u)=[r+b+u for b in B]
sage:R(r,b,u)
(r+b1+u,r+b2+u)
This is all what I want. I then want to take R(r,b,u) in another function: Y(r,b,u,m), so that it gets the result I have above. I can't seem to get a way to run through all the possibilities (I could use a loop, but that ends up getting a bit messy as I go deeper in)
Edit: The values for mi and bi will eventually have numerical values, but currently they are simply symbolic variables. I am currently using this to simplify some algebraic expressions.
I do not understand your question. Are
M
andB
representing maps from{0, ..., (n-1)}
to the reals? Arer
andu
of the same kind ? What isb
compared toB
? Could you please give more details, your attempts so far, etc ?In your work, do the mi and bi have a value or are they symbolic variables ?