Re: goldbach prime partitions for arbitrary integer n => 4
- To: mathgroup at smc.vnet.net
- Subject: [mg43015] Re: goldbach prime partitions for arbitrary integer n => 4
- From: adams at wolfram.com (Adam Strzebonski)
- Date: Fri, 8 Aug 2003 00:26:29 -0400 (EDT)
- References: <bgsn4c$nnq$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
gilmar.rodriguez at nwfwmd.state.fl.us (Gilmar Rodríguez Pierluissi) wrote in message news:<bgsn4c$nnq$1 at smc.vnet.net>... > If one wishes to compute: > eqn={p+q==200}; constraints={2<=p<=100, p<=q, p,q \[Element]Primes}; > wouldn't it be nice that if you evaluate: > Solve[eqn,constraints,{p,q}] > you would get: > {{97,103},{73,127},{61,139},{43,157},{37,163},{19,181},{7,193},{3,197}} ? > A module (or program) that could solve: > eqn={p+q==n}; constraints={2<=p<=n/2, p<=q, p,q \[Element]Primes}; > Solve[eqn,constraints,{p,q}] > for a specified n, (n=>4, n \[Element]Integer), would be even better! > Thank you! In Mathematica 5 you can do it using Reduce, though it requires changing the value of a system option. By default Reduce writes out integer solutions of a <= x <= b explicitly if the number of integers in [a, b] is <= 10, otherwise the solutions are represented as x \[Element] Integers && a <= x <= b. For instance In[1]:= Reduce[1<=x<=10, x, Integers] Out[1]= x == 1 || x == 2 || x == 3 || x == 4 || x == 5 || x == 6 || x == 7 || > x == 8 || x == 9 || x == 10 In[2]:= Reduce[1<=x<=11, x, Integers] Out[2]= x \[Element] Integers && 1 <= x <= 11 This is why in your example we get In[3]:= Reduce[p+q==200 && 2<=p<=100 && p<=q, {p, q}, Primes] Out[3]= (p | q) \[Element] Primes && C[1] \[Element] Integers && > 2 <= C[1] <= 100 && p == C[1] && q == 200 - C[1] If we make Reduce write out integer solutions of 2 <= C[1] <= 100 explicitly, it will then be able to pick out the prime solutions. This can be done by changing the value of Reduce system option "DiscreteSolutionBound". In[4]:= Developer`SetSystemOptions["ReduceOptions"-> ("DiscreteSolutionBound"->Infinity)]; In[5]:= Reduce[p+q==200 && 2<=p<=100 && p<=q, {p, q}, Primes] Out[5]= p == 3 && q == 197 || p == 7 && q == 193 || p == 19 && q == 181 || > p == 37 && q == 163 || p == 43 && q == 157 || p == 61 && q == 139 || > p == 73 && q == 127 || p == 97 && q == 103 In[6]:= ans=Reduce[p+q==20000 && 2<=p<=10000 && p<=q, {p, q}, Primes];//Timing Out[6]= {3.15234 Second, Null} In[7]:= ans//Short Out[7]//Short= p == 3 && q == 19997 || <<230>> Best Regards, Adam Strzebonski Wolfram Research