[Date Index]
[Thread Index]
[Author Index]
Re: Re: equaltity of lists
*To*: mathgroup at smc.vnet.net
*Subject*: [mg19139] Re: [mg19077] Re: equaltity of lists
*From*: "David Park" <djmp at earthlink.net>
*Date*: Thu, 5 Aug 1999 23:58:42 -0400
*Sender*: owner-wri-mathgroup at wolfram.com
Drago,
But still, treating the objects as lists, and a and b as variables, you can't know if
they are equal or not. But if you make a and b objects by making them strings
Mathematica does return False.
{"a", "b"} == {"b", "a"}
False
Or, if you really want to use symbols, you could use something like the following:
SetAttributes[equal2, Listable];
equal2[a_Symbol, b_Symbol] := If[a === b, True, False]
And @@ {a, b}~equal2~{b, a}
False
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
>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.
>>
>
>
>
>
Prev by Date:
**Any Hazards When Installing V3 and V4 in Parallel?**
Next by Date:
**Re: Can someone explain this?**
Previous by thread:
**Re: equaltity of lists**
Next by thread:
**Re: equaltity of lists**
| |