"a[A_,B_] :=" Does not assign variables properly. Why?
- To: mathgroup at smc.vnet.net
- Subject: [mg36141] "a[A_,B_] :=" Does not assign variables properly. Why?
- From: jwelter at sawtek.com (Jason Welter)
- Date: Fri, 23 Aug 2002 00:25:14 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Here's a piece of a conversion I had with Mathematica.
Why is "a[A_,B_] := LinearSolve[X,Y][[1]]" not giving
me the function I expect?
In[261]:= X = {{0,0,0,1},{1,0,0,1},{0,1,0,1},{1,1,1,1}};
In[262]:= Y = {A,B,C,D};
In[263]:= LinearSolve[X,Y]
Out[263]= {-A+B,-A+C,A-B-C+D,A}
In[264]:= LinearSolve[X,Y][[1]]
Out[264]= -A+B
In[265]:= a[A_,B_] := LinearSolve[X,Y][[1]]
In[266]:= a[1,3]
Out[266]= -A+B
The output above is not what I want. I want "2". Here's
what I expect:
In[267]:= a[A_,B_] := -A+B;
In[268]:= a[1,3]
Out[268]= 2
This output is what I expect. What is the difference between
the two?