4 code format edited Oct 25 '12 at 1:31 Ajasja 9,86422 gold badges3838 silver badges9797 bronze badges You are better off thinking that in Mathematica you can control when and if an expression evaluates or not. But, if it evaluates, it does it until it doesn't change any more. In this case, you can make expr either stay as is, or evaluate (1) expr -> (2) {v,w} -> (3) {{v1,v2}+{w1, w2}} -> (4) {{v1+w1, v2+w2}}; Actually, since your definition of expr is immediate (you used Set) it is actually stored as {{v1+w1, v2+w2}} already. If you don't want that to happen, you have to change your design (for example, using a wrapper other than List for your vectors), or temporarily disable the definitions you want to hold. For the distributibity to work, the evaluation must stop at step (2) or (3) Change your expr definition to a SetDelayed expr := v + w;  and now either block Plus so it is no longer Listable while you distribute (step (3) ), or block your symbols (step (2) ) Block[{Plus}, Distribute@f[u, expr]] Block[{v, w}, Distribute@f[u, expr]]  g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}]  You are better off thinking that in Mathematica you can control when and if an expression evaluates or not. But, if it evaluates, it does it until it doesn't change any more. In this case, you can make expr either stay as is, or evaluate (1) expr -> (2) {v,w} -> (3) {{v1,v2}+{w1, w2}} -> (4) {{v1+w1, v2+w2}}; Actually, since your definition of expr is immediate (you used Set) it is actually stored as {{v1+w1, v2+w2}} already. If you don't want that to happen, you have to change your design (for example, using a wrapper other than List for your vectors), or temporarily disable the definitions you want to hold. For the distributibity to work, the evaluation must stop at step (2) or (3) Change your expr definition to a SetDelayed expr := v + w;  and now either block Plus so it is no longer Listable while you distribute (step (3) ), or block your symbols (step (2) ) Block[{Plus}, Distribute@f[u, expr]] Block[{v, w}, Distribute@f[u, expr]]  g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] You are better off thinking that in Mathematica you can control when and if an expression evaluates or not. But, if it evaluates, it does it until it doesn't change any more. In this case, you can make expr either stay as is, or evaluate (1) expr -> (2) {v,w} -> (3) {{v1,v2}+{w1, w2}} -> (4) {{v1+w1, v2+w2}}; Actually, since your definition of expr is immediate (you used Set) it is actually stored as {{v1+w1, v2+w2}} already. If you don't want that to happen, you have to change your design (for example, using a wrapper other than List for your vectors), or temporarily disable the definitions you want to hold. For the distributibity to work, the evaluation must stop at step (2) or (3) Change your expr definition to a SetDelayed expr := v + w;  and now either block Plus so it is no longer Listable while you distribute (step (3) ), or block your symbols (step (2) ) Block[{Plus}, Distribute@f[u, expr]] Block[{v, w}, Distribute@f[u, expr]]  g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}]  3 edited body edited Oct 24 '12 at 19:51 Rojo 35.5k55 gold badges9191 silver badges175175 bronze badges You are better off thinking that in Mathematica you can control when and if an expression evaluates or not. But, if it evaluates, it does it until it doesn't change any more. In this case, you can make expr either stay as is, or evaluate (1) expr  -> (2) {v,uw}  -> (3) {{v1,v2}+{u1w1, u2w2}}  -> (4) {{v1+u1v1+w1, v2+u2v2+w2}}; Actually, since your definition of expr is immediate (you used Set) it is actually stored as {{v1+u1v1+w1, v2+u2v2+w2}} already. If you don't want that to happen, you have to change your design (for example, using a wrapper other than List for your vectors), or temporarily disable the definitions you want to hold. For the distributibity to work, the evaluation must stop at step (2) or (3) For example, changeChange your expr definition to a SetDelayed expr := v + w;  and now either block Plus (soso it is no longer Listable while you distribute (step (3) ), or block your symbols (step (2) ) Block[{Plus}, Distribute@f[u, expr]] Block[{v, w}, Distribute@f[u, expr]]  g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] You are better off thinking that in Mathematica you can control when and if an expression evaluates or not. But, if it evaluates, it does it until it doesn't change any more. In this case, you can make expr either stay as is, or evaluate expr->{v,u}->{{v1,v2}+{u1, u2}}->{{v1+u1, v2+u2}}; Actually, since your definition of expr is immediate (you used Set) it is actually stored as {{v1+u1, v2+u2}} already. If you don't want that to happen, you have to change your design (for example, using a wrapper other than List for your vectors), or temporarily disable the definitions you want to hold. For example, change your expr definition to a SetDelayed expr := v + w;  and now either block Plus (so it is no longer Listable while you distribute), or block your symbols Block[{Plus}, Distribute@f[u, expr]] Block[{v, w}, Distribute@f[u, expr]]  g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] You are better off thinking that in Mathematica you can control when and if an expression evaluates or not. But, if it evaluates, it does it until it doesn't change any more. In this case, you can make expr either stay as is, or evaluate (1) expr  -> (2) {v,w}  -> (3) {{v1,v2}+{w1, w2}}  -> (4) {{v1+w1, v2+w2}}; Actually, since your definition of expr is immediate (you used Set) it is actually stored as {{v1+w1, v2+w2}} already. If you don't want that to happen, you have to change your design (for example, using a wrapper other than List for your vectors), or temporarily disable the definitions you want to hold. For the distributibity to work, the evaluation must stop at step (2) or (3) Change your expr definition to a SetDelayed expr := v + w;  and now either block Plus so it is no longer Listable while you distribute (step (3) ), or block your symbols (step (2) ) Block[{Plus}, Distribute@f[u, expr]] Block[{v, w}, Distribute@f[u, expr]]  g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] 2 added 128 characters in body edited Oct 24 '12 at 18:10 Rojo 35.5k55 gold badges9191 silver badges175175 bronze badges You are better off thinking that in Mathematica you can control when and if an expression evaluates or not. But, if it evaluates, it does it until it doesn't change any more. In this case, you can make expr either stay as is, or evaluate expr->{v,u}->{{v1,v2}+{u1, u2}}->{{v1+u1, v2+u2}}; Actually, since your definition of expr is immediate (you used Set) it is actually stored as {{v1+u1, v2+u2}} already. If you don't want that to happen, you have to change your design (for example, using a wrapper other than List for your vectors), or temporarily disable the definitions you want to hold. For example, change your expr definition to a SetDelayed expr := v + w;  and now either block Plus (so it is no longer Listable while you distribute), or block your symbols Block[{Plus}, Distribute@f[u, expr]] Block[{v, w}, Distribute@f[u, expr]]  g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] You are better off thinking that in Mathematica you can control when and if an expression evaluates or not. But, if it evaluates, it does it until it doesn't change any more. In this case, you can make expr either stay as is, or evaluate expr->{v,u}->{{v1,v2}+{u1, u2}}->{{v1+u1, v2+u2}}; If you don't want that to happen, you have to change your design (for example, using a wrapper other than List for your vectors), or temporarily disable the definitions you want to hold. For example, change your expr definition to a SetDelayed expr := v + w;  and now either block Plus (so it is no longer Listable while you distribute), or block your symbols Block[{Plus}, Distribute@f[u, expr]] Block[{v, w}, Distribute@f[u, expr]]  g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] You are better off thinking that in Mathematica you can control when and if an expression evaluates or not. But, if it evaluates, it does it until it doesn't change any more. In this case, you can make expr either stay as is, or evaluate expr->{v,u}->{{v1,v2}+{u1, u2}}->{{v1+u1, v2+u2}}; Actually, since your definition of expr is immediate (you used Set) it is actually stored as {{v1+u1, v2+u2}} already. If you don't want that to happen, you have to change your design (for example, using a wrapper other than List for your vectors), or temporarily disable the definitions you want to hold. For example, change your expr definition to a SetDelayed expr := v + w;  and now either block Plus (so it is no longer Listable while you distribute), or block your symbols Block[{Plus}, Distribute@f[u, expr]] Block[{v, w}, Distribute@f[u, expr]]  g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] g[{u1, u2}, {v1, v2}] + g[{u1, u2}, {w1, w2}] 1 answered Oct 24 '12 at 16:54 Rojo 35.5k55 gold badges9191 silver badges175175 bronze badges