MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

AW: "a[A_,B_] :=" Does not assign variables properly. Why?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36149] AW: [mg36141] "a[A_,B_] :=" Does not assign variables properly. Why?
  • From: Matthias.Bode at oppenheim.de
  • Date: Fri, 23 Aug 2002 21:34:38 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hello,
try

In[1]:=Clear[a,b,c,d,x,y]
x= {{0,0,0,1},{1,0,0,1},{0,1,0,1},{1,1,1,1}};
y = {a,b,c,d};
 LinearSolve[x,y]
s01= LinearSolve[x,y][[1]]

Out[4]={-a+b,-a+c,a-b-c+d,a}

Out[5]=-a+b

In[6]:=g[a_,b_] =s01

Out[6]=-a+b

In[7]:=g[1,3]

Out[7]=2

*NEVER* use capital letters at the beginning of a variable's name! Never!

Best regards,
Matthias Bode
Sal. Oppenheim jr. & Cie. KGaA
Koenigsberger Strasse 29
D-60487 Frankfurt am Main
GERMANY
Tel.: +49(0)69 71 34 53 80
Mobile: +49(0)172 6 74 95 77
Fax: +49(0)69 71 34 95 380
E-mail: matthias.bode at oppenheim.de
Internet: http://www.oppenheim.de




-----Ursprüngliche Nachricht-----
Von: jwelter at sawtek.com [mailto:jwelter at sawtek.com]
Gesendet: Freitag, 23. August 2002 06:25
An: mathgroup at smc.vnet.net
Betreff: [mg36141] "a[A_,B_] :=" Does not assign variables properly.
Why?


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?


  • Prev by Date: Re: NDSolve with integral equation
  • Next by Date: Re: Integral equations
  • Previous by thread: RE: FindRoot on fn with vble num of vbles
  • Next by thread: another question about pattern replacements