MathGroup Archive 2006

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

Search the Archive

Re: Re: EUREKA Re: Types in Mathematica, a practical example

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63610] Re: [mg63220] Re: EUREKA Re: Types in Mathematica, a practical example
  • From: "Ingolf Dahl" <ingolf.dahl at telia.com>
  • Date: Sat, 7 Jan 2006 02:29:33 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi David,
Comments are interlaced in the text below, 

> -----Original Message-----
> From: David Bailey [mailto:dave at Remove_Thisdbailey.co.uk] 
To: mathgroup at smc.vnet.net
> Subject: [mg63610] [mg63220] Re: EUREKA Re: Types in Mathematica, a 
> practical example
> 
> Hello,
> 
> If you want to compute with undefined array elements, why not 
> use subscript elements such as Subscript[a,1,2].

Hmmm, maybe... Let's see

ax := {{Subscript[ax, 1, 1], Subscript[ax, 1, 2]}, {Subscript[ax, 2, 1],
Subscript[ax, 2, 2]}}

is not a good idea, since evaluation of ax gives an infinite loop. (There
are of course cases when this is not a problem. )

ax := {{Subscript[HoldForm[ax], 1, 1], Subscript[HoldForm[ax], 1, 2]},
{Subscript[HoldForm[ax], 2, 1], Subscript[HoldForm[ax], 2, 2]}}

is better according to my criteria. The suggestion has the benefit that we
can keep a name connection between the elements and the matrix.
Subscript[HoldForm[ax], 1, 1] can be used almost in the same way as a single
variable. Another possibility almost in the same style is

SetAttributes[listelement, HoldFirst];
ax := {{listelement[ax, 1, 1], listelement[ax, 1, 2]}, {listelement[ax, 2,
1], listelement[ax, 2, 2]}};

In both suggestions ax can be seen as a function of its elements and the
elements can be seen as  functions of ax, in a circular manner. I wonder if
anyone of these suggestions would be acceptable from the point of view of a
functional programmer. Anyway we are quite near my suggestion in mg63184,
but with both these variants the elements will have a different appearance
from the standard list parts ax[[i,j]].

> 
> More generally, the concept of a matrix can mean a number of different
> things:
> 
> 1)	A fully filled rectangular array of numbers or other 
> expressions. 
> (SparseArray is simply a variant of this).
> 
> 2)	An array in which some or all of the elements are undefined.
> 
> 3)	An array in which even the dimensions are undefined, 
> but in which you 
> can refer to individual elements.
> 
> 4)	In some work a single symbol is used to represent a 
> matrix together 
> with a non-commutative multiplication.
> 
> Clearly a system cannot be expected to cater for all of these 
> and all possible transitions between one and another. In 
> practice, of course, Mathematica caters for case 1, and you 
> have to supply your own notation to work with the others. 
> This seems reasonable to me.
 
a) Indexed elements are not only occurring as matrix elements, even if the
discussion here has been about such. A mechanism should be applicable to any
expression with a head.  

b) My question was partly how I could supply my own notation in consistence
with how Mathematica works. But I think it is reasonable that I could
suggest points where I think Mathematica could be improved, and I also think
that MathGroup is a good place to discuss such things, since other users
might have valuable information or opinions about the suggestions. Maybe
Mathematica could be improved in such a way that it becomes easier for the
users to supply their own notation for some of the cases above?

> In practice, I find that error messages generated by Part are 
> quite common and extremely useful, and I think it would be 
> most unhelpful if Part expressions that could not be 
> evaluated silently returned unchanged.

I do not think you have to worry about this. What I suggested was that Part
expressions deliberately declared as undefined should be returned unchanged.
If the indices of Part point outside the list, you could still obtain error
messages. How often do you deliberately declare Part expressions as
undefined by mistake and then forget to give them a value? If you have used
any other undefined variable or function, or use the Array method in sec.
2.5.5. for defining matrices with undefined elements, you do not get any
warning for undefined variables. Also I think it anyway is a natural way to
improve and extend Mathematica to replace some error messages with some kind
of regular action, if that could be done in a logical and consistent manner.

> 
> David Bailey
> http://www.dbaileyconsultancy.co.uk
> 
> 

Best regards

Ingolf Dahl
Sweden
http://web.telia.com/~u31815170/Mathematica/



  • Prev by Date: Re: Puzzle Challenge
  • Next by Date: Re: Re: EUREKA Re: Types in Mathematica, a practical example
  • Previous by thread: Re: Re: Getting the small parts right or wrong. Order and Collect
  • Next by thread: Re: Re: EUREKA Re: Types in Mathematica, a practical example