Solve exp(x) = a with real solution only



I want to solve equations of the form exp(x/c) = v and obtain only a
real solution. I use this to solve equations in RC electronic
networks. Sometimes the equation is a bit more complicated with a factor
and a constant added to it, so I cannot just apply log to it. The
problem is that solve generates complex solutions and if c is large this
can become vey unwieldy.

(%i1) EQ: exp(x*5) = 0.5 ;

(%o1) %e^(5*x) = 0.5
(%i2) solve(EQ, x);

rat: replaced -0.5 by -1/2 = -0.5
(%o2) [x = log(%e^(2*%i*%pi/5)/2^(1/5)),x = log(%e^(4*%i*%pi/5)/2^(1/5)),
       x = -(log(2)+4*%i*%pi)/5,x = -(log(2)+2*%i*%pi)/5,x = -log(2)/5]
(%i3) declare(x, real);

(%o3) done
(%i4) solve(EQ, x);

rat: replaced -0.5 by -1/2 = -0.5
(%o4) [x = log(%e^(2*%i*%pi/5)/2^(1/5)),x = log(%e^(4*%i*%pi/5)/2^(1/5)),
       x = -(log(2)+4*%i*%pi)/5,x = -(log(2)+2*%i*%pi)/5,x = -log(2)/5]

You can see that the solution not only gives the real value but also the
logs of the complex fifth roots of 1 added to it. If you want complex
solutions this is of course correct. Unfortunately declaring x real
doesn't help. Apparently solve doesn't honor this. When the constant is
getting large, like in exp(x*1e9), there will be 1 billion solutions
generated which just takes too much time.

Is there a way to make solve just give the real solution?
-- 
Piet van Oostrum <piet at vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]