Message Boards Message Boards

[?] Use Solve to get an integer solution?

Posted 7 years ago

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?

POSTED BY: Ray Lawicki
8 Replies

Try:

 FindInstance[3^(2 x - 1) == 27, x, Integers]
 (*{{x -> 2}}*)
POSTED BY: Mariusz Iwaniuk
Posted 7 years ago

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}}

POSTED BY: Ray Lawicki
Posted 7 years ago

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

POSTED BY: Ray Lawicki

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...

POSTED BY: Sander Huisman
Posted 7 years ago

thanks for the solution

POSTED BY: Ray Lawicki

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

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.

POSTED BY: Syed Huq
Posted 7 years ago

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

POSTED BY: Ray Lawicki
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract