MathGroup Archive 1990

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

Search the Archive

Re: supressing argument evaluation by function Part

  • To: mathgroup at yoda.ncsa.uiuc.edu
  • Subject: Re: supressing argument evaluation by function Part
  • From: uunet!einstein.tamu.edu!phil (Philip B. Yasskin)
  • Date: Thu, 19 Apr 90 14:52:47 CDT

The reason you get error messages from

  lhs = { { -(k^2 + lamsq[[n]]), lamsq[[n]] },
	  { lamsq[[n]], -(k^2 + lamsq[[n]]) } }

  rhs = { { -(k^2 + lamsq[[n]]) u1[[n]], lamsq[[n]] u1[[n]] },
	  { lamsq[[n]] u2[[n]], -(k^2 + lamsq[[n]]) u2[[n]] } }

  cmatrix[k_,n_] = Inverse[lhs] . rhs

is that n is not defined as a number when you define lhs and rhs.  The
errors should dissappear if you insert the expressions for lhs and rhs
into the formula for cmatrix.  However, the following should be much
faster since you don't have to recompute the n-th component
repeatedly:

In[1]:= cmatrix[k_,n_] :=
  Block[{lamsqn=lamsq[[n]], u1n=u1[[n]], u2n=u2[[n]]},
	lhs = { { -(k^2 + lamsqn), lamsqn },
	  { lamsqn, -(k^2 + lamsqn) } };
	rhs = { { -(k^2 + lamsqn) u1n, lamsqn u1n },
	  { lamsqn u2n, -(k^2 + lamsqn) u2n } };
	Inverse[lhs] . rhs
  ]

In[2]:= lamsq = {1,2,3,4}

Out[2]= {1, 2, 3, 4}

In[3]:= u1 = {2,4,6,8}

Out[3]= {2, 4, 6, 8}

In[4]:= u2 = {1,3,5,7}

Out[4]= {1, 3, 5, 7}

In[5]:= cmatrix[1,2]

	  24    6     6  11
Out[5]= {{--, -(-)}, {-, --}}
	  5     5     5  5

Phil Yasskin     phil at einstein.tamu.edu




  • Prev by Date: Math mode for GNU Emacs
  • Next by Date: Re: Transformation Rules via Algebraic Rules
  • Previous by thread: Math mode for GNU Emacs
  • Next by thread: Re: Transformation Rules via Algebraic Rules