# \[?\] Use Solve to get an integer solution?

**URL:** <https://community.wolfram.com/t/use-solve-to-get-an-integer-solution/10373>\
**Category:** Questions\
**Tags:** algebra, equation-solving, symbolic-computations\
**Created:** [April 22, 2017, 6:33am UTC](https://community.wolfram.com/t/use-solve-to-get-an-integer-solution/10373 "2017-04-22T06:33:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![lawickirayp](https://avatars.discourse-cdn.com/v4/letter/l/ee59a6/32.png) [@lawickirayp](https://community.wolfram.com/u/lawickirayp)\
**Post date:** [April 22, 2017, 6:33am UTC](https://community.wolfram.com/t/use-solve-to-get-an-integer-solution/10373/1 "2017-04-22T06:33:24Z")

</div>

How do I get Mathematica to solve 3^(2x-1)=27 . if i type

```
Solve[3^(2x-1)==27,x] 

```

I get a complex response which is obviously wrong since the answer is 3?

---

<div class="post-metadata">

**Author:** ![syedh](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@syedh](https://community.wolfram.com/u/syedh)\
**Post date:** [April 22, 2017, 6:39am UTC](https://community.wolfram.com/t/use-solve-to-get-an-integer-solution/10373/2 "2017-04-22T06:39:45Z")

</div>

Try **Solve[3^(2x-1)==27,x,Integers]** or **Solve[3^(2x-1)==27,x,Reals]**, it gives you 2, which should be the answer.

---

<div class="post-metadata">

**Author:** ![vaungureanu](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/vaungureanu/32/23129_2.png) [@vaungureanu](https://community.wolfram.com/u/vaungureanu)\
**Post date:** [April 22, 2017, 7:12am UTC](https://community.wolfram.com/t/use-solve-to-get-an-integer-solution/10373/3 "2017-04-22T07:12:58Z")

</div>

You may use also the function Reduce[]:

```
In[1]:= Reduce[3^(2 x - 1) == 27, x, Integers]
        Reduce[3^(2 x - 1) == 27, x, Reals]

Out[1]= x == 2
Out[2]= x == 2

```

---

<div class="post-metadata">

**Author:** ![sghuisman](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sghuisman/32/27850_2.png) [@sghuisman](https://community.wolfram.com/u/sghuisman)\
**Post date:** [April 22, 2017, 7:13pm UTC](https://community.wolfram.com/t/use-solve-to-get-an-integer-solution/10373/4 "2017-04-22T19:13:57Z")

</div>

There are actually an infinite number of answers, but only one that is real (as said above).

```
ConditionalExpression[1/2 (1 + (2 I \[Pi] C[1])/Log[3] + Log[27]/Log[3]), C[1] \[Element] Integers]

```

This basically means that x can be the above expression for every choice of C[1] as an integer. C[1] = 0 corresponds to x = 2. The only Real solution…

---

<div class="post-metadata">

**Author:** ![lawickirayp](https://avatars.discourse-cdn.com/v4/letter/l/ee59a6/32.png) [@lawickirayp](https://community.wolfram.com/u/lawickirayp)\
**Post date:** [April 23, 2017, 1:52am UTC](https://community.wolfram.com/t/use-solve-to-get-an-integer-solution/10373/5 "2017-04-23T01:52:30Z")

</div>

thanks for the solution i did not realise that restricting the domain to real was the trick

---

<div class="post-metadata">

**Author:** ![lawickirayp](https://avatars.discourse-cdn.com/v4/letter/l/ee59a6/32.png) [@lawickirayp](https://community.wolfram.com/u/lawickirayp)\
**Post date:** [April 23, 2017, 1:53am UTC](https://community.wolfram.com/t/use-solve-to-get-an-integer-solution/10373/6 "2017-04-23T01:53:20Z")

</div>

thanks for the solution i did not realise that restricting the domain to real was the trick

---

<div class="post-metadata">

**Author:** ![lawickirayp](https://avatars.discourse-cdn.com/v4/letter/l/ee59a6/32.png) [@lawickirayp](https://community.wolfram.com/u/lawickirayp)\
**Post date:** [April 23, 2017, 1:54am UTC](https://community.wolfram.com/t/use-solve-to-get-an-integer-solution/10373/7 "2017-04-23T01:54:38Z")

</div>

thanks for the solution

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [April 23, 2017, 1:02pm UTC](https://community.wolfram.com/t/use-solve-to-get-an-integer-solution/10373/8 "2017-04-23T13:02:35Z")

</div>

Try:

```
 FindInstance[3^(2 x - 1) == 27, x, Integers]
 (*{{x -> 2}}*)

```

---

<div class="post-metadata">

**Author:** ![lawickirayp](https://avatars.discourse-cdn.com/v4/letter/l/ee59a6/32.png) [@lawickirayp](https://community.wolfram.com/u/lawickirayp)\
**Post date:** [April 24, 2017, 7:37am UTC](https://community.wolfram.com/t/use-solve-to-get-an-integer-solution/10373/9 "2017-04-24T07:37:48Z")

</div>

thanks for the hint. it seems to work with solve, reduce and findinstance as long as the expression is followed by “integers” or “reals” which i neglected to add to the problem.  
Solve[3^(2 x - 1) == 27, x, Integers]  
{{x → 2}}
