Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I need to simplify a set of solutions of a system, say for example:

A := (a[1] == 3 && a[2] <= 1 && b[1] <= 5) || (a[1] == 3 && a[2] == 1 && b[1] == -7)

I care only about a[1] and a[2] but I can not use Eliminate since I have inequalities. So one solution is:

Simplify[Reduce[Exists[{b[1]}, A]]]

a[1] == 3 && a[2] <= 1

It works! But since I have a large system (many b's) I need to automate this. Since:

Array[b, 1]

{b[1]}

I tried:

Simplify[Reduce[Exists[Array[b,1],A]]]

a[1] == 3 && a[2] <= 1 && b[1] <= 5

The second method yields the wrong outcome! What am I doing wrong here?

share|improve this question
    
I just noticed you deleted your other question... did you get an answer? I was midway through writing one... –  rm -rf Mar 28 '13 at 23:59
    
sorry for wasting your time! after digging more I found this mathematica.stackexchange.com/questions/3070/… which solves my other problem. thanks. –  Sergio Parreiras Mar 29 '13 at 1:24
    
Ok, no problem. In any case, what you had was mostly fine; you just needed to use HoldPattern. For example, HoldPattern[a@# == _] -> True & /@ Range@5 will generate replacement rules for a[1] through a[5] –  rm -rf Mar 29 '13 at 1:38
add comment

2 Answers

up vote 4 down vote accepted

Exists has attribute HoldAll:

Attributes[Exists]
(* {HoldAll, Protected, ReadProtected} *)

You need to do

Simplify@Reduce@Exists[Evaluate@Array[b, 1], A]
(* a[1] == 3 && a[2] <= 1 *)
share|improve this answer
    
Heh, guess you beat me to it. Didn't see your answer until I entered mine. –  VF1 Mar 27 '13 at 0:43
add comment

Exists has the attribute HoldAll:

Attributes[Exists]
(* {HoldAll, Protected, ReadProtected} *)

As such, specifying Exists[Array[b, 1], A] in your argument for Reduce is the same thing as telling that there is exists a value for the symbol of the form Array[b,1], verbatim, which makes A true.

Using Evaluate to make sure that Array is expanded into its appropriate set of values, you can achieve the desired result:

Simplify[Reduce[Exists[Evaluate[Array[b, 1]], A]]]
(* a[1] == 3 && a[2] <= 1 *)
share|improve this answer
    
LOL! Our answers are identical! :D –  Federico Mar 27 '13 at 0:43
    
We also adopted the same style for posting code: code followed by (* return value *). You just wrote a little more explanation. I'm tired instead, 2AM here... Good night! –  Federico Mar 27 '13 at 0:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.