MathGroup Archive 2000

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

Search the Archive

Re: making a function linear

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25580] Re: [mg25473] making a function linear
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Mon, 9 Oct 2000 01:16:44 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <OczD5.95777$Zh6.250953@ralph.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

I've reluctantly concluded that the only reasonable way to accomplish
what I want is to use HoldFirst.  Reluctant -- because that's one more
concept to have to throw at my Mathematica-novice students.  I tried
creating my own vector[...] data type but that would up being more
trouble than it was worth.

David Park wrote:
> 
> Hi Murray,
> 
> I don't know if this qualifies as a simple way because it does use a
> HoldFirst as an Attribute of T. But the students don't have to use any Holds
> in their use of it.
> 
> Attributes[T] = {HoldFirst};
> T[a_?VectorQ + b_?VectorQ] := T[a] + T[b]
> T[c_ x_?VectorQ] := c T[x]
> 
> a = {1, 2}; T[a] = {3, 4};
> b = {5, 6}; T[b] = {7, 8};
> 
> T[2a]
> T[a + b]
> {6, 8}
> {10, 12}
> 
> It will probably be difficult to think of a simpler approach.
> 
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
> 
> > -----Original Message-----
> > From: Murray Eisenberg [mailto:murray at math.umass.edu]
To: mathgroup at smc.vnet.net
> >
> > For a function T not yet having any "definition by formula" (T[x_] :=
> > ..... ), I want to specify the linearity rules:
> >
> >   T[x_?VectorQ + y_?VectorQ] := T[x] + T[y]
> >
> >   T[c_ x_?VectorQ] := c T[x]
> >
> > Then, merely by specifying, say,
> >
> >   a = {1, 2}; T[a] = {3, 4};
> >   b = {5, 6}; T[b] = {7, 8};
> >
> > evaluating
> >
> >   T[2 a]
> >   T[a + b]
> >
> > would return results:
> >
> >   {6, 8}
> >   {10, 12}
> >
> > The trouble is, of course, that Mathematica first evaluates 2 a and a +
> > b when a and b have actual numeric values, so the two linearity rules
> > never get used.
> >
> > What is a SIMPLE way (if there is one) to accomplish this -- preferably
> > some way to do it that does not explicitly require using some Hold
> > variant?  (I need to be able to explain how to do it early in a linear
> > algebra course where Mathematica is being introduced, and Hold, etc., I
> > consider a definitely advanced topic.)
> >
> >
> > --
> > Murray Eisenberg                     murray at math.umass.edu
> > Mathematics & Statistics Dept.       phone 413 549-1020 (H)
> > Univ. of Massachusetts                     413 545-2859 (W)
> > Amherst, MA 01003-4515
> >
> >

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.       phone 413 549-1020 (H)
Univ. of Massachusetts                     413 545-2859 (W)
Amherst, MA 01003-4515


  • Prev by Date: Re: Can I force arbitary precision
  • Next by Date: Re: problem with nonlinearfit
  • Previous by thread: RE: making a function linear
  • Next by thread: FullSimplify tricks