       Re: If[_, x_, x_] := x ?

• To: mathgroup at smc.vnet.net
• Subject: [mg43794] Re: [mg43791] If[_, x_, x_] := x ?
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Mon, 6 Oct 2003 02:07:48 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```On Saturday, October 4, 2003, at 03:05 PM, Selwyn Hollis wrote:

> Hi all,
>
> I just noticed the following (new in v. 5.0):
>
>    Sum[Cos[i*Pi/n], {i, 1, n}]
>
>       -1 + If[1/(2*n) \[Element] Integers, 0, 0]
>
> One would hope that this would make the desired simplification:
>
>    Simplify[Sum[Cos[i*Pi/n], {i, 1, n}], n \$B":(B Integers]
>
>       -1 + If[1/(2*n) \[Element] Integers, 0, 0]
>
> But apparently one must resort to this:
>
>    Simplify[Sum[Cos[i*(Pi/n)], {i, 1, n}],  Not[1/(2*n) \$B":(B Integers]]
>
>       -1
>
> So, two questions:
>
> (1) Is there a more elegant way to use Simplify to remedy something
> like this?
>
> (2) Is there any reason why you wouldn't want to have If[_, x_, x_] :=
> x in general?
>
>
> -----
> Selwyn Hollis
> http://www.math.armstrong.edu/faculty/hollis
>
>
>

1. I am not sure you will call this  "more elegant" but:

Simplify[ComplexExpand[Re[Sum[E^(I*((i*Pi)/n)),
{i, 1, n}]]], n \$B":(B Integers]
-1

2. In a way, yes. Note that:

If[a,x,y,z]

z

This is logical, since Mathematica  follows here "three-valued"" logic,
in other words a can be True, False or "something else". Of course, it
is not entirely definite what the "something else" ought to mean. One
usually thinks of it as "unknown" but it could also be something that
has no truth value at all. This is mathematically quite reasonable, for
example a could stand for an undecidable statement. Logically it would
not be appropriate for If[a,x,x] to return x in such a case.
(In practice of course it doesn't really matter either way).

Andrzej Kozlowski
Yokohama, Japan
http://www.mimuw.edu.pl/~akoz/
http://platon.c.u-tokyo.ac.jp/andrzej/

```

• Prev by Date: Re: Signal Processing Help please..
• Next by Date: lattice Schroedinger equation
• Previous by thread: Re: Make Mathematica wait for File
• Next by thread: lattice Schroedinger equation