[Date Index]
[Thread Index]
[Author Index]
Re: Solving equations and inequalities with Reduce - how?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg87715] Re: Solving equations and inequalities with Reduce - how?
*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
*Date*: Wed, 16 Apr 2008 05:01:30 -0400 (EDT)
*Organization*: The Open University, Milton Keynes, UK
*References*: <fu1tuf$ogc$1@smc.vnet.net>
Marc Heusser wrote:
> I tried to solve equations with Reduce and somehow did not quite
> formulate it right, so Reduce complains with
> "Reduce::ivar: 1 is not a valid variable".
>
> This is what I tried:
>
> Wanted: A six digit number satisfying the following conditions:
> The first digit is not zero.
> If you take the first two digits and move them to the end of the number,
> the resulting number must be twice the original number.
>
> In[23]:=Reduce[200000a +20000 b +2000 c+200 d+20 e + 2 f
> \[Equal]100000c +10000 d +1000 e+100 f+10 a + b , {a,b,c,d,e,f},
> Modulus\[Rule]9]
>
> I did solve the problem through exhaustive search:
>
> In[14]:=Timing[Select[Range[10^6], FractionalPart[#/10000] 1000000 +
> IntegerPart[#/10000]\[Equal] 2 #&]]
> Out[14]={34.2848 Second,{142857,285714,428571}}
>
> but would like to understand how to use Reduce (or another function) to
> solve such a set of equations.
Marc,
First, one of your variables had been set to the value one before you
tried Reduce[].
Second, the option Modulus->9 is not doing what you may have in mind
(the solution yield by Reduce[] does not fulfill your original criteria ).
Third, using FindInstance[] may help to formulate and check your problem
in an algebraic way.
For instance, starting with a fresh kernel,
In[1]:= eqn =
200000 a + 20000 b + 2000 c + 200 d + 20 e + 2 f ==
100000 c + 10000 d + 1000 e + 100 f + 10 a + b;
In[2]:= Reduce[eqn && a != 0, {a, b, c, d, e, f}, Modulus -> 9]
Out[2]= a != 0 && a == C[1] && b == C[2] && c == C[3] && d == C[4] &&
e == C[5] && f == 8 C[1] + 8 C[2] + 8 C[3] + 8 C[4] + 8 C[5]
In[3]:= FindInstance[eqn && a != 0, {a, b, c, d, e, f},
Modulus -> 10]
eqn /. %[[1]]
Out[3]= {{a -> 1, b -> 0, c -> 0, d -> 0, e -> 0, f -> 0}}
Out[4]= False
In[5]:= FindInstance[eqn && a != 0, {a, b, c, d, e, f}, Integers]
eqn /. %[[1]]
Out[5]= {{a -> 1, b -> 4, c -> 0, d -> 0, e -> 0, f -> 2857}}
Out[6]= True
Regards,
-- Jean-Marc
Prev by Date:
**ListPlot & lots 'o dots.**
Next by Date:
**Re: Re: Deleting Integrate[] transformation rule (some**
Previous by thread:
**Re: Solving equations and inequalities with Reduce - how?**
Next by thread:
** Re: Deleting Integrate[] transformation rule (some progress)**
| |