Re: Re: equaltity of lists

*To*: mathgroup at smc.vnet.net*Subject*: [mg19191] Re: [mg19077] Re: equaltity of lists*From*: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>*Date*: Tue, 10 Aug 1999 02:52:49 -0400*Sender*: owner-wri-mathgroup at wolfram.com

The issues you are raising here are largely "philosophical" so every answer will inevitably contain some "subjective" elements. In my opinion, the first thing that needs to be pointed out is that Mathematica is primarily a programming language. Among all programming languages it is (in my opinion) by far the most suitable for doing mathematics but it should not be thought of as computer simulation of a human mathematician. By that I mean that there are many cases where Mathematica uses language which looks like what you find in some area of mathematics but which actually has a somwhat different meaning. For example thus the answer to NumberQ[Pi] is False. However, we know that Mathematica is not really telling us that Pi is not a number but is answering a certain question connected with the Mathematica programming language. The reason why this function has this sort of "misleading" name is that for those who know its true meaning it is suggestive and easy to remember. There are many more such examples of "departures" from mathematical conventions. There are a number of reasons for their existence and it would require a long essey to list and explain all of them. Sometimes it is simply a matter of efficiancy. Sometimes it is because conventional methematical usage is not consistent and context based (dependent on what area of mathematics you are working with) while Mathematica has to use the same general principles whether one is doing, say, algebra or analysis. As another example, consider the expresion x^2/x. Mathematica always simplifies this expression to x. It will do it before checking what x is thus: In[9]:= x^2/x /. x -> 0 Out[9]= 0 There are several justifications that can be given for doing this. One is efficiency. If Mathematica did not perform this basic simplification but waited for additional information to be entered (e.g. that x is not zero) or if it returned conditionl aswers it would greatly slow down many complex operations. (for example if any expression contained something of the form p/p mathematica would have to solve the equation p==0 before performing a simplification). But there is also a more mathematical justification for this simplification. If you think of the expression x/x as a (say) complex function of x than indeed it is not defined at x=0 and not equal to x. But when you think of it "algebraically" as x*x^(-1), you can read this as x times the multiplicative inverse of x, which is indeed always 1 whenever the expression makes sense. So in this context the simplification Mathematica performs automatically may seem quite reasonable. Of course what is really importnat here it to understand that, for whatever reason, Mathematica always performs this simplification. Once one understands this behaviour one can adapt the way one enters input to get the answers one requires in practically any situation. One should not really ask "why Mathematica's behaviour does not correspond to some standard mathematical practice" but "what do I have to do to get the kind of answer I need". I most cases this is quit easy and natural. Finally, I have in the past got the impression that there are some people who seem to get upset by the mere one suggestion that Mathematica departs from some mathemtical standard or convention. But not only is it easy to find lots of examples when it clearly does so but it is actually inevitable and desirable that it should do so. Until and unless computers can pass the "Turing test" or at least a version of it in which the computer pretends to be a human mathematician and we can't tell the difference, it will be necessary to learn the language and conventions of any mathematical program in order to use it effectively. -- Andrzej Kozlowski Toyama International University JAPAN http://sigma.tuins.ac.jp http://eri2.tuins.ac.jp ---------- >From: "Drago Ganic" <drago.ganic at in2.hr> To: mathgroup at smc.vnet.net >To: mathgroup at smc.vnet.net >Subject: [mg19191] [mg19077] Re: equaltity of lists >Date: Thu, Aug 5, 1999, 7:35 AM > > Hi there, > > Thanks for the answers, but I still have questions. > > 1. I wanted to test the "objects" in a mathematical and not in > a structural way. Therefore I believe I have to use == (Equal) > not === (SameQ). > > 2. My reasoning was as follows > (I'm not a mathematician so maybe it's wrong) > > In Mathematics the Set is a very basic way to collect some > objects together and treat them as one. In Mathematica the > same thing (only finite sets) is implemented with a list > with ONE difference: a list has an order and a Set has not. > (You can never implement something without order in the > computer - you can only neglect the order). > > So mathematically spoken > the set {a, b} IS EQUAL TO the set {b, a}. > > I can get this behavior in Mathematica if I write > Union[{b, a}] == Union[{a, b}] > True > > But when I tread the objects {a,b} and {b,a} as lists the > answer to the question should be false if we look at the > list as a supplement to the set in a mathematical way. > > Of course the same is with > > a == a > True > > and > > a == b > a == b > > or > > x == x^2 > x == x^2 > > Why not False? I don't see that this is only a structural > question ("use SameQ, don't use Equal and you will get False"). > The functions x and x^2 are mathematically not Equal, so an Equal > should return False (the case x=1 is not important for function > equality). Isn't a variable x just a function f (x) = x? > > 3. Just another example > > Simplify[(x^2-1)/(x-1)] > 1+x > > But the two functions are not mathematically identical > (point x=1). > > When I try to plot the function > > Plot [(x^2-1)/(x-1),{x,-2,2}] > > I don't get the graph of the rational function (x^2-1)/(x-1). > Instead I get the graph of the linear function 1+x. > > When I ask > > Reduce [ (x^2-1)/(x-1) == 1 + x, x] > True > > What with x = 1 ? > > > Greetings > Drago Ganic > > P.J. Hinton <paulh at wolfram.com> wrote in message > news:Pine.LNX.4.10.9908030840160.1020-100000 at wabash.wolfram.com... >> On 2 Aug 1999, Drago Ganic wrote: >> >> > Hi !! >> > >> > Why don't I get an answer (False) when I ask Mathematica >> > >> > {a,b}=={b,a} >> > >> > like the one I get with >> > >> > {1,2}=={2,1} >> > False >> >> In order to get False as a result in your first example, you must use a >> stronger logical test function than Equal[]. You need to use SameQ[]. >> >> In[1]:= {a,b} === {b,a} >> >> Out[1]= False >> >> -- >> P.J. Hinton >> Mathematica Programming Group paulh at wolfram.com >> Wolfram Research, Inc. >> Disclaimer: Opinions expressed herein are those of the author alone. >> > > > >

**"LOLLIPOP" PLOTS FOR DISCRETE SEQUENCES**

**Re: Mathematica loosing input focus all the time**

**Re: equaltity of lists**

**Re: Re: equaltity of lists**